From 518b3f7eeed94027673b55b6f459a22983ac542f Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Wed, 28 Feb 2018 15:33:36 -0800 Subject: Update libc to bring in posix_spawn bindings for FreeBSD. --- src/liblibc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/liblibc b/src/liblibc index 56444a4545b..8bed48a7515 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit 56444a4545bd71430d64b86b8a71714cfdbe9f5d +Subproject commit 8bed48a751562c1c396b361bb6940c677268e997 -- cgit 1.4.1-3-g733a5 From 11696acd6d070a90e8dd386a3c9ae877740fb0e2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 25 Jan 2018 18:13:45 -0800 Subject: Support posix_spawn() when possible. --- src/libstd/sys/unix/process/process_unix.rs | 102 ++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index 189280a4ba9..d66c2375140 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -24,6 +24,7 @@ impl Command { -> io::Result<(Process, StdioPipes)> { use sys; + const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX"; let envp = self.capture_env(); @@ -34,6 +35,11 @@ impl Command { } let (ours, theirs) = self.setup_io(default, needs_stdin)?; + + if let Some(ret) = self.posix_spawn(&theirs, envp.as_ref())? { + return Ok((ret, ours)) + } + let (input, output) = sys::pipe::anon_pipe()?; let pid = unsafe { @@ -229,6 +235,102 @@ impl Command { libc::execvp(self.get_argv()[0], self.get_argv().as_ptr()); io::Error::last_os_error() } + + #[cfg(not(any(target_os = "linux", target_os = "macos")))] + fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) + -> io::Result> + { + Ok(None) + } + + #[cfg(any(target_os = "linux", target_os = "macos"))] + fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) + -> io::Result> + { + use mem; + use sys; + + if self.get_cwd().is_some() || + self.get_gid().is_some() || + self.get_uid().is_some() || + self.get_closures().len() != 0 { + return Ok(None) + } + + let mut p = Process { pid: 0, status: None }; + + struct PosixSpawnFileActions(libc::posix_spawn_file_actions_t); + + impl Drop for PosixSpawnFileActions { + fn drop(&mut self) { + unsafe { + libc::posix_spawn_file_actions_destroy(&mut self.0); + } + } + } + + struct PosixSpawnattr(libc::posix_spawnattr_t); + + impl Drop for PosixSpawnattr { + fn drop(&mut self) { + unsafe { + libc::posix_spawnattr_destroy(&mut self.0); + } + } + } + + unsafe { + let mut file_actions = PosixSpawnFileActions(mem::zeroed()); + let mut attrs = PosixSpawnattr(mem::zeroed()); + + libc::posix_spawnattr_init(&mut attrs.0); + libc::posix_spawn_file_actions_init(&mut file_actions.0); + + if let Some(fd) = stdio.stdin.fd() { + cvt(libc::posix_spawn_file_actions_adddup2(&mut file_actions.0, + fd, + libc::STDIN_FILENO))?; + } + if let Some(fd) = stdio.stdout.fd() { + cvt(libc::posix_spawn_file_actions_adddup2(&mut file_actions.0, + fd, + libc::STDOUT_FILENO))?; + } + if let Some(fd) = stdio.stderr.fd() { + cvt(libc::posix_spawn_file_actions_adddup2(&mut file_actions.0, + fd, + libc::STDERR_FILENO))?; + } + + let mut set: libc::sigset_t = mem::zeroed(); + cvt(libc::sigemptyset(&mut set))?; + cvt(libc::posix_spawnattr_setsigmask(&mut attrs.0, + &set))?; + cvt(libc::sigaddset(&mut set, libc::SIGPIPE))?; + cvt(libc::posix_spawnattr_setsigdefault(&mut attrs.0, + &set))?; + + let flags = libc::POSIX_SPAWN_SETSIGDEF | + libc::POSIX_SPAWN_SETSIGMASK; + cvt(libc::posix_spawnattr_setflags(&mut attrs.0, flags as _))?; + + let envp = envp.map(|c| c.as_ptr()) + .unwrap_or(sys::os::environ() as *const _); + let ret = libc::posix_spawnp( + &mut p.pid, + self.get_argv()[0], + &file_actions.0, + &attrs.0, + self.get_argv().as_ptr() as *const _, + envp as *const _, + ); + if ret == 0 { + Ok(Some(p)) + } else { + Err(io::Error::last_os_error()) + } + } + } } //////////////////////////////////////////////////////////////////////////////// -- cgit 1.4.1-3-g733a5 From f4633865d37dea15a88220e886e77839aa1fd1ba Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 26 Feb 2018 17:33:44 -0800 Subject: Avoid error for unused variables --- src/libstd/sys/unix/process/process_unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index d66c2375140..05b4b9b085b 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -237,7 +237,7 @@ impl Command { } #[cfg(not(any(target_os = "linux", target_os = "macos")))] - fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) + fn posix_spawn(&mut self, _stdio: &ChildPipes, _envp: Option<&CStringArray>) -> io::Result> { Ok(None) -- cgit 1.4.1-3-g733a5 From 94630e4ca509f9b37e4c066eee94f40da12cba51 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 26 Feb 2018 20:23:46 -0800 Subject: No need to zero when an initializer for the object is already used. --- src/libstd/sys/unix/process/process_unix.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index 05b4b9b085b..b394d5ff41a 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -280,8 +280,8 @@ impl Command { } unsafe { - let mut file_actions = PosixSpawnFileActions(mem::zeroed()); - let mut attrs = PosixSpawnattr(mem::zeroed()); + let mut file_actions = PosixSpawnFileActions(mem::uninitialized()); + let mut attrs = PosixSpawnattr(mem::uninitialized()); libc::posix_spawnattr_init(&mut attrs.0); libc::posix_spawn_file_actions_init(&mut file_actions.0); @@ -302,7 +302,7 @@ impl Command { libc::STDERR_FILENO))?; } - let mut set: libc::sigset_t = mem::zeroed(); + let mut set: libc::sigset_t = mem::uninitialized(); cvt(libc::sigemptyset(&mut set))?; cvt(libc::posix_spawnattr_setsigmask(&mut attrs.0, &set))?; -- cgit 1.4.1-3-g733a5 From 8e3fa0d3c450051d6445aa82682416eb307b2d5b Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 26 Feb 2018 23:51:19 -0800 Subject: Pass proper pointer for envp. --- src/libstd/sys/unix/process/process_unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index b394d5ff41a..9765ff37e9b 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -315,7 +315,7 @@ impl Command { cvt(libc::posix_spawnattr_setflags(&mut attrs.0, flags as _))?; let envp = envp.map(|c| c.as_ptr()) - .unwrap_or(sys::os::environ() as *const _); + .unwrap_or(*sys::os::environ() as *const _); let ret = libc::posix_spawnp( &mut p.pid, self.get_argv()[0], -- cgit 1.4.1-3-g733a5 From b3ecf5f57ca9d34d10ffd9d064a027ce3f4888ac Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 26 Feb 2018 23:51:39 -0800 Subject: Remove excess newline --- src/libstd/sys/unix/process/process_unix.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index 9765ff37e9b..fa66245abb6 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -24,7 +24,6 @@ impl Command { -> io::Result<(Process, StdioPipes)> { use sys; - const CLOEXEC_MSG_FOOTER: &'static [u8] = b"NOEX"; let envp = self.capture_env(); -- cgit 1.4.1-3-g733a5 From 85b82f254e28f5e50b25d8e096af0f01e4441ef7 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Tue, 27 Feb 2018 14:12:52 -0800 Subject: Support posix_spawn() for FreeBSD. spawn() is expected to return an error if the specified file could not be executed. FreeBSD's posix_spawn() supports returning ENOENT/ENOEXEC if the exec() fails, which not all platforms support. This brings a very significant performance improvement for FreeBSD, involving heavy use of Command in threads, due to fork() invoking jemalloc fork handlers and causing lock contention. FreeBSD's posix_spawn() avoids this problem due to using vfork() internally. --- src/libstd/sys/unix/process/process_unix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index fa66245abb6..c7841a861ce 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -235,14 +235,14 @@ impl Command { io::Error::last_os_error() } - #[cfg(not(any(target_os = "linux", target_os = "macos")))] + #[cfg(not(any(target_os = "freebsd")))] fn posix_spawn(&mut self, _stdio: &ChildPipes, _envp: Option<&CStringArray>) -> io::Result> { Ok(None) } - #[cfg(any(target_os = "linux", target_os = "macos"))] + #[cfg(any(target_os = "freebsd"))] fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) -> io::Result> { -- cgit 1.4.1-3-g733a5 From e6efd0d640742ed4a2fbd32fe79fb743772838cc Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Wed, 28 Feb 2018 19:09:59 -0800 Subject: Add a specific test for spawn() returning ENOENT --- src/test/run-pass/process-spawn-nonexistent.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/run-pass/process-spawn-nonexistent.rs diff --git a/src/test/run-pass/process-spawn-nonexistent.rs b/src/test/run-pass/process-spawn-nonexistent.rs new file mode 100644 index 00000000000..9219cd625f3 --- /dev/null +++ b/src/test/run-pass/process-spawn-nonexistent.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-cloudabi no processes +// ignore-emscripten no processes + +use std::io::ErrorKind; +use std::process::Command; + +fn main() { + assert_eq!(Command::new("nonexistent") + .spawn() + .unwrap_err() + .kind(), + ErrorKind::NotFound); +} -- cgit 1.4.1-3-g733a5 From a9ea876960a06f3ae00049515bf9ef706cca806b Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Wed, 28 Feb 2018 22:16:35 -0800 Subject: posix_spawn() always returns its error rather than setting errno. --- src/libstd/sys/unix/process/process_unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index c7841a861ce..c5dda6273ef 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -326,7 +326,7 @@ impl Command { if ret == 0 { Ok(Some(p)) } else { - Err(io::Error::last_os_error()) + Err(io::Error::from_raw_os_error(ret)) } } } -- cgit 1.4.1-3-g733a5 From 2e2d9260f9425cd700199383096d8201190737de Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Thu, 1 Mar 2018 09:17:49 -0800 Subject: posix_spawn() on OSX supports returning ENOENT. --- src/libstd/sys/unix/process/process_unix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index c5dda6273ef..dcf0278b4aa 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -235,14 +235,14 @@ impl Command { io::Error::last_os_error() } - #[cfg(not(any(target_os = "freebsd")))] + #[cfg(not(any(target_os = "macos", target_os = "freebsd")))] fn posix_spawn(&mut self, _stdio: &ChildPipes, _envp: Option<&CStringArray>) -> io::Result> { Ok(None) } - #[cfg(any(target_os = "freebsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd"))] fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) -> io::Result> { -- cgit 1.4.1-3-g733a5 From ef73b3ae2eac3a03f5b966a4f8b2a568e3619d51 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Thu, 1 Mar 2018 09:18:16 -0800 Subject: Add comment explaining when posix_spawn() can be supported. --- src/libstd/sys/unix/process/process_unix.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index dcf0278b4aa..bd6a8d3f64b 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -242,6 +242,8 @@ impl Command { Ok(None) } + // Only support platforms for which posix_spawn() can return ENOENT + // directly. #[cfg(any(target_os = "macos", target_os = "freebsd"))] fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) -> io::Result> -- cgit 1.4.1-3-g733a5 From 99b50efb6eb048297cda699ad017821822591d7a Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Fri, 2 Mar 2018 08:50:37 -0800 Subject: Use _ --- src/libstd/sys/unix/process/process_unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index bd6a8d3f64b..51ae0aa7315 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -236,7 +236,7 @@ impl Command { } #[cfg(not(any(target_os = "macos", target_os = "freebsd")))] - fn posix_spawn(&mut self, _stdio: &ChildPipes, _envp: Option<&CStringArray>) + fn posix_spawn(&mut self, _: &ChildPipes, _: Option<&CStringArray>) -> io::Result> { Ok(None) -- cgit 1.4.1-3-g733a5 From 5ba6b3a728fb50cd65237b8eeac2f2df05c3c77f Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Fri, 2 Mar 2018 12:50:07 -0800 Subject: Move glibc version lookup handling to sys::os and add a simpler glibc_version() --- src/libstd/sys/unix/net.rs | 33 +++++---------------------------- src/libstd/sys/unix/os.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs index 3f65975e608..04d9f0b06d3 100644 --- a/src/libstd/sys/unix/net.rs +++ b/src/libstd/sys/unix/net.rs @@ -383,12 +383,12 @@ impl IntoInner for Socket { // believe it's thread-safe). #[cfg(target_env = "gnu")] fn on_resolver_failure() { + use sys; + // If the version fails to parse, we treat it the same as "not glibc". - if let Some(Ok(version_str)) = glibc_version_cstr().map(CStr::to_str) { - if let Some(version) = parse_glibc_version(version_str) { - if version < (2, 26) { - unsafe { libc::res_init() }; - } + if let Some(version) = sys::os::glibc_version() { + if version < (2, 26) { + unsafe { libc::res_init() }; } } } @@ -396,29 +396,6 @@ fn on_resolver_failure() { #[cfg(not(target_env = "gnu"))] fn on_resolver_failure() {} -#[cfg(target_env = "gnu")] -fn glibc_version_cstr() -> Option<&'static CStr> { - weak! { - fn gnu_get_libc_version() -> *const libc::c_char - } - if let Some(f) = gnu_get_libc_version.get() { - unsafe { Some(CStr::from_ptr(f())) } - } else { - None - } -} - -// Returns Some((major, minor)) if the string is a valid "x.y" version, -// ignoring any extra dot-separated parts. Otherwise return None. -#[cfg(target_env = "gnu")] -fn parse_glibc_version(version: &str) -> Option<(usize, usize)> { - let mut parsed_ints = version.split(".").map(str::parse::).fuse(); - match (parsed_ints.next(), parsed_ints.next()) { - (Some(Ok(major)), Some(Ok(minor))) => Some((major, minor)), - _ => None - } -} - #[cfg(all(test, taget_env = "gnu"))] mod test { use super::*; diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index a46e855b4a6..4c86fddee4b 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -546,3 +546,35 @@ pub fn getpid() -> u32 { pub fn getppid() -> u32 { unsafe { libc::getppid() as u32 } } + +#[cfg(target_env = "gnu")] +pub fn glibc_version() -> Option<(usize, usize)> { + if let Some(Ok(version_str)) = glibc_version_cstr().map(CStr::to_str) { + parse_glibc_version(version_str) + } else { + None + } +} + +#[cfg(target_env = "gnu")] +fn glibc_version_cstr() -> Option<&'static CStr> { + weak! { + fn gnu_get_libc_version() -> *const libc::c_char + } + if let Some(f) = gnu_get_libc_version.get() { + unsafe { Some(CStr::from_ptr(f())) } + } else { + None + } +} + +// Returns Some((major, minor)) if the string is a valid "x.y" version, +// ignoring any extra dot-separated parts. Otherwise return None. +#[cfg(target_env = "gnu")] +fn parse_glibc_version(version: &str) -> Option<(usize, usize)> { + let mut parsed_ints = version.split(".").map(str::parse::).fuse(); + match (parsed_ints.next(), parsed_ints.next()) { + (Some(Ok(major)), Some(Ok(minor))) => Some((major, minor)), + _ => None + } +} -- cgit 1.4.1-3-g733a5 From d740083fc8981ee933dc48a6b3dcee21b82c993e Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Fri, 2 Mar 2018 13:02:38 -0800 Subject: Support posix_spawn() for Linux glibc 2.24+. The relevant support was added in https://sourceware.org/bugzilla/show_bug.cgi?id=10354#c12 --- src/libstd/sys/unix/process/process_unix.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index 51ae0aa7315..29e33ee822e 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -235,7 +235,8 @@ impl Command { io::Error::last_os_error() } - #[cfg(not(any(target_os = "macos", target_os = "freebsd")))] + #[cfg(not(any(target_os = "macos", target_os = "freebsd", + all(target_os = "linux", target_env = "gnu"))))] fn posix_spawn(&mut self, _: &ChildPipes, _: Option<&CStringArray>) -> io::Result> { @@ -244,7 +245,8 @@ impl Command { // Only support platforms for which posix_spawn() can return ENOENT // directly. - #[cfg(any(target_os = "macos", target_os = "freebsd"))] + #[cfg(any(target_os = "macos", target_os = "freebsd", + all(target_os = "linux", target_env = "gnu")))] fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>) -> io::Result> { @@ -258,6 +260,18 @@ impl Command { return Ok(None) } + // Only glibc 2.24+ posix_spawn() supports returning ENOENT directly. + #[cfg(all(target_os = "linux", target_env = "gnu"))] + { + if let Some(version) = sys::os::glibc_version() { + if version < (2, 24) { + return Ok(None) + } + } else { + return Ok(None) + } + } + let mut p = Process { pid: 0, status: None }; struct PosixSpawnFileActions(libc::posix_spawn_file_actions_t); -- cgit 1.4.1-3-g733a5 From 81130ed4b104adf28921120416dcc9db3253c996 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 10 Mar 2018 11:22:55 +0100 Subject: Split param-bounds-ignored into two, it was testing two independent things Also, tweak the test for ignored type aliases such that replacing the type alias by a newtype struct leads to a well-formed type definition, and errors when used the way the type alias is used. --- src/test/ui/higher-lifetime-bounds.rs | 79 +++++++++++++++++++++++ src/test/ui/higher-lifetime-bounds.stderr | 68 ++++++++++++++++++++ src/test/ui/param-bounds-ignored.rs | 103 ------------------------------ src/test/ui/param-bounds-ignored.stderr | 94 --------------------------- src/test/ui/type-alias-bounds.rs | 51 +++++++++++++++ src/test/ui/type-alias-bounds.stderr | 32 ++++++++++ 6 files changed, 230 insertions(+), 197 deletions(-) create mode 100644 src/test/ui/higher-lifetime-bounds.rs create mode 100644 src/test/ui/higher-lifetime-bounds.stderr delete mode 100644 src/test/ui/param-bounds-ignored.rs delete mode 100644 src/test/ui/param-bounds-ignored.stderr create mode 100644 src/test/ui/type-alias-bounds.rs create mode 100644 src/test/ui/type-alias-bounds.stderr diff --git a/src/test/ui/higher-lifetime-bounds.rs b/src/test/ui/higher-lifetime-bounds.rs new file mode 100644 index 00000000000..70b3b34fbd8 --- /dev/null +++ b/src/test/ui/higher-lifetime-bounds.rs @@ -0,0 +1,79 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code, non_camel_case_types)] + +// Test that bounds on higher-kinded lifetime binders are rejected. + +fn bar1<'a, 'b>( + x: &'a i32, + y: &'b i32, + f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) + //~^ ERROR lifetime bounds cannot be used in this context +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( + //~^ ERROR lifetime bounds cannot be used in this context + x: &'a i32, + y: &'b i32, + f: F) +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +fn bar3<'a, 'b, F>( + x: &'a i32, + y: &'b i32, + f: F) + where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 + //~^ ERROR lifetime bounds cannot be used in this context +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +fn bar4<'a, 'b, F>( + x: &'a i32, + y: &'b i32, + f: F) + where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 + //~^ ERROR lifetime bounds cannot be used in this context +{ + // If the bound in f's type would matter, the call below would (have to) + // be rejected. + f(x, y); +} + +struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); +//~^ ERROR lifetime bounds cannot be used in this context +struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; +//~^ ERROR lifetime bounds cannot be used in this context +struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; +//~^ ERROR lifetime bounds cannot be used in this context + +struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); +//~^ ERROR lifetime bounds cannot be used in this context + +type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; +//~^ ERROR lifetime bounds cannot be used in this context + +fn main() { + let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; + //~^ ERROR lifetime bounds cannot be used in this context + let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + //~^ ERROR lifetime bounds cannot be used in this context +} diff --git a/src/test/ui/higher-lifetime-bounds.stderr b/src/test/ui/higher-lifetime-bounds.stderr new file mode 100644 index 00000000000..82c00747436 --- /dev/null +++ b/src/test/ui/higher-lifetime-bounds.stderr @@ -0,0 +1,68 @@ +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:18:22 + | +LL | f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) + | ^^^ ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:26:34 + | +LL | fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:41:28 + | +LL | where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:53:25 + | +LL | where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:61:28 + | +LL | struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:63:40 + | +LL | struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:65:37 + | +LL | struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:68:29 + | +LL | struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:71:29 + | +LL | type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:75:34 + | +LL | let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; + | ^^^ + +error: lifetime bounds cannot be used in this context + --> $DIR/higher-lifetime-bounds.rs:77:38 + | +LL | let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; + | ^^^ + +error: aborting due to 11 previous errors + diff --git a/src/test/ui/param-bounds-ignored.rs b/src/test/ui/param-bounds-ignored.rs deleted file mode 100644 index 94bcdec9450..00000000000 --- a/src/test/ui/param-bounds-ignored.rs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code, non_camel_case_types)] - -use std::rc::Rc; - -type SVec = Vec; -//~^ WARN bounds on generic parameters are ignored in type aliases -type VVec<'b, 'a: 'b+'b> = Vec<&'a i32>; -//~^ WARN bounds on generic parameters are ignored in type aliases -type WVec<'b, T: 'b+'b> = Vec; -//~^ WARN bounds on generic parameters are ignored in type aliases -type W2Vec<'b, T> where T: 'b, T: 'b = Vec; -//~^ WARN where clauses are ignored in type aliases - -fn foo<'a>(y: &'a i32) { - // If the bounds above would matter, the code below would be rejected. - let mut x : SVec<_> = Vec::new(); - x.push(Rc::new(42)); - - let mut x : VVec<'static, 'a> = Vec::new(); - x.push(y); - - let mut x : WVec<'static, & 'a i32> = Vec::new(); - x.push(y); - - let mut x : W2Vec<'static, & 'a i32> = Vec::new(); - x.push(y); -} - -fn bar1<'a, 'b>( - x: &'a i32, - y: &'b i32, - f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) - //~^ ERROR lifetime bounds cannot be used in this context -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( - //~^ ERROR lifetime bounds cannot be used in this context - x: &'a i32, - y: &'b i32, - f: F) -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -fn bar3<'a, 'b, F>( - x: &'a i32, - y: &'b i32, - f: F) - where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 - //~^ ERROR lifetime bounds cannot be used in this context -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -fn bar4<'a, 'b, F>( - x: &'a i32, - y: &'b i32, - f: F) - where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 - //~^ ERROR lifetime bounds cannot be used in this context -{ - // If the bound in f's type would matter, the call below would (have to) - // be rejected. - f(x, y); -} - -struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); -//~^ ERROR lifetime bounds cannot be used in this context -struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; -//~^ ERROR lifetime bounds cannot be used in this context -struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; -//~^ ERROR lifetime bounds cannot be used in this context - -struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); -//~^ ERROR lifetime bounds cannot be used in this context - -type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; -//~^ ERROR lifetime bounds cannot be used in this context - -fn main() { - let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; - //~^ ERROR lifetime bounds cannot be used in this context - let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; - //~^ ERROR lifetime bounds cannot be used in this context -} diff --git a/src/test/ui/param-bounds-ignored.stderr b/src/test/ui/param-bounds-ignored.stderr deleted file mode 100644 index 657fec54f96..00000000000 --- a/src/test/ui/param-bounds-ignored.stderr +++ /dev/null @@ -1,94 +0,0 @@ -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:42:22 - | -LL | f: for<'xa, 'xb: 'xa+'xa> fn(&'xa i32, &'xb i32) -> &'xa i32) - | ^^^ ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:50:34 - | -LL | fn bar2<'a, 'b, F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32>( - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:65:28 - | -LL | where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32 - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:77:25 - | -LL | where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32 - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:85:28 - | -LL | struct S1 Fn(&'xa i32, &'xb i32) -> &'xa i32>(F); - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:87:40 - | -LL | struct S2(F) where F: for<'xa, 'xb: 'xa> Fn(&'xa i32, &'xb i32) -> &'xa i32; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:89:37 - | -LL | struct S3(F) where for<'xa, 'xb: 'xa> F: Fn(&'xa i32, &'xb i32) -> &'xa i32; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:92:29 - | -LL | struct S_fnty(for<'xa, 'xb: 'xa> fn(&'xa i32, &'xb i32) -> &'xa i32); - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:95:29 - | -LL | type T1 = Box Fn(&'xa i32, &'xb i32) -> &'xa i32>; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:99:34 - | -LL | let _ : Option fn(&'xa i32, &'xb i32) -> &'xa i32> = None; - | ^^^ - -error: lifetime bounds cannot be used in this context - --> $DIR/param-bounds-ignored.rs:101:38 - | -LL | let _ : Option Fn(&'xa i32, &'xb i32) -> &'xa i32>> = None; - | ^^^ - -warning: bounds on generic parameters are ignored in type aliases - --> $DIR/param-bounds-ignored.rs:15:14 - | -LL | type SVec = Vec; - | ^^^^ ^^^^ - | - = note: #[warn(ignored_generic_bounds)] on by default - -warning: bounds on generic parameters are ignored in type aliases - --> $DIR/param-bounds-ignored.rs:17:19 - | -LL | type VVec<'b, 'a: 'b+'b> = Vec<&'a i32>; - | ^^ ^^ - -warning: bounds on generic parameters are ignored in type aliases - --> $DIR/param-bounds-ignored.rs:19:18 - | -LL | type WVec<'b, T: 'b+'b> = Vec; - | ^^ ^^ - -warning: where clauses are ignored in type aliases - --> $DIR/param-bounds-ignored.rs:21:25 - | -LL | type W2Vec<'b, T> where T: 'b, T: 'b = Vec; - | ^^^^^ ^^^^^ - -error: aborting due to 11 previous errors - diff --git a/src/test/ui/type-alias-bounds.rs b/src/test/ui/type-alias-bounds.rs new file mode 100644 index 00000000000..ed368e8f150 --- /dev/null +++ b/src/test/ui/type-alias-bounds.rs @@ -0,0 +1,51 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test ignored_generic_bounds lint warning about bounds in type aliases + +// must-compile-successfully +#![allow(dead_code)] + +use std::rc::Rc; + +type SVec = Vec; +//~^ WARN bounds on generic parameters are ignored in type aliases +type S2Vec where T: Send = Vec; +//~^ WARN where clauses are ignored in type aliases +type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); +//~^ WARN bounds on generic parameters are ignored in type aliases +type WVec<'b, T: 'b+'b> = (&'b u32, Vec); +//~^ WARN bounds on generic parameters are ignored in type aliases +type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); +//~^ WARN where clauses are ignored in type aliases + +static STATIC : u32 = 0; + +fn foo<'a>(y: &'a i32) { + // If any of the bounds above would matter, the code below would be rejected. + // This can be seen when replacing the type aliases above by newtype structs. + // (The type aliases have no unused parameters to make that a valid transformation.) + let mut x : SVec<_> = Vec::new(); + x.push(Rc::new(42)); // is not send + + let mut x : S2Vec<_> = Vec::new(); + x.push(Rc::new(42)); // is not send + + let mut x : VVec<'static, 'a> = (&STATIC, Vec::new()); + x.1.push(y); // 'a: 'static does not hold + + let mut x : WVec<'static, &'a i32> = (&STATIC, Vec::new()); + x.1.push(y); // &'a i32: 'static does not hold + + let mut x : W2Vec<'static, &'a i32> = (&STATIC, Vec::new()); + x.1.push(y); // &'a i32: 'static does not hold +} + +fn main() {} diff --git a/src/test/ui/type-alias-bounds.stderr b/src/test/ui/type-alias-bounds.stderr new file mode 100644 index 00000000000..5237f3c19ef --- /dev/null +++ b/src/test/ui/type-alias-bounds.stderr @@ -0,0 +1,32 @@ +warning: bounds on generic parameters are ignored in type aliases + --> $DIR/type-alias-bounds.rs:18:14 + | +LL | type SVec = Vec; + | ^^^^ ^^^^ + | + = note: #[warn(ignored_generic_bounds)] on by default + +warning: where clauses are ignored in type aliases + --> $DIR/type-alias-bounds.rs:20:21 + | +LL | type S2Vec where T: Send = Vec; + | ^^^^^^^ + +warning: bounds on generic parameters are ignored in type aliases + --> $DIR/type-alias-bounds.rs:22:19 + | +LL | type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); + | ^^ ^^ + +warning: bounds on generic parameters are ignored in type aliases + --> $DIR/type-alias-bounds.rs:24:18 + | +LL | type WVec<'b, T: 'b+'b> = (&'b u32, Vec); + | ^^ ^^ + +warning: where clauses are ignored in type aliases + --> $DIR/type-alias-bounds.rs:26:25 + | +LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); + | ^^^^^ ^^^^^ + -- cgit 1.4.1-3-g733a5 From 562b44d8c3dbcf7c36209774e50fe833e65a98d6 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 10 Mar 2018 11:43:51 +0100 Subject: Rename ignored_generic_bounds -> type_alias_bounds First of all, the lint is specific for type aliases. Second, it turns out the bounds are not entirely ignored but actually used when accessing associated types. So change the wording of the lint, and adapt its name to reality. The lint has never been on stable or beta, so renaming is safe. --- src/librustc_lint/builtin.rs | 25 +++++++------- src/librustc_lint/lib.rs | 2 +- src/test/compile-fail/issue-17994.rs | 2 +- src/test/compile-fail/private-in-public-warn.rs | 4 +-- src/test/ui/type-alias-bounds.rs | 25 ++++++++++---- src/test/ui/type-alias-bounds.stderr | 43 ++++++++++++++++++------- 6 files changed, 68 insertions(+), 33 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c6698cbd006..bdb36ab15b6 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1316,24 +1316,25 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnreachablePub { } } -/// Lint for trait and lifetime bounds that are (accidentally) accepted by the parser, but -/// ignored later. +/// Lint for trait and lifetime bounds in type aliases being mostly ignored: +/// They are relevant when using associated types, but otherwise neither checked +/// at definition site nor enforced at use site. -pub struct IgnoredGenericBounds; +pub struct TypeAliasBounds; declare_lint! { - IGNORED_GENERIC_BOUNDS, + TYPE_ALIAS_BOUNDS, Warn, - "these generic bounds are ignored" + "bounds in type aliases are not enforced" } -impl LintPass for IgnoredGenericBounds { +impl LintPass for TypeAliasBounds { fn get_lints(&self) -> LintArray { - lint_array!(IGNORED_GENERIC_BOUNDS) + lint_array!(TYPE_ALIAS_BOUNDS) } } -impl EarlyLintPass for IgnoredGenericBounds { +impl EarlyLintPass for TypeAliasBounds { fn check_item(&mut self, cx: &EarlyContext, item: &ast::Item) { let type_alias_generics = match item.node { ast::ItemKind::Ty(_, ref generics) => generics, @@ -1343,8 +1344,8 @@ impl EarlyLintPass for IgnoredGenericBounds { if !type_alias_generics.where_clause.predicates.is_empty() { let spans : Vec<_> = type_alias_generics.where_clause.predicates.iter() .map(|pred| pred.span()).collect(); - cx.span_lint(IGNORED_GENERIC_BOUNDS, spans, - "where clauses are ignored in type aliases"); + cx.span_lint(TYPE_ALIAS_BOUNDS, spans, + "where clauses are not enforced in type aliases"); } // The parameters must not have bounds for param in type_alias_generics.params.iter() { @@ -1354,9 +1355,9 @@ impl EarlyLintPass for IgnoredGenericBounds { }; if !spans.is_empty() { cx.span_lint( - IGNORED_GENERIC_BOUNDS, + TYPE_ALIAS_BOUNDS, spans, - "bounds on generic parameters are ignored in type aliases", + "bounds on generic parameters are not enforced in type aliases", ); } } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 779aa3a9037..38f7a0b6faa 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -109,7 +109,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { UnusedImportBraces, AnonymousParameters, UnusedDocComment, - IgnoredGenericBounds, + TypeAliasBounds, ); add_early_builtin_with_new!(sess, diff --git a/src/test/compile-fail/issue-17994.rs b/src/test/compile-fail/issue-17994.rs index 0f30e2461cf..7c3811e2ef2 100644 --- a/src/test/compile-fail/issue-17994.rs +++ b/src/test/compile-fail/issue-17994.rs @@ -10,5 +10,5 @@ trait Tr {} type Huh where T: Tr = isize; //~ ERROR type parameter `T` is unused - //~| WARNING where clauses are ignored in type aliases + //~| WARNING where clauses are not enforced in type aliases fn main() {} diff --git a/src/test/compile-fail/private-in-public-warn.rs b/src/test/compile-fail/private-in-public-warn.rs index cc9eed7e654..8bd9b0a901d 100644 --- a/src/test/compile-fail/private-in-public-warn.rs +++ b/src/test/compile-fail/private-in-public-warn.rs @@ -58,7 +58,7 @@ mod traits { pub trait PubTr {} pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARNING bounds on generic parameters are ignored + //~^ WARNING bounds on generic parameters are not enforced in type aliases //~| WARNING hard error pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error @@ -85,7 +85,7 @@ mod traits_where { pub type Alias where T: PrivTr = T; //~^ ERROR private trait `traits_where::PrivTr` in public interface //~| WARNING hard error - //~| WARNING where clauses are ignored in type aliases + //~| WARNING where clauses are not enforced in type aliases pub trait Tr2 where T: PrivTr {} //~^ ERROR private trait `traits_where::PrivTr` in public interface //~| WARNING hard error diff --git a/src/test/ui/type-alias-bounds.rs b/src/test/ui/type-alias-bounds.rs index ed368e8f150..7ec3afd9c87 100644 --- a/src/test/ui/type-alias-bounds.rs +++ b/src/test/ui/type-alias-bounds.rs @@ -10,21 +10,20 @@ // Test ignored_generic_bounds lint warning about bounds in type aliases -// must-compile-successfully #![allow(dead_code)] use std::rc::Rc; type SVec = Vec; -//~^ WARN bounds on generic parameters are ignored in type aliases +//~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] type S2Vec where T: Send = Vec; -//~^ WARN where clauses are ignored in type aliases +//~^ WARN where clauses are not enforced in type aliases [type_alias_bounds] type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); -//~^ WARN bounds on generic parameters are ignored in type aliases +//~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] type WVec<'b, T: 'b+'b> = (&'b u32, Vec); -//~^ WARN bounds on generic parameters are ignored in type aliases +//~^ WARN bounds on generic parameters are not enforced in type aliases [type_alias_bounds] type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); -//~^ WARN where clauses are ignored in type aliases +//~^ WARN where clauses are not enforced in type aliases [type_alias_bounds] static STATIC : u32 = 0; @@ -48,4 +47,18 @@ fn foo<'a>(y: &'a i32) { x.1.push(y); // &'a i32: 'static does not hold } +// Bounds are not checked either, i.e. the definition is not necessarily well-formed +struct Sendable(T); +type MySendable = Sendable; // no error here! + +// However, bounds *are* taken into account when accessing associated types +trait Bound { type Assoc; } +type T1 = U::Assoc; +//~^ WARN bounds on generic parameters are not enforced in type aliases +type T2 where U: Bound = U::Assoc; +//~^ WARN where clauses are not enforced in type aliases +type T3 = U::Assoc; +//~^ ERROR associated type `Assoc` not found for `U` +type T4 = ::Assoc; + fn main() {} diff --git a/src/test/ui/type-alias-bounds.stderr b/src/test/ui/type-alias-bounds.stderr index 5237f3c19ef..46aacd7321c 100644 --- a/src/test/ui/type-alias-bounds.stderr +++ b/src/test/ui/type-alias-bounds.stderr @@ -1,32 +1,53 @@ -warning: bounds on generic parameters are ignored in type aliases - --> $DIR/type-alias-bounds.rs:18:14 +warning: bounds on generic parameters are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:17:14 | LL | type SVec = Vec; | ^^^^ ^^^^ | - = note: #[warn(ignored_generic_bounds)] on by default + = note: #[warn(type_alias_bounds)] on by default -warning: where clauses are ignored in type aliases - --> $DIR/type-alias-bounds.rs:20:21 +warning: where clauses are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:19:21 | LL | type S2Vec where T: Send = Vec; | ^^^^^^^ -warning: bounds on generic parameters are ignored in type aliases - --> $DIR/type-alias-bounds.rs:22:19 +warning: bounds on generic parameters are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:21:19 | LL | type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); | ^^ ^^ -warning: bounds on generic parameters are ignored in type aliases - --> $DIR/type-alias-bounds.rs:24:18 +warning: bounds on generic parameters are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:23:18 | LL | type WVec<'b, T: 'b+'b> = (&'b u32, Vec); | ^^ ^^ -warning: where clauses are ignored in type aliases - --> $DIR/type-alias-bounds.rs:26:25 +warning: where clauses are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:25:25 | LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); | ^^^^^ ^^^^^ +warning: bounds on generic parameters are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:56:12 + | +LL | type T1 = U::Assoc; + | ^^^^^ + +warning: where clauses are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:58:18 + | +LL | type T2 where U: Bound = U::Assoc; + | ^^^^^^^^ + +error[E0220]: associated type `Assoc` not found for `U` + --> $DIR/type-alias-bounds.rs:60:14 + | +LL | type T3 = U::Assoc; + | ^^^^^^^^ associated type `Assoc` not found + +error: aborting due to previous error + +If you want more information on this error, try using "rustc --explain E0220" -- cgit 1.4.1-3-g733a5 From 0e6d40a3fb1000d1105646703c60c9201f3ed5cc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 10 Mar 2018 13:32:11 +0100 Subject: type_alias_bounds lint: If the type alias uses an associated type without "as", suggest to use the "as" form instead. This is necessary to get rid of the type bound, and hence silence the warning. --- src/librustc/hir/mod.rs | 19 +++++++++ src/librustc_lint/builtin.rs | 83 ++++++++++++++++++++++++++++++++---- src/librustc_lint/lib.rs | 2 +- src/test/ui/type-alias-bounds.rs | 17 +++++--- src/test/ui/type-alias-bounds.stderr | 58 +++++++++++++++++++------ 5 files changed, 150 insertions(+), 29 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index f4638c23c5f..d4bfa7a1d30 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -395,6 +395,15 @@ pub enum TyParamBound { RegionTyParamBound(Lifetime), } +impl TyParamBound { + pub fn span(&self) -> Span { + match self { + &TraitTyParamBound(ref t, ..) => t.span, + &RegionTyParamBound(ref l) => l.span, + } + } +} + /// A modifier on a bound, currently this is only used for `?Sized`, where the /// modifier is `Maybe`. Negative bounds should also be handled here. #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] @@ -570,6 +579,16 @@ pub enum WherePredicate { EqPredicate(WhereEqPredicate), } +impl WherePredicate { + pub fn span(&self) -> Span { + match self { + &WherePredicate::BoundPredicate(ref p) => p.span, + &WherePredicate::RegionPredicate(ref p) => p.span, + &WherePredicate::EqPredicate(ref p) => p.span, + } + } +} + /// A type bound, eg `for<'c> Foo: Send+Clone+'c` #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct WhereBoundPredicate { diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index bdb36ab15b6..2ea13b2cb6d 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -46,6 +46,7 @@ use syntax::attr; use syntax::feature_gate::{AttributeGate, AttributeType, Stability, deprecated_attributes}; use syntax_pos::{BytePos, Span, SyntaxContext}; use syntax::symbol::keywords; +use syntax::errors::DiagnosticBuilder; use rustc::hir::{self, PatKind}; use rustc::hir::intravisit::FnKind; @@ -1334,31 +1335,97 @@ impl LintPass for TypeAliasBounds { } } -impl EarlyLintPass for TypeAliasBounds { - fn check_item(&mut self, cx: &EarlyContext, item: &ast::Item) { - let type_alias_generics = match item.node { - ast::ItemKind::Ty(_, ref generics) => generics, +impl TypeAliasBounds { + fn is_type_variable_assoc(qpath: &hir::QPath) -> bool { + match *qpath { + hir::QPath::TypeRelative(ref ty, _) => { + // If this is a type variable, we found a `T::Assoc`. + match ty.node { + hir::TyPath(hir::QPath::Resolved(None, ref path)) => { + match path.def { + Def::TyParam(_) => true, + _ => false + } + } + _ => false + } + } + hir::QPath::Resolved(..) => false, + } + } + + fn suggest_changing_assoc_types(ty: &hir::Ty, err: &mut DiagnosticBuilder) { + // Access to associates types should use `::Assoc`, which does not need a + // bound. Let's see of this type does that. + + // We use an AST visitor to walk the type. + use rustc::hir::intravisit::{self, Visitor}; + use syntax::ast::NodeId; + struct WalkAssocTypes<'a, 'db> where 'db: 'a { + err: &'a mut DiagnosticBuilder<'db> + } + impl<'a, 'db, 'v> Visitor<'v> for WalkAssocTypes<'a, 'db> { + fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'v> + { + intravisit::NestedVisitorMap::None + } + + fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: NodeId, span: Span) { + if TypeAliasBounds::is_type_variable_assoc(qpath) { + self.err.span_help(span, + "use absolute paths (i.e., ::Assoc) to refer to associated \ + types in type aliases"); + } + intravisit::walk_qpath(self, qpath, id, span) + } + } + + // Let's go for a walk! + let mut visitor = WalkAssocTypes { err }; + visitor.visit_ty(ty); + } +} + +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { + fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { + let (ty, type_alias_generics) = match item.node { + hir::ItemTy(ref ty, ref generics) => (&*ty, generics), _ => return, }; + let mut suggested_changing_assoc_types = false; // There must not be a where clause if !type_alias_generics.where_clause.predicates.is_empty() { let spans : Vec<_> = type_alias_generics.where_clause.predicates.iter() .map(|pred| pred.span()).collect(); - cx.span_lint(TYPE_ALIAS_BOUNDS, spans, + let mut err = cx.struct_span_lint(TYPE_ALIAS_BOUNDS, spans, "where clauses are not enforced in type aliases"); + err.help("the clause will not be checked when the type alias is used, \ + and should be removed"); + if !suggested_changing_assoc_types { + TypeAliasBounds::suggest_changing_assoc_types(ty, &mut err); + suggested_changing_assoc_types = true; + } + err.emit(); } // The parameters must not have bounds for param in type_alias_generics.params.iter() { let spans : Vec<_> = match param { - &ast::GenericParam::Lifetime(ref l) => l.bounds.iter().map(|b| b.span).collect(), - &ast::GenericParam::Type(ref ty) => ty.bounds.iter().map(|b| b.span()).collect(), + &hir::GenericParam::Lifetime(ref l) => l.bounds.iter().map(|b| b.span).collect(), + &hir::GenericParam::Type(ref ty) => ty.bounds.iter().map(|b| b.span()).collect(), }; if !spans.is_empty() { - cx.span_lint( + let mut err = cx.struct_span_lint( TYPE_ALIAS_BOUNDS, spans, "bounds on generic parameters are not enforced in type aliases", ); + err.help("the bound will not be checked when the type alias is used, \ + and should be removed"); + if !suggested_changing_assoc_types { + TypeAliasBounds::suggest_changing_assoc_types(ty, &mut err); + suggested_changing_assoc_types = true; + } + err.emit(); } } } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 38f7a0b6faa..7237d2fd5d1 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -109,7 +109,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { UnusedImportBraces, AnonymousParameters, UnusedDocComment, - TypeAliasBounds, ); add_early_builtin_with_new!(sess, @@ -139,6 +138,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { MutableTransmutes, UnionsWithDropFields, UnreachablePub, + TypeAliasBounds, ); add_builtin_with_new!(sess, diff --git a/src/test/ui/type-alias-bounds.rs b/src/test/ui/type-alias-bounds.rs index 7ec3afd9c87..c1cdeef3a46 100644 --- a/src/test/ui/type-alias-bounds.rs +++ b/src/test/ui/type-alias-bounds.rs @@ -10,6 +10,7 @@ // Test ignored_generic_bounds lint warning about bounds in type aliases +// must-compile-successfully #![allow(dead_code)] use std::rc::Rc; @@ -53,12 +54,16 @@ type MySendable = Sendable; // no error here! // However, bounds *are* taken into account when accessing associated types trait Bound { type Assoc; } -type T1 = U::Assoc; -//~^ WARN bounds on generic parameters are not enforced in type aliases -type T2 where U: Bound = U::Assoc; -//~^ WARN where clauses are not enforced in type aliases -type T3 = U::Assoc; -//~^ ERROR associated type `Assoc` not found for `U` +type T1 = U::Assoc; //~ WARN not enforced in type aliases +type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases + +// This errors +// type T3 = U::Assoc; +// Do this instead type T4 = ::Assoc; +// Make sure the help about associatd types is not shown incorrectly +type T5 = ::Assoc; //~ WARN not enforced in type aliases +type T6 = ::std::vec::Vec; //~ WARN not enforced in type aliases + fn main() {} diff --git a/src/test/ui/type-alias-bounds.stderr b/src/test/ui/type-alias-bounds.stderr index 46aacd7321c..5288dca79be 100644 --- a/src/test/ui/type-alias-bounds.stderr +++ b/src/test/ui/type-alias-bounds.stderr @@ -1,53 +1,83 @@ warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:17:14 + --> $DIR/type-alias-bounds.rs:18:14 | LL | type SVec = Vec; | ^^^^ ^^^^ | = note: #[warn(type_alias_bounds)] on by default + = help: the bound will not be checked when the type alias is used, and should be removed warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:19:21 + --> $DIR/type-alias-bounds.rs:20:21 | LL | type S2Vec where T: Send = Vec; | ^^^^^^^ + | + = help: the clause will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:21:19 + --> $DIR/type-alias-bounds.rs:22:19 | LL | type VVec<'b, 'a: 'b+'b> = (&'b u32, Vec<&'a i32>); | ^^ ^^ + | + = help: the bound will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:23:18 + --> $DIR/type-alias-bounds.rs:24:18 | LL | type WVec<'b, T: 'b+'b> = (&'b u32, Vec); | ^^ ^^ + | + = help: the bound will not be checked when the type alias is used, and should be removed warning: where clauses are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:25:25 + --> $DIR/type-alias-bounds.rs:26:25 | LL | type W2Vec<'b, T> where T: 'b, T: 'b = (&'b u32, Vec); | ^^^^^ ^^^^^ + | + = help: the clause will not be checked when the type alias is used, and should be removed warning: bounds on generic parameters are not enforced in type aliases - --> $DIR/type-alias-bounds.rs:56:12 + --> $DIR/type-alias-bounds.rs:57:12 | -LL | type T1 = U::Assoc; +LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^ + | + = help: the bound will not be checked when the type alias is used, and should be removed +help: use absolute paths (i.e., ::Assoc) to refer to associated types in type aliases + --> $DIR/type-alias-bounds.rs:57:21 + | +LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases + | ^^^^^^^^ warning: where clauses are not enforced in type aliases --> $DIR/type-alias-bounds.rs:58:18 | -LL | type T2 where U: Bound = U::Assoc; +LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^^^^ + | + = help: the clause will not be checked when the type alias is used, and should be removed +help: use absolute paths (i.e., ::Assoc) to refer to associated types in type aliases + --> $DIR/type-alias-bounds.rs:58:29 + | +LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases + | ^^^^^^^^ -error[E0220]: associated type `Assoc` not found for `U` - --> $DIR/type-alias-bounds.rs:60:14 +warning: bounds on generic parameters are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:66:12 + | +LL | type T5 = ::Assoc; //~ WARN not enforced in type aliases + | ^^^^^ | -LL | type T3 = U::Assoc; - | ^^^^^^^^ associated type `Assoc` not found + = help: the bound will not be checked when the type alias is used, and should be removed -error: aborting due to previous error +warning: bounds on generic parameters are not enforced in type aliases + --> $DIR/type-alias-bounds.rs:67:12 + | +LL | type T6 = ::std::vec::Vec; //~ WARN not enforced in type aliases + | ^^^^^ + | + = help: the bound will not be checked when the type alias is used, and should be removed -If you want more information on this error, try using "rustc --explain E0220" -- cgit 1.4.1-3-g733a5 From c685b57bf27d3ddecd83ab77e1973d36dff755b4 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 12 Mar 2018 17:16:21 -0500 Subject: add page to the Rustdoc Book about unstable features --- src/doc/rustdoc/src/SUMMARY.md | 1 + src/doc/rustdoc/src/unstable-features.md | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/doc/rustdoc/src/unstable-features.md diff --git a/src/doc/rustdoc/src/SUMMARY.md b/src/doc/rustdoc/src/SUMMARY.md index 6315cb81a84..46528187c11 100644 --- a/src/doc/rustdoc/src/SUMMARY.md +++ b/src/doc/rustdoc/src/SUMMARY.md @@ -5,3 +5,4 @@ - [The `#[doc]` attribute](the-doc-attribute.md) - [Documentation tests](documentation-tests.md) - [Passes](passes.md) +- [Unstable features](unstable-features.md) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md new file mode 100644 index 00000000000..35380cdf069 --- /dev/null +++ b/src/doc/rustdoc/src/unstable-features.md @@ -0,0 +1,10 @@ +# Unstable features + +Rustdoc is under active developement, and like the Rust compiler, some features are only available +on the nightly releases. Some of these are new and need some more testing before they're able to get +released to the world at large, and some of them are tied to features in the Rust compiler that are +themselves unstable. Several features here require a matching `#![feature(...)]` attribute to +enable, and thus are more fully documented in the [Unstable Book]. Those sections will link over +there as necessary. + +[Unstable Book]: ../unstable-book/ -- cgit 1.4.1-3-g733a5 From 373b2cdcd13788249e27d7f06f5c36f37bc8684e Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 12 Mar 2018 17:26:20 -0500 Subject: talk about error numbers for compile_fail doctests --- src/doc/rustdoc/src/unstable-features.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 35380cdf069..8dbd0aa9a9a 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -8,3 +8,26 @@ enable, and thus are more fully documented in the [Unstable Book]. Those section there as necessary. [Unstable Book]: ../unstable-book/ + +## Error numbers for `compile-fail` doctests + +As detailed in [the chapter on documentation tests][doctest-attributes], you can add a +`compile_fail` attribute to a doctest to state that the test should fail to compile. However, on +nightly, you can optionally add an error number to state that a doctest should emit a specific error +number: + +[doctest-attributes]: documentation-tests.html#attributes + +``````markdown +```compile_fail,E0044 +extern { fn some_func(x: T); } +``` +`````` + +This is used by the error index to ensure that the samples that correspond to a given error number +properly emit that error code. However, these error codes aren't guaranteed to be the only thing +that a piece of code emits from version to version, so this in unlikely to be stabilized in the +future. + +Attempting to use these error numbers on stable will result in the code sample being interpreted as +plain text. -- cgit 1.4.1-3-g733a5 From 30adb53f46628fa37042543359a269221350b6d7 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 13 Mar 2018 17:00:51 -0500 Subject: talk about intra-links --- src/doc/rustdoc/src/unstable-features.md | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 8dbd0aa9a9a..08cceff0e70 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -31,3 +31,48 @@ future. Attempting to use these error numbers on stable will result in the code sample being interpreted as plain text. + +## Linking to items by type + +As designed in [RFC 1946], Rustdoc can parse paths to items when you use them as links. To resolve +these type names, it uses the items currently in-scope, either by declaration or by `use` statement. +For modules, the "active scope" depends on whether the documentation is written outside the module +(as `///` comments on the `mod` statement) or inside the module (at `//!` comments inside the file +or block). For all other items, it uses the enclosing module's scope. + +[RFC 1946]: https://github.com/rust-lang/rfcs/pull/1946 + +For example, in the following code: + +```rust +/// Does the thing. +pub fn do_the_thing(_: SomeType) { + println!("Let's do the thing!"); +} + +/// Token you use to [`do_the_thing`]. +pub struct SomeType; +``` + +The link to ``[`do_the_thing`]`` in `SomeType`'s docs will properly link to the page for `fn +do_the_thing`. Note that here, rustdoc will insert the link target for you, but manually writing the +target out also works: + +```rust +pub mod some_module { + /// Token you use to do the thing. + pub struct SomeStruct; +} + +/// Does the thing. Requires one [`SomeStruct`] for the thing to work. +/// +/// [`SomeStruct`]: some_module::SomeStruct +pub fn do_the_thing(_: some_module::SomeStruct) { + println!("Let's do the thing!"); +} +``` + +For more details, check out [the RFC][RFC 1946], and see [the tracking issue][43466] for more +information about what parts of the feature are available. + +[43466]: https://github.com/rust-lang/rust/issues/43466 -- cgit 1.4.1-3-g733a5 From 0f96e145fbe8c635e7a58fb17c8c46bc4e42d454 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Wed, 14 Mar 2018 15:32:25 -0500 Subject: talk about doc(cfg) --- src/doc/rustdoc/src/unstable-features.md | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 08cceff0e70..245d53e8b79 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -76,3 +76,55 @@ For more details, check out [the RFC][RFC 1946], and see [the tracking issue][43 information about what parts of the feature are available. [43466]: https://github.com/rust-lang/rust/issues/43466 + +## Documenting platform-/feature-specific information + +Because of the way Rustdoc documents a crate, the documentation it creates is specific to the target +rustc compiles for. Anything that's specific to any other target is dropped via `#[cfg]` attribute +processing early in the compilation process. However, Rustdoc has a trick up its sleeve to handle +platform-specific code if it *does* receive it. + +Because Rustdoc doesn't need to fully compile a crate to binary, it replaces function bodies with +`loop {}` to prevent having to process more than necessary. This means that any code within a +function that requires platform-specific pieces is ignored. Combined with a special attribute, +`#[doc(cfg(...))]`, you can tell Rustdoc exactly which platform something is supposed to run on, +ensuring that doctests are only run on the appropriate platforms. + +The `#[doc(cfg(...))]` attribute has another effect: When Rustdoc renders documentation for that +item, it will be accompanied by a banner explaining that the item is only available on certain +platforms. + +As mentioned earlier, getting the items to Rustdoc requires some extra preparation. The standard +library adds a `--cfg dox` flag to every Rustdoc command, but the same thing can be accomplished by +adding a feature to your Cargo.toml and adding `--feature dox` (or whatever you choose to name the +feature) to your `cargo doc` calls. + +Either way, once you create an environment for the documentation, you can start to augment your +`#[cfg]` attributes to allow both the target platform *and* the documentation configuration to leave +the item in. For example, `#[cfg(any(windows, feature = "dox"))]` will preserve the item either on +Windows or during the documentation process. Then, adding a new attribute `#[doc(cfg(windows))]` +will tell Rustdoc that the item is supposed to be used on Windows. For example: + +```rust +#![feature(doc_cfg)] + +/// Token struct that can only be used on Windows. +#[cfg(any(windows, feature = "dox"))] +#[doc(cfg(windows))] +pub struct WindowsToken; + +/// Token struct that can only be used on Unix. +#[cfg(any(unix, feature = "dox"))] +#[doc(cfg(unix))] +pub struct UnixToken; +``` + +In this sample, the tokens will only appear on their respective platforms, but they will both appear +in documentation. + +`#[doc(cfg(...))]` was introduced to be used by the standard library and is currently controlled by +a feature gate. For more information, see [its chapter in the Unstable Book][unstable-doc-cfg] and +[its tracking issue][issue-doc-cfg]. + +[unstable-doc-cfg]: ../unstable-book/language-features/doc-cfg.html +[issue-doc-cfg]: https://github.com/rust-lang/rust/issues/43781 -- cgit 1.4.1-3-g733a5 From 23a1da4d637648ae37090f88be695de3a63cd507 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Wed, 14 Mar 2018 16:06:53 -0500 Subject: talk about doc(spotlight) --- src/doc/rustdoc/src/unstable-features.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 245d53e8b79..16702239524 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -128,3 +128,23 @@ a feature gate. For more information, see [its chapter in the Unstable Book][uns [unstable-doc-cfg]: ../unstable-book/language-features/doc-cfg.html [issue-doc-cfg]: https://github.com/rust-lang/rust/issues/43781 + +## Adding your trait to the "Important Traits" dialog + +Rustdoc keeps a list of a few traits that are believed to be "fundamental" to a given type when +implemented on it. These traits are intended to be the primary interface for their types, and are +often the only thing available to be documented on their types. For this reason, Rustdoc will track +when a given type implements one of these traits and call special attention to it when a function +returns one of these types. This is the "Important Traits" dialog, visible as a circle-i button next +to the function, which, when clicked, shows the dialog. + +In the standard library, the traits that qualify for inclusion are `Iterator`, `io::Read`, and +`io::Write`. However, rather than being implemented as a hard-coded list, these traits have a +special marker attribute on them: `#[doc(spotlight)]`. This means that you could apply this +attribute to your own trait to include it in the "Important Traits" dialog in documentation. + +The `#[doc(spotlight)]` attribute is controlled by a feature gate. For more information, see [its +chapter in the Unstable Book][unstable-spotlight] and [its tracking issue][issue-spotlight]. + +[unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html +[issue-spotlight]: https://github.com/rust-lang/rust/issues/45040 -- cgit 1.4.1-3-g733a5 From 82bd146d60425c3cd0c99892742f1454f5eb8191 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Wed, 14 Mar 2018 16:40:28 -0500 Subject: talk about doc(masked) --- src/doc/rustdoc/src/unstable-features.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 16702239524..9f0476d4eef 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -148,3 +148,23 @@ chapter in the Unstable Book][unstable-spotlight] and [its tracking issue][issue [unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html [issue-spotlight]: https://github.com/rust-lang/rust/issues/45040 + +## Exclude certain dependencies from documentation + +The standard library uses several dependencies which, in turn, use several types and traits from the +standard library. In addition, there are several compiler-internal crates that are not considered to +be part of the official standard library, and thus would be a distraction to include in +documentation. It's not enough to exclude their crate documentation, since information about trait +implementations appears on the pages for both the type and the trait, which can be in different +crates! + +To prevent internal types from being included in documentation, the standard library adds an +attribute to their `extern crate` declarations: `#[doc(masked)]`. This causes Rustdoc to "mask out" +types from these crates when building lists of trait implementations. + +The `#[doc(masked)]` attribute is intended to be used internally, and is governed by a feature gate. +For more information, see [its chapter in the Unstable Book][unstable-masked] and [its tracking +issue][issue-masked]. + +[unstable-masked]: ../unstable-book/language-features/doc-masked.html +[issue-masked]: https://github.com/rust-lang/rust/issues/44027 -- cgit 1.4.1-3-g733a5 From 067553d5a1d867c7f8404153ce37a4008489b82a Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Wed, 14 Mar 2018 17:13:52 -0500 Subject: talk about doc(include) --- src/doc/rustdoc/src/unstable-features.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 9f0476d4eef..62112fbf293 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -162,9 +162,25 @@ To prevent internal types from being included in documentation, the standard lib attribute to their `extern crate` declarations: `#[doc(masked)]`. This causes Rustdoc to "mask out" types from these crates when building lists of trait implementations. -The `#[doc(masked)]` attribute is intended to be used internally, and is governed by a feature gate. -For more information, see [its chapter in the Unstable Book][unstable-masked] and [its tracking -issue][issue-masked]. +The `#[doc(masked)]` attribute is intended to be used internally, and is controlled by a feature +gate. For more information, see [its chapter in the Unstable Book][unstable-masked] and [its +tracking issue][issue-masked]. [unstable-masked]: ../unstable-book/language-features/doc-masked.html [issue-masked]: https://github.com/rust-lang/rust/issues/44027 + +## Include external files as API documentation + +As designed in [RFC 1990], Rustdoc can read an external file to use as a type's documentation. This +is useful if certain documentation is so long that it would break the flow of reading the source. +Instead of writing it all inline, writing `#[doc(include = "sometype.md")]` (where `sometype.md` is +a file adjacent to the `lib.rs` for the crate) will ask Rustdoc to instead read that file and use it +as if it were written inline. + +[RFC 1990]: https://github.com/rust-lang/rfcs/pull/1990 + +`#[doc(include = "...")]` is currently controlled by a feature gate. For more information, see [its +chapter in the Unstable Book][unstable-include] and [its tracking issue][issue-include]. + +[unstable-include]: ../unstable-book/language-features/external-doc.html +[issue-include]: https://github.com/rust-lang/rust/issues/44732 -- cgit 1.4.1-3-g733a5 From 3d90b4d73880f7f7146a31544ac414e85014ca6f Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Wed, 14 Mar 2018 17:22:15 -0500 Subject: add headings to categorize the features --- src/doc/rustdoc/src/unstable-features.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 62112fbf293..5f9978c61b6 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -9,7 +9,14 @@ there as necessary. [Unstable Book]: ../unstable-book/ -## Error numbers for `compile-fail` doctests +## Nightly-gated functionality + +These features just require a nightly build to operate. Unlike the other features on this page, +these don't need to be "turned on" with a command-line flag or a `#![feature(...)]` attribute in +your crate. This can give them some subtle fallback modes when used on a stable release, so be +careful! + +### Error numbers for `compile-fail` doctests As detailed in [the chapter on documentation tests][doctest-attributes], you can add a `compile_fail` attribute to a doctest to state that the test should fail to compile. However, on @@ -32,7 +39,7 @@ future. Attempting to use these error numbers on stable will result in the code sample being interpreted as plain text. -## Linking to items by type +### Linking to items by type As designed in [RFC 1946], Rustdoc can parse paths to items when you use them as links. To resolve these type names, it uses the items currently in-scope, either by declaration or by `use` statement. @@ -77,7 +84,12 @@ information about what parts of the feature are available. [43466]: https://github.com/rust-lang/rust/issues/43466 -## Documenting platform-/feature-specific information +## Extensions to the `#[doc]` attribute + +These features operate by extending the `#[doc]` attribute, and thus can be caught by the compiler +and enabled with a `#![feature(...)]` attribute in your crate. + +### Documenting platform-/feature-specific information Because of the way Rustdoc documents a crate, the documentation it creates is specific to the target rustc compiles for. Anything that's specific to any other target is dropped via `#[cfg]` attribute @@ -129,7 +141,7 @@ a feature gate. For more information, see [its chapter in the Unstable Book][uns [unstable-doc-cfg]: ../unstable-book/language-features/doc-cfg.html [issue-doc-cfg]: https://github.com/rust-lang/rust/issues/43781 -## Adding your trait to the "Important Traits" dialog +### Adding your trait to the "Important Traits" dialog Rustdoc keeps a list of a few traits that are believed to be "fundamental" to a given type when implemented on it. These traits are intended to be the primary interface for their types, and are @@ -149,7 +161,7 @@ chapter in the Unstable Book][unstable-spotlight] and [its tracking issue][issue [unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html [issue-spotlight]: https://github.com/rust-lang/rust/issues/45040 -## Exclude certain dependencies from documentation +### Exclude certain dependencies from documentation The standard library uses several dependencies which, in turn, use several types and traits from the standard library. In addition, there are several compiler-internal crates that are not considered to @@ -169,7 +181,7 @@ tracking issue][issue-masked]. [unstable-masked]: ../unstable-book/language-features/doc-masked.html [issue-masked]: https://github.com/rust-lang/rust/issues/44027 -## Include external files as API documentation +### Include external files as API documentation As designed in [RFC 1990], Rustdoc can read an external file to use as a type's documentation. This is useful if certain documentation is so long that it would break the flow of reading the source. -- cgit 1.4.1-3-g733a5 From c24a58c87c41f17e341cb165f990ef2fd5ec3cb5 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 15 Mar 2018 09:29:54 -0500 Subject: fix link --- src/doc/rustdoc/src/unstable-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 5f9978c61b6..243d6073767 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -7,7 +7,7 @@ themselves unstable. Several features here require a matching `#![feature(...)]` enable, and thus are more fully documented in the [Unstable Book]. Those sections will link over there as necessary. -[Unstable Book]: ../unstable-book/ +[Unstable Book]: ../unstable-book/index.html ## Nightly-gated functionality -- cgit 1.4.1-3-g733a5 From 43ed37711e98585178cc291283b9b3345448f311 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 15 Mar 2018 09:33:57 -0500 Subject: add new section about CLI flags --- src/doc/rustdoc/src/unstable-features.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 243d6073767..837a55f371f 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -196,3 +196,10 @@ chapter in the Unstable Book][unstable-include] and [its tracking issue][issue-i [unstable-include]: ../unstable-book/language-features/external-doc.html [issue-include]: https://github.com/rust-lang/rust/issues/44732 + +## Unstable command-line arguments + +These features are enabled by passing a command-line flag to Rustdoc, but the flags in question are +themselves marked as unstable. To use any of these options, pass `-Z unstable-options` as well as +the flag in question to Rustdoc on the command-line. To do this from Cargo, you can either use the +`RUSTDOCFLAGS` environment variable or the `cargo rustdoc` command. -- cgit 1.4.1-3-g733a5 From bb328237fc68fcc9c0495b283da74f8ec361b371 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 15 Mar 2018 12:47:26 -0500 Subject: talk about --markdown-(before|after)-content --- src/doc/rustdoc/src/unstable-features.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 837a55f371f..873aebfc777 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -203,3 +203,31 @@ These features are enabled by passing a command-line flag to Rustdoc, but the fl themselves marked as unstable. To use any of these options, pass `-Z unstable-options` as well as the flag in question to Rustdoc on the command-line. To do this from Cargo, you can either use the `RUSTDOCFLAGS` environment variable or the `cargo rustdoc` command. + +### `--markdown-before-content`: include rendered Markdown before the content + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --markdown-before-content extra.md +$ rustdoc README.md -Z unstable-options --markdown-before-content extra.md +``` + +Just like `--html-before-content`, this allows you to insert extra content inside the `` tag +but before the other content `rustdoc` would normally produce in the rendered documentation. +However, instead of directly inserting the file verbatim, `rustdoc` will pass the files through a +Markdown renderer before inserting the result into the file. + +### `--markdown-after-content`: include rendered Markdown after the content + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --markdown-after-content extra.md +$ rustdoc README.md -Z unstable-options --markdown-after-content extra.md +``` + +Just like `--html-after-content`, this allows you to insert extra content before the `` tag +but after the other content `rustdoc` would normally produce in the rendered documentation. +However, instead of directly inserting the file verbatim, `rustdoc` will pass the files through a +Markdown renderer before inserting the result into the file. -- cgit 1.4.1-3-g733a5 From 5d8443aeb1bf441897efddfc1246377f0d51149d Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 15 Mar 2018 14:44:17 -0500 Subject: talk about --playground-url --- src/doc/rustdoc/src/unstable-features.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 873aebfc777..9cb5760ec37 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -231,3 +231,26 @@ Just like `--html-after-content`, this allows you to insert extra content before but after the other content `rustdoc` would normally produce in the rendered documentation. However, instead of directly inserting the file verbatim, `rustdoc` will pass the files through a Markdown renderer before inserting the result into the file. + +### `--playground-url`: control the location of the playground + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --playground-url https://play.rust-lang.org/ +``` + +When rendering a crate's docs, this flag gives the base URL of the Rust Playground, to use for +generating `Run` buttons. Unlike `--markdown-playground-url`, this argument works for standalone +Markdown files *and* Rust crates. This works the same way as adding `#![doc(html_playground_url = +"url")]` to your crate root, as mentioned in [the chapter about the `#[doc]` +attribute][doc-playground]. Please be aware that the official Rust Playground at +https://play.rust-lang.org does not have every crate available, so if your examples require your +crate, make sure the playground you provide has your crate available. + +[doc-playground]: the-doc-attribute.html#html_playground_url + +If both `--playground-url` and `--markdown-playground-url` are present when rendering a standalone +Markdown file, the URL given to `--markdown-playground-url` will take precedence. If both +`--playground-url` and `#![doc(html_playground_url = "url")]` are present when rendering crate docs, +the attribute will take precedence. -- cgit 1.4.1-3-g733a5 From f9d38451382017a6cd053e25011e4c096d545d17 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 16 Mar 2018 13:38:06 -0500 Subject: talk about --crate-version --- src/doc/rustdoc/src/unstable-features.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 9cb5760ec37..867e4585d9c 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -254,3 +254,15 @@ If both `--playground-url` and `--markdown-playground-url` are present when rend Markdown file, the URL given to `--markdown-playground-url` will take precedence. If both `--playground-url` and `#![doc(html_playground_url = "url")]` are present when rendering crate docs, the attribute will take precedence. + +### `--crate-version`: control the crate version + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --crate-version 1.3.37 +``` + +When `rustdoc` receives this flag, it will print an extra "Version (version)" into the sidebar of +the crate root's docs. You can use this flag to differentiate between different versions of your +library's documentation. -- cgit 1.4.1-3-g733a5 From 33ed787b495477f2cc859b275a1deb6dc1a396a0 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 16 Mar 2018 13:46:10 -0500 Subject: talk about --linker --- src/doc/rustdoc/src/unstable-features.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 867e4585d9c..870d77895fd 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -266,3 +266,16 @@ $ rustdoc src/lib.rs -Z unstable-options --crate-version 1.3.37 When `rustdoc` receives this flag, it will print an extra "Version (version)" into the sidebar of the crate root's docs. You can use this flag to differentiate between different versions of your library's documentation. + +### `--linker`: control the linker used for documentation tests + +Using this flag looks like this: + +```bash +$ rustdoc --test src/lib.rs -Z unstable-options --linker foo +$ rustdoc --test README.md -Z unstable-options --linker foo +``` + +When `rustdoc` runs your documentation tests, it needs to compile and link the tests as executables +before running them. This flag can be used to change the linker used on these executables. It's +equivalent to passing `-C linker=foo` to `rustc`. -- cgit 1.4.1-3-g733a5 From cc4f97e88354bea5d07c3ae762ac0466e5c9888c Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 16 Mar 2018 14:30:56 -0500 Subject: talk about --sort-modules-by-appearance --- src/doc/rustdoc/src/unstable-features.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 870d77895fd..80b59166503 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -279,3 +279,16 @@ $ rustdoc --test README.md -Z unstable-options --linker foo When `rustdoc` runs your documentation tests, it needs to compile and link the tests as executables before running them. This flag can be used to change the linker used on these executables. It's equivalent to passing `-C linker=foo` to `rustc`. + +### `--sort-modules-by-appearance`: control how items on module pages are sorted + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --sort-modules-by-appearance +``` + +Ordinarily, when `rustdoc` prints items in module pages, it will sort them alphabetically (taking +some consideration for their stability, and names that end in a number). Giving this flag to +`rustdoc` will disable this sorting and instead make it print the items in the order they appear in +the source. -- cgit 1.4.1-3-g733a5 From 6b2906018f93a9813392056da4c3de855d92f619 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 16 Mar 2018 14:41:51 -0500 Subject: talk about --themes and --theme-checker --- src/doc/rustdoc/src/unstable-features.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 80b59166503..3ebc2fa466c 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -292,3 +292,27 @@ Ordinarily, when `rustdoc` prints items in module pages, it will sort them alpha some consideration for their stability, and names that end in a number). Giving this flag to `rustdoc` will disable this sorting and instead make it print the items in the order they appear in the source. + +### `--themes`: provide additional themes + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --themes theme.css +``` + +Giving this flag to `rustdoc` will make it copy your theme into the generated crate docs and enable +it in the theme selector. Note that `rustdoc` will reject your theme file if it doesn't style +everything the "main" theme does. See `--theme-checker` below for details. + +### `--theme-checker`: verify theme CSS for validity + +Using this flag looks like this: + +```bash +$ rustdoc -Z unstable-options --theme-checker theme.css +``` + +Before including your theme in crate docs, `rustdoc` will compare all the CSS rules it contains +against the "main" theme included by default. Using this flag will allow you to see which rules are +missing if `rustdoc` rejects your theme. -- cgit 1.4.1-3-g733a5 From b5ab5ceb4b2aa733366ed9453c0e714d6f0cd9f0 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 16 Mar 2018 15:06:36 -0500 Subject: talk about --resource-suffix --- src/doc/rustdoc/src/unstable-features.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 3ebc2fa466c..93489f89626 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -316,3 +316,16 @@ $ rustdoc -Z unstable-options --theme-checker theme.css Before including your theme in crate docs, `rustdoc` will compare all the CSS rules it contains against the "main" theme included by default. Using this flag will allow you to see which rules are missing if `rustdoc` rejects your theme. + +### `--resource-suffix`: modifying the name of CSS/JavaScript in crate docs + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --resource-suffix suf +``` + +When rendering docs, `rustdoc` creates several CSS and JavaScript files as part of the output. Since +all these files are linked from every page, changing where they are can be cumbersome if you need to +specially cache them. This flag will rename all these files in the output to include the suffix in +the filename. For example, `main.css` would become `main-suf.css` with the above command. -- cgit 1.4.1-3-g733a5 From 9e6268191205c42bc7958d949fa48811d60857f9 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sat, 17 Mar 2018 10:32:29 +0900 Subject: Remove core::fmt::num::Decimal Before ebf9e1aaf6, it was used for Display::fmt, but ebf9e1aaf6 replaced that with a faster implementation, and nothing else uses it. --- src/libcore/fmt/num.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 2992e7cf8db..57e3b849ae1 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -107,10 +107,6 @@ struct Binary; #[derive(Clone, PartialEq)] struct Octal; -/// A decimal (base 10) radix -#[derive(Clone, PartialEq)] -struct Decimal; - /// A hexadecimal (base 16) radix, formatted with lower-case characters #[derive(Clone, PartialEq)] struct LowerHex; @@ -136,7 +132,6 @@ macro_rules! radix { radix! { Binary, 2, "0b", x @ 0 ... 1 => b'0' + x } radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x } -radix! { Decimal, 10, "", x @ 0 ... 9 => b'0' + x } radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x, x @ 10 ... 15 => b'a' + (x - 10) } radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, -- cgit 1.4.1-3-g733a5 From f53d4af223a5301daa6123c7b1e4cba108700db4 Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Thu, 15 Feb 2018 10:40:02 +0100 Subject: Remove unused imports --- src/test/run-pass-fulldeps/issue-35829.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/run-pass-fulldeps/issue-35829.rs b/src/test/run-pass-fulldeps/issue-35829.rs index c4202433250..798c214bc47 100644 --- a/src/test/run-pass-fulldeps/issue-35829.rs +++ b/src/test/run-pass-fulldeps/issue-35829.rs @@ -20,8 +20,7 @@ use syntax::ext::expand::ExpansionConfig; use syntax::parse::ParseSess; use syntax::codemap::{FilePathMapping, dummy_spanned}; use syntax::print::pprust::expr_to_string; -use syntax::ast::{Expr, ExprKind, LitKind, StrStyle, RangeLimits}; -use syntax::symbol::Symbol; +use syntax::ast::{ExprKind, LitKind, RangeLimits}; use syntax::ptr::P; use rustc_data_structures::sync::Lrc; -- cgit 1.4.1-3-g733a5 From 3fa69c935d2dc28207908987a3a3cb518ab7f62d Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Sun, 3 Dec 2017 14:37:23 +0100 Subject: Make Span and Symbol implement Send and Sync --- src/libsyntax_pos/lib.rs | 6 +++++- src/libsyntax_pos/symbol.rs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index bec46ff3d79..51da9a755ec 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -184,8 +184,12 @@ impl SpanData { } } -// The interner in thread-local, so `Span` shouldn't move between threads. +// The interner is pointed to by a thread local value which is only set on the main thread +// with parallelization is disabled. So we don't allow Span to transfer between threads +// to avoid panics and other errors, even though it would be memory safe to do so. +#[cfg(not(parallel_queries))] impl !Send for Span {} +#[cfg(not(parallel_queries))] impl !Sync for Span {} impl PartialOrd for Span { diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index e95079f7c88..34716e6eeec 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -83,8 +83,12 @@ impl Decodable for Ident { #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Symbol(u32); -// The interner in thread-local, so `Symbol` shouldn't move between threads. +// The interner is pointed to by a thread local value which is only set on the main thread +// with parallelization is disabled. So we don't allow Symbol to transfer between threads +// to avoid panics and other errors, even though it would be memory safe to do so. +#[cfg(not(parallel_queries))] impl !Send for Symbol { } +#[cfg(not(parallel_queries))] impl !Sync for Symbol { } impl Symbol { -- cgit 1.4.1-3-g733a5 From 1dbc84d0066c4689a1e3de21f5a22d87e74a2ac1 Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Wed, 7 Mar 2018 02:43:50 +0100 Subject: Remove rustc_global! --- src/librustc_data_structures/sync.rs | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index d7cd459e577..f066ea98f91 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -26,11 +26,6 @@ //! //! `MTLock` is a mutex which disappears if cfg!(parallel_queries) is false. //! -//! `rustc_global!` gives us a way to declare variables which are intended to be -//! global for the current rustc session. This currently maps to thread-locals, -//! since rustdoc uses the rustc libraries in multiple threads. -//! These globals should eventually be moved into the `Session` structure. -//! //! `rustc_erase_owner!` erases a OwningRef owner into Erased or Erased + Send + Sync //! depending on the value of cfg!(parallel_queries). @@ -228,31 +223,6 @@ pub fn assert_sync() {} pub fn assert_send_val(_t: &T) {} pub fn assert_send_sync_val(_t: &T) {} -#[macro_export] -#[allow_internal_unstable] -macro_rules! rustc_global { - // empty (base case for the recursion) - () => {}; - - // process multiple declarations - ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr; $($rest:tt)*) => ( - thread_local!($(#[$attr])* $vis static $name: $t = $init); - rustc_global!($($rest)*); - ); - - // handle a single declaration - ($(#[$attr:meta])* $vis:vis static $name:ident: $t:ty = $init:expr) => ( - thread_local!($(#[$attr])* $vis static $name: $t = $init); - ); -} - -#[macro_export] -macro_rules! rustc_access_global { - ($name:path, $callback:expr) => { - $name.with($callback) - } -} - impl Debug for LockCell { fn fmt(&self, f: &mut Formatter) -> fmt::Result { f.debug_struct("LockCell") -- cgit 1.4.1-3-g733a5 From 1551ef181267ea1e5db534b247148aba6bd14970 Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Wed, 14 Mar 2018 23:23:46 +0100 Subject: Don't get the global lock in the fast case --- src/librustc/ty/context.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index fd3465f59eb..37a539cfff4 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -161,12 +161,12 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { -> Ty<'tcx> { let ty = { let mut interner = self.type_.borrow_mut(); - let global_interner = global_interners.map(|interners| { - interners.type_.borrow_mut() - }); if let Some(&Interned(ty)) = interner.get(&st) { return ty; } + let global_interner = global_interners.map(|interners| { + interners.type_.borrow_mut() + }); if let Some(ref interner) = global_interner { if let Some(&Interned(ty)) = interner.get(&st) { return ty; -- cgit 1.4.1-3-g733a5 From 697d3bee96c8e385cea9cf2a01325f033ae160fa Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Wed, 14 Mar 2018 20:11:23 +0100 Subject: Replace Rc with Lrc --- src/librustc/middle/const_val.rs | 4 ++-- src/librustc/traits/query/dropck_outlives.rs | 6 +++--- src/librustc/traits/query/normalize.rs | 6 +++--- src/librustc/ty/structural_impls.rs | 3 ++- src/librustc_mir/interpret/const_eval.rs | 6 +++--- src/librustc_traits/dropck_outlives.rs | 4 ++-- src/librustc_traits/normalize_projection_ty.rs | 4 ++-- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/librustc/middle/const_val.rs b/src/librustc/middle/const_val.rs index 8c3dfd0bce7..19a7576b7ce 100644 --- a/src/librustc/middle/const_val.rs +++ b/src/librustc/middle/const_val.rs @@ -19,7 +19,7 @@ use graphviz::IntoCow; use syntax_pos::Span; use std::borrow::Cow; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; pub type EvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ConstEvalErr<'tcx>>; @@ -52,7 +52,7 @@ impl<'tcx> ConstVal<'tcx> { #[derive(Clone, Debug)] pub struct ConstEvalErr<'tcx> { pub span: Span, - pub kind: Rc>, + pub kind: Lrc>, } #[derive(Clone, Debug)] diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 1caab6fd89e..e16a1082214 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -15,7 +15,7 @@ use std::iter::FromIterator; use traits::query::CanonicalTyGoal; use ty::{self, Ty, TyCtxt}; use ty::subst::Kind; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> { /// Given a type `ty` of some value being dropped, computes a set @@ -182,13 +182,13 @@ impl_stable_hash_for!(struct DropckOutlivesResult<'tcx> { impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for QueryResult<'tcx, DropckOutlivesResult<'tcx>> { // we ought to intern this, but I'm too lazy just now - type Canonicalized = Rc>>>; + type Canonicalized = Lrc>>>; fn intern( _gcx: TyCtxt<'_, 'gcx, 'gcx>, value: Canonical<'gcx, Self::Lifted>, ) -> Self::Canonicalized { - Rc::new(value) + Lrc::new(value) } } diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index 70c5cf5f390..63f50cff4c2 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -17,7 +17,7 @@ use infer::at::At; use infer::canonical::{Canonical, Canonicalize, QueryResult}; use middle::const_val::ConstVal; use mir::interpret::GlobalId; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; use traits::{Obligation, ObligationCause, PredicateObligation, Reveal}; use traits::query::CanonicalProjectionGoal; use traits::project::Normalized; @@ -259,13 +259,13 @@ impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ty::ParamEnvAnd<'tcx, ty::Pr impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for QueryResult<'tcx, NormalizationResult<'tcx>> { // we ought to intern this, but I'm too lazy just now - type Canonicalized = Rc>>>; + type Canonicalized = Lrc>>>; fn intern( _gcx: TyCtxt<'_, 'gcx, 'gcx>, value: Canonical<'gcx, Self::Lifted>, ) -> Self::Canonicalized { - Rc::new(value) + Lrc::new(value) } } diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index c9a69d5405c..3fc20508ad7 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -18,6 +18,7 @@ use ty::{self, Lift, Ty, TyCtxt}; use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use rustc_data_structures::accumulate_vec::AccumulateVec; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; +use rustc_data_structures::sync::Lrc; use mir::interpret; use std::rc::Rc; @@ -465,7 +466,7 @@ impl<'a, 'tcx> Lift<'tcx> for ConstEvalErr<'a> { tcx.lift(&*self.kind).map(|kind| { ConstEvalErr { span: self.span, - kind: Rc::new(kind), + kind: Lrc::new(kind), } }) } diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs index 82eb28287b0..50997089a57 100644 --- a/src/librustc_mir/interpret/const_eval.rs +++ b/src/librustc_mir/interpret/const_eval.rs @@ -14,7 +14,7 @@ use super::{Place, EvalContext, StackPopCleanup, ValTy, PlaceExtra, Memory}; use std::fmt; use std::error::Error; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, @@ -477,7 +477,7 @@ pub fn const_eval_provider<'a, 'tcx>( // Do match-check before building MIR if tcx.check_match(def_id).is_err() { return Err(ConstEvalErr { - kind: Rc::new(CheckMatchError), + kind: Lrc::new(CheckMatchError), span, }); } @@ -489,7 +489,7 @@ pub fn const_eval_provider<'a, 'tcx>( // Do not continue into miri if typeck errors occurred; it will fail horribly if tables.tainted_by_errors { return Err(ConstEvalErr { - kind: Rc::new(TypeckError), + kind: Lrc::new(TypeckError), span, }); } diff --git a/src/librustc_traits/dropck_outlives.rs b/src/librustc_traits/dropck_outlives.rs index 2a8cfe5cc06..1fe2f87128a 100644 --- a/src/librustc_traits/dropck_outlives.rs +++ b/src/librustc_traits/dropck_outlives.rs @@ -16,14 +16,14 @@ use rustc::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResu use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt}; use rustc::ty::subst::Subst; use rustc::util::nodemap::FxHashSet; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; use syntax::codemap::{Span, DUMMY_SP}; use util; crate fn dropck_outlives<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, goal: CanonicalTyGoal<'tcx>, -) -> Result>>>, NoSolution> { +) -> Result>>>, NoSolution> { debug!("dropck_outlives(goal={:#?})", goal); tcx.infer_ctxt().enter(|ref infcx| { diff --git a/src/librustc_traits/normalize_projection_ty.rs b/src/librustc_traits/normalize_projection_ty.rs index 55785d9586c..62d5ef11551 100644 --- a/src/librustc_traits/normalize_projection_ty.rs +++ b/src/librustc_traits/normalize_projection_ty.rs @@ -14,7 +14,7 @@ use rustc::traits::{self, FulfillmentContext, Normalized, ObligationCause, use rustc::traits::query::{CanonicalProjectionGoal, NoSolution, normalize::NormalizationResult}; use rustc::ty::{ParamEnvAnd, TyCtxt}; use rustc::util::common::CellUsizeExt; -use std::rc::Rc; +use rustc_data_structures::sync::Lrc; use syntax::ast::DUMMY_NODE_ID; use syntax_pos::DUMMY_SP; use util; @@ -22,7 +22,7 @@ use util; crate fn normalize_projection_ty<'tcx>( tcx: TyCtxt<'_, 'tcx, 'tcx>, goal: CanonicalProjectionGoal<'tcx>, -) -> Result>>>, NoSolution> { +) -> Result>>>, NoSolution> { debug!("normalize_provider(goal={:#?})", goal); tcx.sess.perf_stats.normalize_projection_ty.increment(); -- cgit 1.4.1-3-g733a5 From 8e5eb025a2b438eaaf609894ed910458078cc899 Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Wed, 14 Mar 2018 20:13:42 +0100 Subject: Add an Default impl for Lock --- src/librustc_data_structures/sync.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc_data_structures/sync.rs b/src/librustc_data_structures/sync.rs index f066ea98f91..184ef136976 100644 --- a/src/librustc_data_structures/sync.rs +++ b/src/librustc_data_structures/sync.rs @@ -333,6 +333,13 @@ impl Lock { } } +impl Default for Lock { + #[inline] + fn default() -> Self { + Lock::new(T::default()) + } +} + // FIXME: Probably a bad idea impl Clone for Lock { #[inline] -- cgit 1.4.1-3-g733a5 From 37f9c7ff8281696545c72fc4f24e61d72b9e8df4 Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Thu, 15 Mar 2018 10:38:12 +0100 Subject: Add OnDrop --- src/librustc_data_structures/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 81246aea1b5..bf0b3726bb3 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -76,6 +76,14 @@ pub mod flock; pub mod sync; pub mod owning_ref; +pub struct OnDrop(pub F); + +impl Drop for OnDrop { + fn drop(&mut self) { + (self.0)(); + } +} + // See comments in src/librustc/lib.rs #[doc(hidden)] pub fn __noop_fix_for_27438() {} -- cgit 1.4.1-3-g733a5 From ec4a9c6b2fb188ffd5eeee00e635061fb784af5d Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Thu, 15 Mar 2018 10:01:17 +0100 Subject: Minor cleanup --- src/librustc/ty/context.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 37a539cfff4..fbee9a0ec5c 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1010,17 +1010,16 @@ impl<'tcx> InterpretInterner<'tcx> { } } -impl<'tcx> GlobalCtxt<'tcx> { +impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { /// Get the global TyCtxt. - pub fn global_tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx> { + #[inline] + pub fn global_tcx(self) -> TyCtxt<'a, 'gcx, 'gcx> { TyCtxt { - gcx: self, - interners: &self.global_interners + gcx: self.gcx, + interners: &self.gcx.global_interners, } } -} -impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics { self.global_arenas.generics.alloc(generics) } -- cgit 1.4.1-3-g733a5 From e09c2ff3f85b428cd8283a7f7d9b38843bbc95a9 Mon Sep 17 00:00:00 2001 From: John KÃ¥re Alsaker Date: Sat, 17 Mar 2018 23:02:27 +0100 Subject: Make interners thread-safe --- src/librustc/ty/context.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index fbee9a0ec5c..966c96e594f 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1080,12 +1080,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self, alloc: interpret::Allocation, ) -> &'gcx interpret::Allocation { - if let Some(alloc) = self.interpret_interner.inner.borrow().allocs.get(&alloc) { + let allocs = &mut self.interpret_interner.inner.borrow_mut().allocs; + if let Some(alloc) = allocs.get(&alloc) { return alloc; } let interned = self.global_arenas.const_allocs.alloc(alloc); - if let Some(prev) = self.interpret_interner.inner.borrow_mut().allocs.replace(interned) { + if let Some(prev) = allocs.replace(interned) { bug!("Tried to overwrite interned Allocation: {:#?}", prev) } interned @@ -1112,24 +1113,26 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn intern_stability(self, stab: attr::Stability) -> &'gcx attr::Stability { - if let Some(st) = self.stability_interner.borrow().get(&stab) { + let mut stability_interner = self.stability_interner.borrow_mut(); + if let Some(st) = stability_interner.get(&stab) { return st; } let interned = self.global_interners.arena.alloc(stab); - if let Some(prev) = self.stability_interner.borrow_mut().replace(interned) { + if let Some(prev) = stability_interner.replace(interned) { bug!("Tried to overwrite interned Stability: {:?}", prev) } interned } pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails { - if let Some(layout) = self.layout_interner.borrow().get(&layout) { + let mut layout_interner = self.layout_interner.borrow_mut(); + if let Some(layout) = layout_interner.get(&layout) { return layout; } let interned = self.global_arenas.layout.alloc(layout); - if let Some(prev) = self.layout_interner.borrow_mut().replace(interned) { + if let Some(prev) = layout_interner.replace(interned) { bug!("Tried to overwrite interned Layout: {:?}", prev) } interned -- cgit 1.4.1-3-g733a5 From f40877feeb17c538a73fe6294d48af123251a8c5 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 16 Feb 2018 10:39:24 +0100 Subject: Add 12 num::NonZero* types for each primitive integer RFC: https://github.com/rust-lang/rfcs/pull/2307 --- src/libcore/nonzero.rs | 2 +- src/libcore/num/mod.rs | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/libstd/lib.rs | 1 + src/libstd/num.rs | 11 +++++++ 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index 2c966eb3b57..c6a1dab5617 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -62,7 +62,7 @@ impl_zeroable_for_integer_types! { /// NULL or 0 that might allow certain optimizations. #[lang = "non_zero"] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] -pub struct NonZero(T); +pub struct NonZero(pub(crate) T); impl NonZero { /// Creates an instance of NonZero with the provided value. diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 09ab7060d37..d3556ef742b 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -15,9 +15,96 @@ use convert::{Infallible, TryFrom}; use fmt; use intrinsics; +use nonzero::NonZero; use ops; use str::FromStr; +macro_rules! impl_nonzero_fmt { + ( #[$stability: meta] ( $( $Trait: ident ),+ ) for $Ty: ident ) => { + $( + #[$stability] + impl fmt::$Trait for $Ty { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.get().fmt(f) + } + } + )+ + } +} + +macro_rules! nonzero_integers { + ( #[$stability: meta] $( $Ty: ident($Int: ty); )+ ) => { + $( + /// An integer that is known not to equal zero. + /// + /// This may enable some memory layout optimization such as: + /// + /// ```rust + /// # #![feature(nonzero)] + /// use std::mem::size_of; + /// assert_eq!(size_of::>(), size_of::()); + /// ``` + #[$stability] + #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] + pub struct $Ty(NonZero<$Int>); + + impl $Ty { + /// Create a non-zero without checking the value. + /// + /// # Safety + /// + /// The value must not be zero. + #[$stability] + #[inline] + pub const unsafe fn new_unchecked(n: $Int) -> Self { + $Ty(NonZero(n)) + } + + /// Create a non-zero if the given value is not zero. + #[$stability] + #[inline] + pub fn new(n: $Int) -> Option { + if n != 0 { + Some($Ty(NonZero(n))) + } else { + None + } + } + + /// Returns the value as a primitive type. + #[$stability] + #[inline] + pub fn get(self) -> $Int { + self.0 .0 + } + + } + + impl_nonzero_fmt! { + #[$stability] + (Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty + } + )+ + } +} + +nonzero_integers! { + #[unstable(feature = "nonzero", issue = "27730")] + NonZeroU8(u8); NonZeroI8(i8); + NonZeroU16(u16); NonZeroI16(i16); + NonZeroU32(u32); NonZeroI32(i32); + NonZeroU64(u64); NonZeroI64(i64); + NonZeroUsize(usize); NonZeroIsize(isize); +} + +nonzero_integers! { + // Change this to `#[unstable(feature = "i128", issue = "35118")]` + // if other NonZero* integer types are stabilizied before 128-bit integers + #[unstable(feature = "nonzero", issue = "27730")] + NonZeroU128(u128); NonZeroI128(i128); +} + /// Provides intentionally-wrapped arithmetic on `T`. /// /// Operations like `+` on `u32` values is intended to never overflow, diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 70a1f82c9a1..5c0a83fde10 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -282,6 +282,7 @@ #![feature(macro_vis_matcher)] #![feature(needs_panic_runtime)] #![feature(exhaustive_patterns)] +#![feature(nonzero)] #![feature(num_bits_bytes)] #![feature(old_wrapping)] #![feature(on_unimplemented)] diff --git a/src/libstd/num.rs b/src/libstd/num.rs index a2c133954a3..5e0406ca220 100644 --- a/src/libstd/num.rs +++ b/src/libstd/num.rs @@ -21,6 +21,17 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} #[stable(feature = "rust1", since = "1.0.0")] pub use core::num::Wrapping; +#[unstable(feature = "nonzero", issue = "27730")] +pub use core::num::{ + NonZeroU8, NonZeroI8, NonZeroU16, NonZeroI16, NonZeroU32, NonZeroI32, + NonZeroU64, NonZeroI64, NonZeroUsize, NonZeroIsize, +}; + +// Change this to `#[unstable(feature = "i128", issue = "35118")]` +// if other NonZero* integer types are stabilizied before 128-bit integers +#[unstable(feature = "nonzero", issue = "27730")] +pub use core::num::{NonZeroU128, NonZeroI128}; + #[cfg(test)] use fmt; #[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem}; -- cgit 1.4.1-3-g733a5 From 2d13ddb6e14322edcd07135a436d0d848d127fb2 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 16 Feb 2018 10:58:48 +0100 Subject: Use NonNull<_> instead of NonZero<*const _> in btree internals --- src/liballoc/btree/node.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/liballoc/btree/node.rs b/src/liballoc/btree/node.rs index c1618043ce6..464f8f2f4ec 100644 --- a/src/liballoc/btree/node.rs +++ b/src/liballoc/btree/node.rs @@ -43,8 +43,7 @@ use core::marker::PhantomData; use core::mem; -use core::nonzero::NonZero; -use core::ptr::{self, Unique}; +use core::ptr::{self, Unique, NonNull}; use core::slice; use boxed::Box; @@ -149,14 +148,12 @@ impl BoxedNode { } } - unsafe fn from_ptr(ptr: NonZero<*const LeafNode>) -> Self { - BoxedNode { ptr: Unique::new_unchecked(ptr.get() as *mut LeafNode) } + unsafe fn from_ptr(ptr: NonNull>) -> Self { + BoxedNode { ptr: Unique::from(ptr) } } - fn as_ptr(&self) -> NonZero<*const LeafNode> { - unsafe { - NonZero::from(self.ptr.as_ref()) - } + fn as_ptr(&self) -> NonNull> { + NonNull::from(self.ptr) } } @@ -276,7 +273,7 @@ impl Root { /// `NodeRef` could be pointing to either type of node. pub struct NodeRef { height: usize, - node: NonZero<*const LeafNode>, + node: NonNull>, // This is null unless the borrow type is `Mut` root: *const Root, _marker: PhantomData<(BorrowType, Type)> @@ -302,7 +299,7 @@ unsafe impl Send impl NodeRef { fn as_internal(&self) -> &InternalNode { unsafe { - &*(self.node.get() as *const InternalNode) + &*(self.node.as_ptr() as *mut InternalNode) } } } @@ -310,7 +307,7 @@ impl NodeRef { impl<'a, K, V> NodeRef, K, V, marker::Internal> { fn as_internal_mut(&mut self) -> &mut InternalNode { unsafe { - &mut *(self.node.get() as *mut InternalNode) + &mut *(self.node.as_ptr() as *mut InternalNode) } } } @@ -352,7 +349,7 @@ impl NodeRef { fn as_leaf(&self) -> &LeafNode { unsafe { - &*self.node.get() + self.node.as_ref() } } @@ -382,7 +379,8 @@ impl NodeRef { >, Self > { - if let Some(non_zero) = NonZero::new(self.as_leaf().parent as *const LeafNode) { + let parent_as_leaf = self.as_leaf().parent as *const LeafNode; + if let Some(non_zero) = NonNull::new(parent_as_leaf as *mut _) { Ok(Handle { node: NodeRef { height: self.height + 1, @@ -498,7 +496,7 @@ impl<'a, K, V, Type> NodeRef, K, V, Type> { fn as_leaf_mut(&mut self) -> &mut LeafNode { unsafe { - &mut *(self.node.get() as *mut LeafNode) + self.node.as_mut() } } @@ -1241,12 +1239,12 @@ impl<'a, K, V> Handle, K, V, marker::Internal>, marker:: } Heap.dealloc( - right_node.node.get() as *mut u8, + right_node.node.as_ptr() as *mut u8, Layout::new::>(), ); } else { Heap.dealloc( - right_node.node.get() as *mut u8, + right_node.node.as_ptr() as *mut u8, Layout::new::>(), ); } -- cgit 1.4.1-3-g733a5 From 67f46ce1122121849890ad51c35f0eb6ded14b6f Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 16 Feb 2018 11:02:06 +0100 Subject: Use num::NonZero* instead of NonZero<_> in rustc and tests --- src/libcore/tests/nonzero.rs | 14 +++++----- src/librustc/ty/subst.rs | 6 ++--- .../obligation_forest/node_index.rs | 6 ++--- src/librustc_mir/dataflow/move_paths/mod.rs | 6 ++--- src/test/run-pass/enum-null-pointer-opt.rs | 9 +++---- src/test/run-pass/issue-23433.rs | 2 +- src/test/ui/print_type_sizes/niche-filling.rs | 31 ++++++++-------------- src/test/ui/print_type_sizes/niche-filling.stdout | 10 ++++--- 8 files changed, 38 insertions(+), 46 deletions(-) diff --git a/src/libcore/tests/nonzero.rs b/src/libcore/tests/nonzero.rs index a795dd57504..9eaf7529dd3 100644 --- a/src/libcore/tests/nonzero.rs +++ b/src/libcore/tests/nonzero.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::nonzero::NonZero; +use core::num::NonZeroU32; use core::option::Option; use core::option::Option::{Some, None}; use std::mem::size_of; @@ -16,28 +16,28 @@ use std::mem::size_of; #[test] fn test_create_nonzero_instance() { let _a = unsafe { - NonZero::new_unchecked(21) + NonZeroU32::new_unchecked(21) }; } #[test] fn test_size_nonzero_in_option() { - assert_eq!(size_of::>(), size_of::>>()); + assert_eq!(size_of::(), size_of::>()); } #[test] fn test_match_on_nonzero_option() { let a = Some(unsafe { - NonZero::new_unchecked(42) + NonZeroU32::new_unchecked(42) }); match a { Some(val) => assert_eq!(val.get(), 42), - None => panic!("unexpected None while matching on Some(NonZero(_))") + None => panic!("unexpected None while matching on Some(NonZeroU32(_))") } - match unsafe { Some(NonZero::new_unchecked(43)) } { + match unsafe { Some(NonZeroU32::new_unchecked(43)) } { Some(val) => assert_eq!(val.get(), 43), - None => panic!("unexpected None while matching on Some(NonZero(_))") + None => panic!("unexpected None while matching on Some(NonZeroU32(_))") } } diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index a301049fe1c..e7b58ae1564 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -19,11 +19,11 @@ use syntax_pos::{Span, DUMMY_SP}; use rustc_data_structures::accumulate_vec::AccumulateVec; use core::intrinsics; -use core::nonzero::NonZero; use std::fmt; use std::iter; use std::marker::PhantomData; use std::mem; +use std::num::NonZeroUsize; /// An entity in the Rust typesystem, which can be one of /// several kinds (only types and lifetimes for now). @@ -32,7 +32,7 @@ use std::mem; /// indicate the type (`Ty` or `Region`) it points to. #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct Kind<'tcx> { - ptr: NonZero, + ptr: NonZeroUsize, marker: PhantomData<(Ty<'tcx>, ty::Region<'tcx>)> } @@ -63,7 +63,7 @@ impl<'tcx> UnpackedKind<'tcx> { Kind { ptr: unsafe { - NonZero::new_unchecked(ptr | tag) + NonZeroUsize::new_unchecked(ptr | tag) }, marker: PhantomData } diff --git a/src/librustc_data_structures/obligation_forest/node_index.rs b/src/librustc_data_structures/obligation_forest/node_index.rs index a72cc6b57ea..37512e4bcd5 100644 --- a/src/librustc_data_structures/obligation_forest/node_index.rs +++ b/src/librustc_data_structures/obligation_forest/node_index.rs @@ -8,18 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::nonzero::NonZero; +use std::num::NonZeroU32; use std::u32; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct NodeIndex { - index: NonZero, + index: NonZeroU32, } impl NodeIndex { pub fn new(value: usize) -> NodeIndex { assert!(value < (u32::MAX as usize)); - NodeIndex { index: NonZero::new((value as u32) + 1).unwrap() } + NodeIndex { index: NonZeroU32::new((value as u32) + 1).unwrap() } } pub fn get(self) -> usize { diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index 7b6ebc6fba8..9f6cf8c036e 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -29,17 +29,17 @@ mod abs_domain; // (which is likely to yield a subtle off-by-one error). pub(crate) mod indexes { use std::fmt; - use core::nonzero::NonZero; + use std::num::NonZeroUsize; use rustc_data_structures::indexed_vec::Idx; macro_rules! new_index { ($Index:ident, $debug_name:expr) => { #[derive(Copy, Clone, PartialEq, Eq, Hash)] - pub struct $Index(NonZero); + pub struct $Index(NonZeroUsize); impl Idx for $Index { fn new(idx: usize) -> Self { - $Index(NonZero::new(idx + 1).unwrap()) + $Index(NonZeroUsize::new(idx + 1).unwrap()) } fn index(self) -> usize { self.0.get() - 1 diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index e296aff2782..12f17a1575e 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -10,10 +10,9 @@ #![feature(nonzero, core)] -extern crate core; - -use core::nonzero::NonZero; use std::mem::size_of; +use std::num::NonZeroUsize; +use std::ptr::NonNull; use std::rc::Rc; use std::sync::Arc; @@ -59,8 +58,8 @@ fn main() { assert_eq!(size_of::<[Box; 1]>(), size_of::; 1]>>()); // Should apply to NonZero - assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::>(), size_of::>>()); + assert_eq!(size_of::(), size_of::>()); + assert_eq!(size_of::>(), size_of::>>()); // Should apply to types that use NonZero internally assert_eq!(size_of::>(), size_of::>>()); diff --git a/src/test/run-pass/issue-23433.rs b/src/test/run-pass/issue-23433.rs index 7af732f561d..9547b2f08a6 100644 --- a/src/test/run-pass/issue-23433.rs +++ b/src/test/run-pass/issue-23433.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Don't fail if we encounter a NonZero<*T> where T is an unsized type +// Don't fail if we encounter a NonNull where T is an unsized type use std::ptr::NonNull; diff --git a/src/test/ui/print_type_sizes/niche-filling.rs b/src/test/ui/print_type_sizes/niche-filling.rs index 7f234e243e9..875883a2cca 100644 --- a/src/test/ui/print_type_sizes/niche-filling.rs +++ b/src/test/ui/print_type_sizes/niche-filling.rs @@ -14,7 +14,7 @@ // This file illustrates how niche-filling enums are handled, // modelled after cases like `Option<&u32>`, `Option` and such. // -// It uses NonZero directly, rather than `&_` or `Unique<_>`, because +// It uses NonZeroU32 rather than `&_` or `Unique<_>`, because // the test is not set up to deal with target-dependent pointer width. // // It avoids using u64/i64 because on some targets that is only 4-byte @@ -25,8 +25,7 @@ #![feature(nonzero)] #![allow(dead_code)] -extern crate core; -use core::nonzero::{NonZero, Zeroable}; +use std::num::NonZeroU32; pub enum MyOption { None, Some(T) } @@ -36,7 +35,7 @@ impl Default for MyOption { pub enum EmbeddedDiscr { None, - Record { pre: u8, val: NonZero, post: u16 }, + Record { pre: u8, val: NonZeroU32, post: u16 }, } impl Default for EmbeddedDiscr { @@ -44,32 +43,24 @@ impl Default for EmbeddedDiscr { } #[derive(Default)] -pub struct IndirectNonZero { +pub struct IndirectNonZero { pre: u8, - nested: NestedNonZero, + nested: NestedNonZero, post: u16, } -pub struct NestedNonZero { +pub struct NestedNonZero { pre: u8, - val: NonZero, + val: NonZeroU32, post: u16, } -impl Default for NestedNonZero { +impl Default for NestedNonZero { fn default() -> Self { - NestedNonZero { pre: 0, val: NonZero::new(T::one()).unwrap(), post: 0 } + NestedNonZero { pre: 0, val: NonZeroU32::new(1).unwrap(), post: 0 } } } -pub trait One { - fn one() -> Self; -} - -impl One for u32 { - fn one() -> Self { 1 } -} - pub enum Enum4 { One(A), Two(B), @@ -79,9 +70,9 @@ pub enum Enum4 { #[start] fn start(_: isize, _: *const *const u8) -> isize { - let _x: MyOption> = Default::default(); + let _x: MyOption = Default::default(); let _y: EmbeddedDiscr = Default::default(); - let _z: MyOption> = Default::default(); + let _z: MyOption = Default::default(); let _a: MyOption = Default::default(); let _b: MyOption = Default::default(); let _c: MyOption = Default::default(); diff --git a/src/test/ui/print_type_sizes/niche-filling.stdout b/src/test/ui/print_type_sizes/niche-filling.stdout index 0f53e7722dd..79f9ef5a231 100644 --- a/src/test/ui/print_type_sizes/niche-filling.stdout +++ b/src/test/ui/print_type_sizes/niche-filling.stdout @@ -1,9 +1,9 @@ -print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes +print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes print-type-size field `.nested`: 8 bytes print-type-size field `.post`: 2 bytes print-type-size field `.pre`: 1 bytes print-type-size end padding: 1 bytes -print-type-size type: `MyOption>`: 12 bytes, alignment: 4 bytes +print-type-size type: `MyOption`: 12 bytes, alignment: 4 bytes print-type-size variant `None`: 0 bytes print-type-size variant `Some`: 12 bytes print-type-size field `.0`: 12 bytes @@ -14,7 +14,7 @@ print-type-size field `.val`: 4 bytes print-type-size field `.post`: 2 bytes print-type-size field `.pre`: 1 bytes print-type-size end padding: 1 bytes -print-type-size type: `NestedNonZero`: 8 bytes, alignment: 4 bytes +print-type-size type: `NestedNonZero`: 8 bytes, alignment: 4 bytes print-type-size field `.val`: 4 bytes print-type-size field `.post`: 2 bytes print-type-size field `.pre`: 1 bytes @@ -32,12 +32,14 @@ print-type-size type: `MyOption`: 4 bytes, alignment: 4 bytes print-type-size variant `None`: 0 bytes print-type-size variant `Some`: 4 bytes print-type-size field `.0`: 4 bytes -print-type-size type: `MyOption>`: 4 bytes, alignment: 4 bytes +print-type-size type: `MyOption`: 4 bytes, alignment: 4 bytes print-type-size variant `None`: 0 bytes print-type-size variant `Some`: 4 bytes print-type-size field `.0`: 4 bytes print-type-size type: `core::nonzero::NonZero`: 4 bytes, alignment: 4 bytes print-type-size field `.0`: 4 bytes +print-type-size type: `std::num::NonZeroU32`: 4 bytes, alignment: 4 bytes +print-type-size field `.0`: 4 bytes print-type-size type: `Enum4<(), (), (), MyOption>`: 2 bytes, alignment: 1 bytes print-type-size variant `One`: 0 bytes print-type-size field `.0`: 0 bytes -- cgit 1.4.1-3-g733a5 From 22f7a0295828c0d75b5487d89343e722b406dd5f Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 16 Feb 2018 11:14:35 +0100 Subject: Deprecate core::nonzero in favor of ptr::NonNull and num::NonZero* --- src/libcore/nonzero.rs | 5 ++++- src/libcore/num/mod.rs | 4 +++- src/libcore/ptr.rs | 11 +++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index c6a1dab5617..59aaef9d66a 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -10,8 +10,11 @@ //! Exposes the NonZero lang item which provides optimization hints. #![unstable(feature = "nonzero", - reason = "needs an RFC to flesh out the design", + reason = "deprecated", issue = "27730")] +#![rustc_deprecated(reason = "use `std::ptr::NonNull` or `std::num::NonZero*` instead", + since = "1.26.0")] +#![allow(deprecated)] use ops::CoerceUnsized; diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index d3556ef742b..84f6ab9b764 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -15,7 +15,7 @@ use convert::{Infallible, TryFrom}; use fmt; use intrinsics; -use nonzero::NonZero; +#[allow(deprecated)] use nonzero::NonZero; use ops; use str::FromStr; @@ -46,9 +46,11 @@ macro_rules! nonzero_integers { /// assert_eq!(size_of::>(), size_of::()); /// ``` #[$stability] + #[allow(deprecated)] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct $Ty(NonZero<$Int>); + #[allow(deprecated)] impl $Ty { /// Create a non-zero without checking the value. /// diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 6270e5892b3..834a2ed09f7 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -23,7 +23,7 @@ use fmt; use hash; use marker::{PhantomData, Unsize}; use mem; -use nonzero::NonZero; +#[allow(deprecated)] use nonzero::NonZero; use cmp::Ordering::{self, Less, Equal, Greater}; @@ -2285,6 +2285,7 @@ impl PartialOrd for *mut T { #[unstable(feature = "ptr_internals", issue = "0", reason = "use NonNull instead and consider PhantomData \ (if you also use #[may_dangle]), Send, and/or Sync")] +#[allow(deprecated)] pub struct Unique { pointer: NonZero<*const T>, // NOTE: this marker has no consequences for variance, but is necessary @@ -2332,6 +2333,7 @@ impl Unique { } #[unstable(feature = "ptr_internals", issue = "0")] +#[allow(deprecated)] impl Unique { /// Creates a new `Unique`. /// @@ -2392,6 +2394,7 @@ impl fmt::Pointer for Unique { } #[unstable(feature = "ptr_internals", issue = "0")] +#[allow(deprecated)] impl<'a, T: ?Sized> From<&'a mut T> for Unique { fn from(reference: &'a mut T) -> Self { Unique { pointer: NonZero::from(reference), _marker: PhantomData } @@ -2399,6 +2402,7 @@ impl<'a, T: ?Sized> From<&'a mut T> for Unique { } #[unstable(feature = "ptr_internals", issue = "0")] +#[allow(deprecated)] impl<'a, T: ?Sized> From<&'a T> for Unique { fn from(reference: &'a T) -> Self { Unique { pointer: NonZero::from(reference), _marker: PhantomData } @@ -2436,7 +2440,7 @@ pub type Shared = NonNull; /// provide a public API that follows the normal shared XOR mutable rules of Rust. #[stable(feature = "nonnull", since = "1.25.0")] pub struct NonNull { - pointer: NonZero<*const T>, + #[allow(deprecated)] pointer: NonZero<*const T>, } /// `NonNull` pointers are not `Send` because the data they reference may be aliased. @@ -2463,6 +2467,7 @@ impl NonNull { } } +#[allow(deprecated)] impl NonNull { /// Creates a new `NonNull`. /// @@ -2581,6 +2586,7 @@ impl From> for NonNull { } #[stable(feature = "nonnull", since = "1.25.0")] +#[allow(deprecated)] impl<'a, T: ?Sized> From<&'a mut T> for NonNull { fn from(reference: &'a mut T) -> Self { NonNull { pointer: NonZero::from(reference) } @@ -2588,6 +2594,7 @@ impl<'a, T: ?Sized> From<&'a mut T> for NonNull { } #[stable(feature = "nonnull", since = "1.25.0")] +#[allow(deprecated)] impl<'a, T: ?Sized> From<&'a T> for NonNull { fn from(reference: &'a T) -> Self { NonNull { pointer: NonZero::from(reference) } -- cgit 1.4.1-3-g733a5 From 6d682c9adc12c5aee1bac37afa15f01b420be8ee Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 16 Feb 2018 11:45:44 +0100 Subject: Stop using deprecated NonZero APIs These will eventually be removed (though the NonZero lang item will likely stay). --- src/libcore/ptr.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 834a2ed09f7..4ab0ceb7967 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2341,17 +2341,21 @@ impl Unique { /// /// `ptr` must be non-null. pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { - Unique { pointer: NonZero::new_unchecked(ptr), _marker: PhantomData } + Unique { pointer: NonZero(ptr as _), _marker: PhantomData } } /// Creates a new `Unique` if `ptr` is non-null. pub fn new(ptr: *mut T) -> Option { - NonZero::new(ptr as *const T).map(|nz| Unique { pointer: nz, _marker: PhantomData }) + if !ptr.is_null() { + Some(Unique { pointer: NonZero(ptr as _), _marker: PhantomData }) + } else { + None + } } /// Acquires the underlying `*mut` pointer. pub fn as_ptr(self) -> *mut T { - self.pointer.get() as *mut T + self.pointer.0 as *mut T } /// Dereferences the content. @@ -2397,7 +2401,7 @@ impl fmt::Pointer for Unique { #[allow(deprecated)] impl<'a, T: ?Sized> From<&'a mut T> for Unique { fn from(reference: &'a mut T) -> Self { - Unique { pointer: NonZero::from(reference), _marker: PhantomData } + Unique { pointer: NonZero(reference as _), _marker: PhantomData } } } @@ -2405,7 +2409,7 @@ impl<'a, T: ?Sized> From<&'a mut T> for Unique { #[allow(deprecated)] impl<'a, T: ?Sized> From<&'a T> for Unique { fn from(reference: &'a T) -> Self { - Unique { pointer: NonZero::from(reference), _marker: PhantomData } + Unique { pointer: NonZero(reference as _), _marker: PhantomData } } } @@ -2476,19 +2480,23 @@ impl NonNull { /// `ptr` must be non-null. #[stable(feature = "nonnull", since = "1.25.0")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { - NonNull { pointer: NonZero::new_unchecked(ptr) } + NonNull { pointer: NonZero(ptr as _) } } /// Creates a new `NonNull` if `ptr` is non-null. #[stable(feature = "nonnull", since = "1.25.0")] pub fn new(ptr: *mut T) -> Option { - NonZero::new(ptr as *const T).map(|nz| NonNull { pointer: nz }) + if !ptr.is_null() { + Some(NonNull { pointer: NonZero(ptr as _) }) + } else { + None + } } /// Acquires the underlying `*mut` pointer. #[stable(feature = "nonnull", since = "1.25.0")] pub fn as_ptr(self) -> *mut T { - self.pointer.get() as *mut T + self.pointer.0 as *mut T } /// Dereferences the content. @@ -2589,7 +2597,7 @@ impl From> for NonNull { #[allow(deprecated)] impl<'a, T: ?Sized> From<&'a mut T> for NonNull { fn from(reference: &'a mut T) -> Self { - NonNull { pointer: NonZero::from(reference) } + NonNull { pointer: NonZero(reference as _) } } } @@ -2597,6 +2605,6 @@ impl<'a, T: ?Sized> From<&'a mut T> for NonNull { #[allow(deprecated)] impl<'a, T: ?Sized> From<&'a T> for NonNull { fn from(reference: &'a T) -> Self { - NonNull { pointer: NonZero::from(reference) } + NonNull { pointer: NonZero(reference as _) } } } -- cgit 1.4.1-3-g733a5 From 7cf1f18cb9209156108e3871e11cb5d63f7f1cf1 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Fri, 16 Feb 2018 19:28:13 +0100 Subject: Test NonZero in a const item in a pattern. (This was buggy before https://github.com/rust-lang/rust/pull/46882) --- src/libcore/tests/nonzero.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libcore/tests/nonzero.rs b/src/libcore/tests/nonzero.rs index 9eaf7529dd3..8d39298bac3 100644 --- a/src/libcore/tests/nonzero.rs +++ b/src/libcore/tests/nonzero.rs @@ -98,3 +98,26 @@ fn test_match_option_string() { None => panic!("unexpected None while matching on Some(String { ... })") } } + +mod atom { + use core::num::NonZeroU32; + + #[derive(PartialEq, Eq)] + pub struct Atom { + index: NonZeroU32, // private + } + pub const FOO_ATOM: Atom = Atom { index: unsafe { NonZeroU32::new_unchecked(7) } }; +} + +macro_rules! atom { + ("foo") => { atom::FOO_ATOM } +} + +#[test] +fn test_match_nonzero_const_pattern() { + match atom!("foo") { + // Using as a pattern is supported by the compiler: + atom!("foo") => {} + _ => panic!("Expected the const item as a pattern to match.") + } +} -- cgit 1.4.1-3-g733a5 From 73c053786dde55059932b9ebcd4a40edf89eae15 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 8 Mar 2018 16:55:51 +0100 Subject: Remove deprecated unstable ptr::Shared type alias. It has been deprecated for about one release cycle. --- src/libcore/cell.rs | 5 ++--- src/libcore/ptr.rs | 5 ----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 36618e86968..c8ee166fee3 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -146,13 +146,12 @@ //! //! ``` //! #![feature(core_intrinsics)] -//! #![feature(shared)] //! use std::cell::Cell; -//! use std::ptr::Shared; +//! use std::ptr::NonNull; //! use std::intrinsics::abort; //! //! struct Rc { -//! ptr: Shared> +//! ptr: NonNull> //! } //! //! struct RcBox { diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 4ab0ceb7967..cebd5989e96 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2420,11 +2420,6 @@ impl<'a, T: ?Sized> From> for Unique { } } -/// Previous name of `NonNull`. -#[rustc_deprecated(since = "1.25.0", reason = "renamed to `NonNull`")] -#[unstable(feature = "shared", issue = "27730")] -pub type Shared = NonNull; - /// `*mut T` but non-zero and covariant. /// /// This is often the correct thing to use when building data structures using -- cgit 1.4.1-3-g733a5 From fad1648e0f8299a8b108f85c2b1055eb37bdab9e Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Fri, 9 Mar 2018 23:56:40 -0600 Subject: Initial implementation of RFC 2151, Raw Identifiers --- src/libproc_macro/lib.rs | 11 ++- src/librustc/ich/impls_syntax.rs | 5 +- src/librustc_passes/ast_validation.rs | 4 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_resolve/macros.rs | 2 +- src/librustc_resolve/resolve_imports.rs | 4 +- src/librustdoc/html/highlight.rs | 8 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/attr.rs | 13 +-- src/libsyntax/diagnostics/plugin.rs | 10 +- src/libsyntax/ext/base.rs | 5 +- src/libsyntax/ext/quote.rs | 11 ++- src/libsyntax/ext/tt/macro_parser.rs | 19 ++-- src/libsyntax/ext/tt/macro_rules.rs | 6 +- src/libsyntax/ext/tt/quoted.rs | 2 +- src/libsyntax/ext/tt/transcribe.rs | 2 +- src/libsyntax/fold.rs | 5 +- src/libsyntax/parse/lexer/mod.rs | 69 ++++++++----- src/libsyntax/parse/mod.rs | 20 ++-- src/libsyntax/parse/parser.rs | 29 +++--- src/libsyntax/parse/token.rs | 108 +++++++++++++++------ src/libsyntax/print/pprust.rs | 40 ++++---- src/libsyntax/tokenstream.rs | 2 +- src/libsyntax_ext/concat_idents.rs | 3 +- src/libsyntax_ext/format.rs | 2 +- src/test/parse-fail/raw-str-delim.rs | 2 +- .../run-pass-fulldeps/auxiliary/roman_numerals.rs | 2 +- src/test/run-pass/rfc-2151-raw-identifiers/attr.rs | 24 +++++ .../run-pass/rfc-2151-raw-identifiers/basic.rs | 29 ++++++ .../run-pass/rfc-2151-raw-identifiers/items.rs | 41 ++++++++ .../run-pass/rfc-2151-raw-identifiers/macros.rs | 47 +++++++++ src/test/ui/raw-literal-keywords.rs | 25 +++++ src/test/ui/raw-literal-keywords.stderr | 20 ++++ src/test/ui/raw-literal-self.rs | 15 +++ src/test/ui/raw-literal-self.stderr | 8 ++ src/test/ui/raw-literal-underscore.rs | 15 +++ src/test/ui/raw-literal-underscore.stderr | 8 ++ 37 files changed, 475 insertions(+), 145 deletions(-) create mode 100644 src/test/run-pass/rfc-2151-raw-identifiers/attr.rs create mode 100644 src/test/run-pass/rfc-2151-raw-identifiers/basic.rs create mode 100644 src/test/run-pass/rfc-2151-raw-identifiers/items.rs create mode 100644 src/test/run-pass/rfc-2151-raw-identifiers/macros.rs create mode 100644 src/test/ui/raw-literal-keywords.rs create mode 100644 src/test/ui/raw-literal-keywords.stderr create mode 100644 src/test/ui/raw-literal-self.rs create mode 100644 src/test/ui/raw-literal-self.stderr create mode 100644 src/test/ui/raw-literal-underscore.rs create mode 100644 src/test/ui/raw-literal-underscore.stderr diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index b239f8018be..d6e679bad48 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -681,7 +681,8 @@ impl TokenTree { Dollar => op!('$'), Question => op!('?'), - Ident(ident) | Lifetime(ident) => TokenNode::Term(Term(ident.name)), + Ident(ident, false) | Lifetime(ident) => TokenNode::Term(Term(ident.name)), + Ident(ident, true) => TokenNode::Term(Term(Symbol::intern(&format!("r#{}", ident)))), Literal(..) | DocComment(..) => TokenNode::Literal(self::Literal(token)), Interpolated(_) => { @@ -713,8 +714,14 @@ impl TokenTree { }, TokenNode::Term(symbol) => { let ident = ast::Ident { name: symbol.0, ctxt: self.span.0.ctxt() }; + let sym_str = symbol.0.as_str(); let token = - if symbol.0.as_str().starts_with("'") { Lifetime(ident) } else { Ident(ident) }; + if sym_str.starts_with("'") { Lifetime(ident) } + else if sym_str.starts_with("r#") { + let name = Symbol::intern(&sym_str[2..]); + let ident = ast::Ident { name, ctxt: self.span.0.ctxt() }; + Ident(ident, true) + } else { Ident(ident, false) }; return TokenTree::Token(self.span.0, token).into(); } TokenNode::Literal(token) => return TokenTree::Token(self.span.0, token.0).into(), diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 513b6c835f9..0b037964981 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -318,7 +318,10 @@ fn hash_token<'a, 'gcx, W: StableHasherResult>( opt_name.hash_stable(hcx, hasher); } - token::Token::Ident(ident) | + token::Token::Ident(ident, is_raw) => { + ident.name.hash_stable(hcx, hasher); + is_raw.hash_stable(hcx, hasher); + } token::Token::Lifetime(ident) => ident.name.hash_stable(hcx, hasher), token::Token::Interpolated(_) => { diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 4215bf306a4..3c33d29585a 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -41,13 +41,13 @@ impl<'a> AstValidator<'a> { keywords::StaticLifetime.name(), keywords::Invalid.name()]; if !valid_names.contains(&lifetime.ident.name) && - token::Ident(lifetime.ident.without_first_quote()).is_reserved_ident() { + token::is_reserved_ident(lifetime.ident.without_first_quote()) { self.err_handler().span_err(lifetime.span, "lifetimes cannot use keyword names"); } } fn check_label(&self, label: Ident, span: Span) { - if token::Ident(label.without_first_quote()).is_reserved_ident() { + if token::is_reserved_ident(label.without_first_quote()) { self.err_handler().span_err(span, &format!("invalid label name `{}`", label.name)); } } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index dc22c23271d..2cb2c76c632 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3206,7 +3206,7 @@ impl<'a> Resolver<'a> { // `$crate::a::b` module = Some(self.resolve_crate_root(ident.node.ctxt, true)); continue - } else if i == 1 && !token::Ident(ident.node).is_path_segment_keyword() { + } else if i == 1 && !token::is_path_segment_keyword(ident.node) { let prev_name = path[0].node.name; if prev_name == keywords::Extern.name() || prev_name == keywords::CrateRoot.name() && diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 95fa0f3b52f..0692a1e0d7f 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -268,7 +268,7 @@ impl<'a> base::Resolver for Resolver<'a> { if k > 0 { tokens.push(TokenTree::Token(path.span, Token::ModSep).into()); } - let tok = Token::Ident(segment.identifier); + let tok = Token::from_ast_ident(segment.identifier); tokens.push(TokenTree::Token(path.span, tok).into()); } } diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 4cbebdc3c1c..78d2357e02b 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -625,7 +625,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { } else { Some(self.resolve_crate_root(source.ctxt.modern(), false)) } - } else if is_extern && !token::Ident(source).is_path_segment_keyword() { + } else if is_extern && !token::is_path_segment_keyword(source) { let crate_id = self.crate_loader.resolve_crate_from_path(source.name, directive.span); let crate_root = @@ -667,7 +667,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { } PathResult::Failed(span, msg, true) => { let (mut self_path, mut self_result) = (module_path.clone(), None); - let is_special = |ident| token::Ident(ident).is_path_segment_keyword() && + let is_special = |ident| token::is_path_segment_keyword(ident) && ident.name != keywords::CrateRoot.name(); if !self_path.is_empty() && !is_special(self_path[0].node) && !(self_path.len() > 1 && is_special(self_path[1].node)) { diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 659ec8a993d..cfa3f5a4e0b 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -323,12 +323,12 @@ impl<'a> Classifier<'a> { } // Keywords are also included in the identifier set. - token::Ident(ident) => { + token::Ident(ident, is_raw) => { match &*ident.name.as_str() { - "ref" | "mut" => Class::RefKeyWord, + "ref" | "mut" if !is_raw => Class::RefKeyWord, - "self" |"Self" => Class::Self_, - "false" | "true" => Class::Bool, + "self" | "Self" => Class::Self_, + "false" | "true" if !is_raw => Class::Bool, "Option" | "Result" => Class::PreludeTy, "Some" | "None" | "Ok" | "Err" => Class::PreludeVal, diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1f16b728cd2..a3af6b247ee 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -112,7 +112,7 @@ impl Path { // or starts with something like `self`/`super`/`$crate`/etc. pub fn make_root(&self) -> Option { if let Some(ident) = self.segments.get(0).map(|seg| seg.identifier) { - if ::parse::token::Ident(ident).is_path_segment_keyword() && + if ::parse::token::is_path_segment_keyword(ident) && ident.name != keywords::Crate.name() { return None; } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f2cdcda98da..5954b9eb274 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -1106,7 +1106,8 @@ impl IntType { impl MetaItem { fn tokens(&self) -> TokenStream { - let ident = TokenTree::Token(self.span, Token::Ident(Ident::with_empty_ctxt(self.name))); + let ident = TokenTree::Token(self.span, + Token::from_ast_ident(Ident::with_empty_ctxt(self.name))); TokenStream::concat(vec![ident.into(), self.node.tokens(self.span)]) } @@ -1114,9 +1115,9 @@ impl MetaItem { where I: Iterator, { let (span, name) = match tokens.next() { - Some(TokenTree::Token(span, Token::Ident(ident))) => (span, ident.name), + Some(TokenTree::Token(span, Token::Ident(ident, _))) => (span, ident.name), Some(TokenTree::Token(_, Token::Interpolated(ref nt))) => match nt.0 { - token::Nonterminal::NtIdent(ident) => (ident.span, ident.node.name), + token::Nonterminal::NtIdent(ident, _) => (ident.span, ident.node.name), token::Nonterminal::NtMeta(ref meta) => return Some(meta.clone()), _ => return None, }, @@ -1269,14 +1270,14 @@ impl LitKind { "true" } else { "false" - }))), + })), false), } } fn from_token(token: Token) -> Option { match token { - Token::Ident(ident) if ident.name == "true" => Some(LitKind::Bool(true)), - Token::Ident(ident) if ident.name == "false" => Some(LitKind::Bool(false)), + Token::Ident(ident, false) if ident.name == "true" => Some(LitKind::Bool(true)), + Token::Ident(ident, false) if ident.name == "false" => Some(LitKind::Bool(false)), Token::Interpolated(ref nt) => match nt.0 { token::NtExpr(ref v) => match v.node { ExprKind::Lit(ref lit) => Some(lit.node.clone()), diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index 2c91844da96..c7e453c9e10 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -44,7 +44,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt, token_tree: &[TokenTree]) -> Box { let code = match (token_tree.len(), token_tree.get(0)) { - (1, Some(&TokenTree::Token(_, token::Ident(code)))) => code, + (1, Some(&TokenTree::Token(_, token::Ident(code, false)))) => code, _ => unreachable!() }; @@ -82,10 +82,10 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, token_tree.get(1), token_tree.get(2) ) { - (1, Some(&TokenTree::Token(_, token::Ident(ref code))), None, None) => { + (1, Some(&TokenTree::Token(_, token::Ident(ref code, false))), None, None) => { (code, None) }, - (3, Some(&TokenTree::Token(_, token::Ident(ref code))), + (3, Some(&TokenTree::Token(_, token::Ident(ref code, false))), Some(&TokenTree::Token(_, token::Comma)), Some(&TokenTree::Token(_, token::Literal(token::StrRaw(description, _), None)))) => { (code, Some(description)) @@ -150,9 +150,9 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, let (crate_name, name) = match (&token_tree[0], &token_tree[2]) { ( // Crate name. - &TokenTree::Token(_, token::Ident(ref crate_name)), + &TokenTree::Token(_, token::Ident(ref crate_name, false)), // DIAGNOSTICS ident. - &TokenTree::Token(_, token::Ident(ref name)) + &TokenTree::Token(_, token::Ident(ref name, false)) ) => (*&crate_name, name), _ => unreachable!() }; diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 23c42972912..c3ae0fd2ca8 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -229,8 +229,9 @@ impl TTMacroExpander for F impl Folder for AvoidInterpolatedIdents { fn fold_tt(&mut self, tt: tokenstream::TokenTree) -> tokenstream::TokenTree { if let tokenstream::TokenTree::Token(_, token::Interpolated(ref nt)) = tt { - if let token::NtIdent(ident) = nt.0 { - return tokenstream::TokenTree::Token(ident.span, token::Ident(ident.node)); + if let token::NtIdent(ident, is_raw) = nt.0 { + return tokenstream::TokenTree::Token(ident.span, + token::Ident(ident.node, is_raw)); } } fold::noop_fold_tt(tt, self) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 6844532e7b3..090b9a35446 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -75,7 +75,7 @@ pub mod rt { impl ToTokens for ast::Ident { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { - vec![TokenTree::Token(DUMMY_SP, token::Ident(*self))] + vec![TokenTree::Token(DUMMY_SP, Token::from_ast_ident(*self))] } } @@ -238,7 +238,8 @@ pub mod rt { if i > 0 { inner.push(TokenTree::Token(self.span, token::Colon).into()); } - inner.push(TokenTree::Token(self.span, token::Ident(segment.identifier)).into()); + inner.push(TokenTree::Token(self.span, + token::Ident(segment.identifier, false)).into()); } inner.push(self.tokens.clone()); @@ -658,10 +659,10 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { token::Literal(token::ByteStr(i), suf) => return mk_lit!("ByteStr", suf, i), token::Literal(token::ByteStrRaw(i, n), suf) => return mk_lit!("ByteStrRaw", suf, i, n), - token::Ident(ident) => { + token::Ident(ident, is_raw) => { return cx.expr_call(sp, mk_token_path(cx, sp, "Ident"), - vec![mk_ident(cx, sp, ident)]); + vec![mk_ident(cx, sp, ident), cx.expr_bool(sp, is_raw)]); } token::Lifetime(ident) => { @@ -720,7 +721,7 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P { fn statements_mk_tt(cx: &ExtCtxt, tt: &TokenTree, quoted: bool) -> Vec { match *tt { - TokenTree::Token(sp, token::Ident(ident)) if quoted => { + TokenTree::Token(sp, token::Ident(ident, _)) if quoted => { // tt.extend($ident.to_tokens(ext_cx)) let e_to_toks = diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 667653b5f7f..714b7ca981d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -365,7 +365,7 @@ pub fn parse_failure_msg(tok: Token) -> String { /// Perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) fn token_name_eq(t1: &Token, t2: &Token) -> bool { if let (Some(id1), Some(id2)) = (t1.ident(), t2.ident()) { - id1.name == id2.name + id1.name == id2.name && t1.is_raw_ident() == t2.is_raw_ident() } else if let (&token::Lifetime(id1), &token::Lifetime(id2)) = (t1, t2) { id1.name == id2.name } else { @@ -711,9 +711,10 @@ pub fn parse( /// The token is an identifier, but not `_`. /// We prohibit passing `_` to macros expecting `ident` for now. -fn get_macro_ident(token: &Token) -> Option { +fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { match *token { - token::Ident(ident) if ident.name != keywords::Underscore.name() => Some(ident), + token::Ident(ident, is_raw) if ident.name != keywords::Underscore.name() => + Some((ident, is_raw)), _ => None, } } @@ -737,7 +738,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { "ident" => get_macro_ident(token).is_some(), "vis" => match *token { // The follow-set of :vis + "priv" keyword + interpolated - Token::Comma | Token::Ident(_) | Token::Interpolated(_) => true, + Token::Comma | Token::Ident(..) | Token::Interpolated(_) => true, _ => token.can_begin_type(), }, "block" => match *token { @@ -746,7 +747,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { token::NtItem(_) | token::NtPat(_) | token::NtTy(_) - | token::NtIdent(_) + | token::NtIdent(..) | token::NtMeta(_) | token::NtPath(_) | token::NtVis(_) => false, // none of these may start with '{'. @@ -755,7 +756,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { _ => false, }, "path" | "meta" => match *token { - Token::ModSep | Token::Ident(_) => true, + Token::ModSep | Token::Ident(..) => true, Token::Interpolated(ref nt) => match nt.0 { token::NtPath(_) | token::NtMeta(_) => true, _ => may_be_ident(&nt.0), @@ -763,7 +764,7 @@ fn may_begin_with(name: &str, token: &Token) -> bool { _ => false, }, "pat" => match *token { - Token::Ident(_) | // box, ref, mut, and other identifiers (can stricten) + Token::Ident(..) | // box, ref, mut, and other identifiers (can stricten) Token::OpenDelim(token::Paren) | // tuple pattern Token::OpenDelim(token::Bracket) | // slice pattern Token::BinOp(token::And) | // reference @@ -823,9 +824,9 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { "expr" => token::NtExpr(panictry!(p.parse_expr())), "ty" => token::NtTy(panictry!(p.parse_ty())), // this could be handled like a token, since it is one - "ident" => if let Some(ident) = get_macro_ident(&p.token) { + "ident" => if let Some((ident, is_raw)) = get_macro_ident(&p.token) { p.bump(); - token::NtIdent(respan(p.prev_span, ident)) + token::NtIdent(respan(p.prev_span, ident), is_raw) } else { let token_str = pprust::token_to_string(&p.token); p.fatal(&format!("expected ident, found {}", &token_str)).emit(); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index a4b2c3990f5..10e5926eb9e 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -831,7 +831,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result match *tok { TokenTree::Token(_, ref tok) => match *tok { FatArrow | Comma | Eq | BinOp(token::Or) => Ok(true), - Ident(i) if i.name == "if" || i.name == "in" => Ok(true), + Ident(i, false) if i.name == "if" || i.name == "in" => Ok(true), _ => Ok(false) }, _ => Ok(false), @@ -840,7 +840,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result match *tok { OpenDelim(token::DelimToken::Brace) | OpenDelim(token::DelimToken::Bracket) | Comma | FatArrow | Colon | Eq | Gt | Semi | BinOp(token::Or) => Ok(true), - Ident(i) if i.name == "as" || i.name == "where" => Ok(true), + Ident(i, false) if i.name == "as" || i.name == "where" => Ok(true), _ => Ok(false) }, TokenTree::MetaVarDecl(_, _, frag) if frag.name == "block" => Ok(true), @@ -860,7 +860,7 @@ fn is_in_follow(tok: "ed::TokenTree, frag: &str) -> Result match *tok { Comma => Ok(true), - Ident(i) if i.name != "priv" => Ok(true), + Ident(i, is_raw) if is_raw || i.name != "priv" => Ok(true), ref tok => Ok(tok.can_begin_type()) }, TokenTree::MetaVarDecl(_, _, frag) if frag.name == "ident" diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 122bb9ba024..11eb9b940ae 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -296,7 +296,7 @@ where name: keywords::DollarCrate.name(), ..ident }; - TokenTree::Token(span, token::Ident(ident)) + TokenTree::Token(span, token::Ident(ident, false)) } else { TokenTree::MetaVar(span, ident) } diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 7883c4bbc16..0f5855a3225 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -169,7 +169,7 @@ pub fn transcribe(cx: &ExtCtxt, Ident { ctxt: ident.ctxt.apply_mark(cx.current_expansion.mark), ..ident }; sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)); result.push(TokenTree::Token(sp, token::Dollar).into()); - result.push(TokenTree::Token(sp, token::Ident(ident)).into()); + result.push(TokenTree::Token(sp, token::Ident(ident, false)).into()); } } quoted::TokenTree::Delimited(mut span, delimited) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 46e6027b094..05a3150c139 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -578,7 +578,7 @@ pub fn noop_fold_tts(tts: TokenStream, fld: &mut T) -> TokenStream { // apply ident folder if it's an ident, apply other folds to interpolated nodes pub fn noop_fold_token(t: token::Token, fld: &mut T) -> token::Token { match t { - token::Ident(id) => token::Ident(fld.fold_ident(id)), + token::Ident(id, is_raw) => token::Ident(fld.fold_ident(id), is_raw), token::Lifetime(id) => token::Lifetime(fld.fold_ident(id)), token::Interpolated(nt) => { let nt = match Lrc::try_unwrap(nt) { @@ -630,7 +630,8 @@ pub fn noop_fold_interpolated(nt: token::Nonterminal, fld: &mut T) token::NtPat(pat) => token::NtPat(fld.fold_pat(pat)), token::NtExpr(expr) => token::NtExpr(fld.fold_expr(expr)), token::NtTy(ty) => token::NtTy(fld.fold_ty(ty)), - token::NtIdent(id) => token::NtIdent(Spanned::{node: fld.fold_ident(id.node), ..id}), + token::NtIdent(id, is_raw) => + token::NtIdent(Spanned::{node: fld.fold_ident(id.node), ..id}, is_raw), token::NtMeta(meta) => token::NtMeta(fld.fold_meta_item(meta)), token::NtPath(path) => token::NtPath(fld.fold_path(path)), token::NtTT(tt) => token::NtTT(fld.fold_tt(tt)), diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0e20eb49d39..0596fb44abe 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -14,7 +14,7 @@ use codemap::{CodeMap, FilePathMapping}; use errors::{FatalError, DiagnosticBuilder}; use parse::{token, ParseSess}; use str::char_at; -use symbol::Symbol; +use symbol::{Symbol, keywords}; use std_unicode::property::Pattern_White_Space; use std::borrow::Cow; @@ -1115,26 +1115,49 @@ impl<'a> StringReader<'a> { /// token, and updates the interner fn next_token_inner(&mut self) -> Result { let c = self.ch; - if ident_start(c) && - match (c.unwrap(), self.nextch(), self.nextnextch()) { - // Note: r as in r" or r#" is part of a raw string literal, - // b as in b' is part of a byte literal. - // They are not identifiers, and are handled further down. - ('r', Some('"'), _) | - ('r', Some('#'), _) | - ('b', Some('"'), _) | - ('b', Some('\''), _) | - ('b', Some('r'), Some('"')) | - ('b', Some('r'), Some('#')) => false, - _ => true, - } { - let start = self.pos; - while ident_continue(self.ch) { - self.bump(); - } - // FIXME: perform NFKC normalization here. (Issue #2253) - return Ok(self.with_str_from(start, |string| token::Ident(self.mk_ident(string)))); + if ident_start(c) { + let (is_ident_start, is_raw_ident) = + match (c.unwrap(), self.nextch(), self.nextnextch()) { + // r# followed by an identifier starter is a raw identifier. + // This is an exception to the r# case below. + ('r', Some('#'), x) if ident_start(x) => (true, true), + // r as in r" or r#" is part of a raw string literal. + // b as in b' is part of a byte literal. + // They are not identifiers, and are handled further down. + ('r', Some('"'), _) | + ('r', Some('#'), _) | + ('b', Some('"'), _) | + ('b', Some('\''), _) | + ('b', Some('r'), Some('"')) | + ('b', Some('r'), Some('#')) => (false, false), + _ => (true, false), + }; + if is_ident_start { + let raw_start = self.pos; + if is_raw_ident { + // Consume the 'r#' characters. + self.bump(); + self.bump(); + } + + let start = self.pos; + while ident_continue(self.ch) { + self.bump(); + } + + return Ok(self.with_str_from(start, |string| { + // FIXME: perform NFKC normalization here. (Issue #2253) + let ident = self.mk_ident(string); + if is_raw_ident && (token::is_path_segment_keyword(ident) || + ident.name == keywords::Underscore.name()) { + self.fatal_span_(raw_start, self.pos, + &format!("`r#{}` is not currently supported.", ident.name) + ).raise(); + } + token::Ident(ident, is_raw_ident) + })); + } } if is_dec_digit(c) { @@ -1801,7 +1824,7 @@ mod tests { assert_eq!(string_reader.next_token().tok, token::Whitespace); let tok1 = string_reader.next_token(); let tok2 = TokenAndSpan { - tok: token::Ident(id), + tok: token::Ident(id, false), sp: Span::new(BytePos(21), BytePos(23), NO_EXPANSION), }; assert_eq!(tok1, tok2); @@ -1811,7 +1834,7 @@ mod tests { // read another token: let tok3 = string_reader.next_token(); let tok4 = TokenAndSpan { - tok: token::Ident(Ident::from_str("main")), + tok: mk_ident("main"), sp: Span::new(BytePos(24), BytePos(28), NO_EXPANSION), }; assert_eq!(tok3, tok4); @@ -1830,7 +1853,7 @@ mod tests { // make the identifier by looking up the string in the interner fn mk_ident(id: &str) -> token::Token { - token::Ident(Ident::from_str(id)) + token::Token::from_ast_ident(Ident::from_str(id)) } #[test] diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index f7e5d40b524..4acfdab53c0 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -741,9 +741,9 @@ mod tests { match (tts.len(), tts.get(0), tts.get(1), tts.get(2), tts.get(3)) { ( 4, - Some(&TokenTree::Token(_, token::Ident(name_macro_rules))), + Some(&TokenTree::Token(_, token::Ident(name_macro_rules, false))), Some(&TokenTree::Token(_, token::Not)), - Some(&TokenTree::Token(_, token::Ident(name_zip))), + Some(&TokenTree::Token(_, token::Ident(name_zip, false))), Some(&TokenTree::Delimited(_, ref macro_delimed)), ) if name_macro_rules.name == "macro_rules" @@ -762,7 +762,7 @@ mod tests { ( 2, Some(&TokenTree::Token(_, token::Dollar)), - Some(&TokenTree::Token(_, token::Ident(ident))), + Some(&TokenTree::Token(_, token::Ident(ident, false))), ) if first_delimed.delim == token::Paren && ident.name == "a" => {}, _ => panic!("value 3: {:?}", *first_delimed), @@ -772,7 +772,7 @@ mod tests { ( 2, Some(&TokenTree::Token(_, token::Dollar)), - Some(&TokenTree::Token(_, token::Ident(ident))), + Some(&TokenTree::Token(_, token::Ident(ident, false))), ) if second_delimed.delim == token::Paren && ident.name == "a" => {}, @@ -793,17 +793,18 @@ mod tests { let tts = string_to_stream("fn a (b : i32) { b; }".to_string()); let expected = TokenStream::concat(vec![ - TokenTree::Token(sp(0, 2), token::Ident(Ident::from_str("fn"))).into(), - TokenTree::Token(sp(3, 4), token::Ident(Ident::from_str("a"))).into(), + TokenTree::Token(sp(0, 2), token::Ident(Ident::from_str("fn"), false)).into(), + TokenTree::Token(sp(3, 4), token::Ident(Ident::from_str("a"), false)).into(), TokenTree::Delimited( sp(5, 14), tokenstream::Delimited { delim: token::DelimToken::Paren, tts: TokenStream::concat(vec![ - TokenTree::Token(sp(6, 7), token::Ident(Ident::from_str("b"))).into(), + TokenTree::Token(sp(6, 7), + token::Ident(Ident::from_str("b"), false)).into(), TokenTree::Token(sp(8, 9), token::Colon).into(), TokenTree::Token(sp(10, 13), - token::Ident(Ident::from_str("i32"))).into(), + token::Ident(Ident::from_str("i32"), false)).into(), ]).into(), }).into(), TokenTree::Delimited( @@ -811,7 +812,8 @@ mod tests { tokenstream::Delimited { delim: token::DelimToken::Brace, tts: TokenStream::concat(vec![ - TokenTree::Token(sp(17, 18), token::Ident(Ident::from_str("b"))).into(), + TokenTree::Token(sp(17, 18), + token::Ident(Ident::from_str("b"), false)).into(), TokenTree::Token(sp(18, 19), token::Semi).into(), ]).into(), }).into() diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cb5010a638d..4c1575cf589 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -358,7 +358,7 @@ impl TokenCursor { let body = TokenTree::Delimited(sp, Delimited { delim: token::Bracket, - tts: [TokenTree::Token(sp, token::Ident(ast::Ident::from_str("doc"))), + tts: [TokenTree::Token(sp, token::Ident(ast::Ident::from_str("doc"), false)), TokenTree::Token(sp, token::Eq), TokenTree::Token(sp, token::Literal( token::StrRaw(Symbol::intern(&stripped), num_of_hashes), None))] @@ -784,7 +784,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i) => { + token::Ident(i, _) => { if self.token.is_reserved_ident() { let mut err = self.expected_ident_found(); if recover { @@ -1925,7 +1925,7 @@ impl<'a> Parser<'a> { pub fn parse_path_segment_ident(&mut self) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(sid) if self.token.is_path_segment_keyword() => { + token::Ident(sid, _) if self.token.is_path_segment_keyword() => { self.bump(); Ok(sid) } @@ -2740,11 +2740,14 @@ impl<'a> Parser<'a> { } pub fn process_potential_macro_variable(&mut self) { - let ident = match self.token { + let (ident, is_raw) = match self.token { token::Dollar if self.span.ctxt() != syntax_pos::hygiene::SyntaxContext::empty() && self.look_ahead(1, |t| t.is_ident()) => { self.bump(); - let name = match self.token { token::Ident(ident) => ident, _ => unreachable!() }; + let name = match self.token { + token::Ident(ident, _) => ident, + _ => unreachable!() + }; let mut err = self.fatal(&format!("unknown macro variable `{}`", name)); err.span_label(self.span, "unknown macro variable"); err.emit(); @@ -2753,13 +2756,13 @@ impl<'a> Parser<'a> { token::Interpolated(ref nt) => { self.meta_var_span = Some(self.span); match nt.0 { - token::NtIdent(ident) => ident, + token::NtIdent(ident, is_raw) => (ident, is_raw), _ => return, } } _ => return, }; - self.token = token::Ident(ident.node); + self.token = token::Ident(ident.node, is_raw); self.span = ident.span; } @@ -4245,7 +4248,7 @@ impl<'a> Parser<'a> { -> PResult<'a, Option>> { let token_lo = self.span; let (ident, def) = match self.token { - token::Ident(ident) if ident.name == keywords::Macro.name() => { + token::Ident(ident, false) if ident.name == keywords::Macro.name() => { self.bump(); let ident = self.parse_ident()?; let tokens = if self.check(&token::OpenDelim(token::Brace)) { @@ -4273,7 +4276,7 @@ impl<'a> Parser<'a> { (ident, ast::MacroDef { tokens: tokens.into(), legacy: false }) } - token::Ident(ident) if ident.name == "macro_rules" && + token::Ident(ident, _) if ident.name == "macro_rules" && self.look_ahead(1, |t| *t == token::Not) => { let prev_span = self.prev_span; self.complain_if_pub_macro(&vis.node, prev_span); @@ -5078,7 +5081,9 @@ impl<'a> Parser<'a> { fn parse_self_arg(&mut self) -> PResult<'a, Option> { let expect_ident = |this: &mut Self| match this.token { // Preserve hygienic context. - token::Ident(ident) => { let sp = this.span; this.bump(); codemap::respan(sp, ident) } + token::Ident(ident, _) => { + let sp = this.span; this.bump(); codemap::respan(sp, ident) + } _ => unreachable!() }; let isolated_self = |this: &mut Self, n| { @@ -5375,7 +5380,7 @@ impl<'a> Parser<'a> { VisibilityKind::Inherited => Ok(()), _ => { let is_macro_rules: bool = match self.token { - token::Ident(sid) => sid.name == Symbol::intern("macro_rules"), + token::Ident(sid, _) => sid.name == Symbol::intern("macro_rules"), _ => false, }; if is_macro_rules { @@ -7016,7 +7021,7 @@ impl<'a> Parser<'a> { fn parse_rename(&mut self) -> PResult<'a, Option> { if self.eat_keyword(keywords::As) { match self.token { - token::Ident(ident) if ident.name == keywords::Underscore.name() => { + token::Ident(ident, false) if ident.name == keywords::Underscore.name() => { self.bump(); // `_` Ok(Some(Ident { name: ident.name.gensymed(), ..ident })) } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 4ada9e20f2c..6406651bcba 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -91,8 +91,8 @@ impl Lit { } } -fn ident_can_begin_expr(ident: ast::Ident) -> bool { - let ident_token: Token = Ident(ident); +fn ident_can_begin_expr(ident: ast::Ident, is_raw: bool) -> bool { + let ident_token: Token = Ident(ident, is_raw); !ident_token.is_reserved_ident() || ident_token.is_path_segment_keyword() || @@ -116,8 +116,8 @@ fn ident_can_begin_expr(ident: ast::Ident) -> bool { ].contains(&ident.name) } -fn ident_can_begin_type(ident: ast::Ident) -> bool { - let ident_token: Token = Ident(ident); +fn ident_can_begin_type(ident: ast::Ident, is_raw: bool) -> bool { + let ident_token: Token = Ident(ident, is_raw); !ident_token.is_reserved_ident() || ident_token.is_path_segment_keyword() || @@ -132,6 +132,37 @@ fn ident_can_begin_type(ident: ast::Ident) -> bool { ].contains(&ident.name) } +pub fn is_path_segment_keyword(id: ast::Ident) -> bool { + id.name == keywords::Super.name() || + id.name == keywords::SelfValue.name() || + id.name == keywords::SelfType.name() || + id.name == keywords::Extern.name() || + id.name == keywords::Crate.name() || + id.name == keywords::CrateRoot.name() || + id.name == keywords::DollarCrate.name() +} + +// Returns true for reserved identifiers used internally for elided lifetimes, +// unnamed method parameters, crate root module, error recovery etc. +pub fn is_special_ident(id: ast::Ident) -> bool { + id.name <= keywords::Underscore.name() +} + +/// Returns `true` if the token is a keyword used in the language. +pub fn is_used_keyword(id: ast::Ident) -> bool { + id.name >= keywords::As.name() && id.name <= keywords::While.name() +} + +/// Returns `true` if the token is a keyword reserved for possible future use. +pub fn is_unused_keyword(id: ast::Ident) -> bool { + id.name >= keywords::Abstract.name() && id.name <= keywords::Yield.name() +} + +/// Returns `true` if the token is either a special identifier or a keyword. +pub fn is_reserved_ident(id: ast::Ident) -> bool { + is_special_ident(id) || is_used_keyword(id) || is_unused_keyword(id) +} + #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug)] pub enum Token { /* Expression-operator symbols. */ @@ -175,7 +206,7 @@ pub enum Token { Literal(Lit, Option), /* Name components */ - Ident(ast::Ident), + Ident(ast::Ident, /* is_raw */ bool), Lifetime(ast::Ident), // The `LazyTokenStream` is a pure function of the `Nonterminal`, @@ -203,6 +234,11 @@ impl Token { Token::Interpolated(Lrc::new((nt, LazyTokenStream::new()))) } + /// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary. + pub fn from_ast_ident(ident: ast::Ident) -> Token { + Ident(ident, is_reserved_ident(ident)) + } + /// Returns `true` if the token starts with '>'. pub fn is_like_gt(&self) -> bool { match *self { @@ -214,7 +250,8 @@ impl Token { /// Returns `true` if the token can appear at the start of an expression. pub fn can_begin_expr(&self) -> bool { match *self { - Ident(ident) => ident_can_begin_expr(ident), // value name or keyword + Ident(ident, is_raw) => + ident_can_begin_expr(ident, is_raw), // value name or keyword OpenDelim(..) | // tuple, array or block Literal(..) | // literal Not | // operator not @@ -239,7 +276,8 @@ impl Token { /// Returns `true` if the token can appear at the start of a type. pub fn can_begin_type(&self) -> bool { match *self { - Ident(ident) => ident_can_begin_type(ident), // type name or keyword + Ident(ident, is_raw) => + ident_can_begin_type(ident, is_raw), // type name or keyword OpenDelim(Paren) | // tuple OpenDelim(Bracket) | // array Not | // never @@ -272,17 +310,32 @@ impl Token { } } - pub fn ident(&self) -> Option { + fn ident_common(&self, allow_raw: bool) -> Option { match *self { - Ident(ident) => Some(ident), + Ident(ident, is_raw) if !is_raw || allow_raw => Some(ident), Interpolated(ref nt) => match nt.0 { - NtIdent(ident) => Some(ident.node), + NtIdent(ident, is_raw) if !is_raw || allow_raw => Some(ident.node), _ => None, }, _ => None, } } + pub fn nonraw_ident(&self) -> Option { + self.ident_common(false) + } + + pub fn is_raw_ident(&self) -> bool { + match *self { + Ident(_, true) => true, + _ => false, + } + } + + pub fn ident(&self) -> Option { + self.ident_common(true) + } + /// Returns `true` if the token is an identifier. pub fn is_ident(&self) -> bool { self.ident().is_some() @@ -351,18 +404,12 @@ impl Token { /// Returns `true` if the token is a given keyword, `kw`. pub fn is_keyword(&self, kw: keywords::Keyword) -> bool { - self.ident().map(|ident| ident.name == kw.name()).unwrap_or(false) + self.nonraw_ident().map(|ident| ident.name == kw.name()).unwrap_or(false) } pub fn is_path_segment_keyword(&self) -> bool { - match self.ident() { - Some(id) => id.name == keywords::Super.name() || - id.name == keywords::SelfValue.name() || - id.name == keywords::SelfType.name() || - id.name == keywords::Extern.name() || - id.name == keywords::Crate.name() || - id.name == keywords::CrateRoot.name() || - id.name == keywords::DollarCrate.name(), + match self.nonraw_ident() { + Some(id) => is_path_segment_keyword(id), None => false, } } @@ -370,24 +417,24 @@ impl Token { // Returns true for reserved identifiers used internally for elided lifetimes, // unnamed method parameters, crate root module, error recovery etc. pub fn is_special_ident(&self) -> bool { - match self.ident() { - Some(id) => id.name <= keywords::Underscore.name(), + match self.nonraw_ident() { + Some(id) => is_special_ident(id), _ => false, } } /// Returns `true` if the token is a keyword used in the language. pub fn is_used_keyword(&self) -> bool { - match self.ident() { - Some(id) => id.name >= keywords::As.name() && id.name <= keywords::While.name(), + match self.nonraw_ident() { + Some(id) => is_used_keyword(id), _ => false, } } /// Returns `true` if the token is a keyword reserved for possible future use. pub fn is_unused_keyword(&self) -> bool { - match self.ident() { - Some(id) => id.name >= keywords::Abstract.name() && id.name <= keywords::Yield.name(), + match self.nonraw_ident() { + Some(id) => is_unused_keyword(id), _ => false, } } @@ -460,7 +507,10 @@ impl Token { /// Returns `true` if the token is either a special identifier or a keyword. pub fn is_reserved_ident(&self) -> bool { - self.is_special_ident() || self.is_used_keyword() || self.is_unused_keyword() + match self.nonraw_ident() { + Some(id) => is_reserved_ident(id), + _ => false, + } } pub fn interpolated_to_tokenstream(&self, sess: &ParseSess, span: Span) @@ -496,8 +546,8 @@ impl Token { Nonterminal::NtImplItem(ref item) => { tokens = prepend_attrs(sess, &item.attrs, item.tokens.as_ref(), span); } - Nonterminal::NtIdent(ident) => { - let token = Token::Ident(ident.node); + Nonterminal::NtIdent(ident, is_raw) => { + let token = Token::Ident(ident.node, is_raw); tokens = Some(TokenTree::Token(ident.span, token).into()); } Nonterminal::NtLifetime(lifetime) => { @@ -529,7 +579,7 @@ pub enum Nonterminal { NtPat(P), NtExpr(P), NtTy(P), - NtIdent(ast::SpannedIdent), + NtIdent(ast::SpannedIdent, /* is_raw */ bool), /// Stuff inside brackets for attributes NtMeta(ast::MetaItem), NtPath(ast::Path), diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 7adb2848f8d..50577a26abf 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -250,7 +250,8 @@ pub fn token_to_string(tok: &Token) -> String { } /* Name components */ - token::Ident(s) => s.to_string(), + token::Ident(s, false) => s.to_string(), + token::Ident(s, true) => format!("r#{}", s), token::Lifetime(s) => s.to_string(), /* Other */ @@ -261,24 +262,25 @@ pub fn token_to_string(tok: &Token) -> String { token::Shebang(s) => format!("/* shebang: {}*/", s), token::Interpolated(ref nt) => match nt.0 { - token::NtExpr(ref e) => expr_to_string(e), - token::NtMeta(ref e) => meta_item_to_string(e), - token::NtTy(ref e) => ty_to_string(e), - token::NtPath(ref e) => path_to_string(e), - token::NtItem(ref e) => item_to_string(e), - token::NtBlock(ref e) => block_to_string(e), - token::NtStmt(ref e) => stmt_to_string(e), - token::NtPat(ref e) => pat_to_string(e), - token::NtIdent(ref e) => ident_to_string(e.node), - token::NtTT(ref tree) => tt_to_string(tree.clone()), - token::NtArm(ref e) => arm_to_string(e), - token::NtImplItem(ref e) => impl_item_to_string(e), - token::NtTraitItem(ref e) => trait_item_to_string(e), - token::NtGenerics(ref e) => generic_params_to_string(&e.params), - token::NtWhereClause(ref e) => where_clause_to_string(e), - token::NtArg(ref e) => arg_to_string(e), - token::NtVis(ref e) => vis_to_string(e), - token::NtLifetime(ref e) => lifetime_to_string(e), + token::NtExpr(ref e) => expr_to_string(e), + token::NtMeta(ref e) => meta_item_to_string(e), + token::NtTy(ref e) => ty_to_string(e), + token::NtPath(ref e) => path_to_string(e), + token::NtItem(ref e) => item_to_string(e), + token::NtBlock(ref e) => block_to_string(e), + token::NtStmt(ref e) => stmt_to_string(e), + token::NtPat(ref e) => pat_to_string(e), + token::NtIdent(ref e, false) => ident_to_string(e.node), + token::NtIdent(ref e, true) => format!("r#{}", ident_to_string(e.node)), + token::NtTT(ref tree) => tt_to_string(tree.clone()), + token::NtArm(ref e) => arm_to_string(e), + token::NtImplItem(ref e) => impl_item_to_string(e), + token::NtTraitItem(ref e) => trait_item_to_string(e), + token::NtGenerics(ref e) => generic_params_to_string(&e.params), + token::NtWhereClause(ref e) => where_clause_to_string(e), + token::NtArg(ref e) => arg_to_string(e), + token::NtVis(ref e) => vis_to_string(e), + token::NtLifetime(ref e) => lifetime_to_string(e), } } } diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 1219e909e12..3a7a1b9a669 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -684,7 +684,7 @@ mod tests { with_globals(|| { let test0: TokenStream = Vec::::new().into_iter().collect(); let test1: TokenStream = - TokenTree::Token(sp(0, 1), Token::Ident(Ident::from_str("a"))).into(); + TokenTree::Token(sp(0, 1), Token::Ident(Ident::from_str("a"), false)).into(); let test2 = string_to_ts("foo(bar::baz)"); assert_eq!(test0.is_empty(), true); diff --git a/src/libsyntax_ext/concat_idents.rs b/src/libsyntax_ext/concat_idents.rs index 8d0104e512b..d513008f0e2 100644 --- a/src/libsyntax_ext/concat_idents.rs +++ b/src/libsyntax_ext/concat_idents.rs @@ -44,7 +44,8 @@ pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt, } } else { match *e { - TokenTree::Token(_, token::Ident(ident)) => res_str.push_str(&ident.name.as_str()), + TokenTree::Token(_, token::Ident(ident, _)) => + res_str.push_str(&ident.name.as_str()), _ => { cx.span_err(sp, "concat_idents! requires ident args."); return DummyResult::expr(sp); diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 8fd95aa1ca8..d9c68e3167b 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -149,7 +149,7 @@ fn parse_args(ecx: &mut ExtCtxt, if named || (p.token.is_ident() && p.look_ahead(1, |t| *t == token::Eq)) { named = true; let ident = match p.token { - token::Ident(i) => { + token::Ident(i, _) => { p.bump(); i } diff --git a/src/test/parse-fail/raw-str-delim.rs b/src/test/parse-fail/raw-str-delim.rs index 3fc5f8aae18..8c0027287de 100644 --- a/src/test/parse-fail/raw-str-delim.rs +++ b/src/test/parse-fail/raw-str-delim.rs @@ -11,5 +11,5 @@ // compile-flags: -Z parse-only static s: &'static str = - r#x"#"x# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation + r#~"#"~# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation ; diff --git a/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs b/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs index 26419a51513..ed0434051b7 100644 --- a/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs +++ b/src/test/run-pass-fulldeps/auxiliary/roman_numerals.rs @@ -49,7 +49,7 @@ fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree]) } let text = match args[0] { - TokenTree::Token(_, token::Ident(s)) => s.to_string(), + TokenTree::Token(_, token::Ident(s, _)) => s.to_string(), _ => { cx.span_err(sp, "argument should be a single identifier"); return DummyResult::any(sp); diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs new file mode 100644 index 00000000000..2ef9fba2076 --- /dev/null +++ b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; + +#[r#repr(r#C, r#packed)] +struct Test { + a: bool, b: u64 +} + +#[r#derive(r#Debug)] +struct Test2(u32); + +pub fn main() { + assert_eq!(mem::size_of::(), 9); + assert_eq!("Test2(123)", format!("{:?}", Test2(123))); +} diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs new file mode 100644 index 00000000000..eefce3981be --- /dev/null +++ b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn r#fn(r#match: u32) -> u32 { + r#match +} + +pub fn main() { + let r#struct = 1; + assert_eq!(1, r#struct); + + let foo = 2; + assert_eq!(2, r#foo); + + let r#bar = 3; + assert_eq!(3, bar); + + assert_eq!(4, r#fn(4)); + + let r#true = false; + assert_eq!(r#true, false); +} diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs new file mode 100644 index 00000000000..4306ffe2042 --- /dev/null +++ b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs @@ -0,0 +1,41 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Debug, PartialEq, Eq)] +struct IntWrapper(u32); + +#[derive(Debug, Ord, PartialOrd, PartialEq, Eq, Hash, Copy, Clone, Default)] +struct HasKeywordField { + r#struct: u32, +} + +struct Generic(T); + +trait Trait { + fn r#trait(&self) -> u32; +} +impl Trait for Generic { + fn r#trait(&self) -> u32 { + self.0 + } +} + +pub fn main() { + assert_eq!(IntWrapper(1), r#IntWrapper(1)); + + match IntWrapper(2) { + r#IntWrapper(r#struct) => assert_eq!(2, r#struct), + } + + assert_eq!("HasKeywordField { struct: 3 }", format!("{:?}", HasKeywordField { r#struct: 3 })); + + assert_eq!(4, Generic(4).0); + assert_eq!(5, Generic(5).r#trait()); +} diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs new file mode 100644 index 00000000000..9e89b79266c --- /dev/null +++ b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs @@ -0,0 +1,47 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(decl_macro)] + +r#macro_rules! r#struct { + ($r#struct:expr) => { $r#struct } +} + +macro_rules! old_macro { + ($a:expr) => {$a} +} + +macro r#decl_macro($r#fn:expr) { + $r#fn +} + +macro passthrough($id:ident) { + $id +} + +macro_rules! test_pat_match { + (a) => { 6 }; + (r#a) => { 7 }; +} + +pub fn main() { + r#println!("{struct}", r#struct = 1); + assert_eq!(2, r#struct!(2)); + assert_eq!(3, r#old_macro!(3)); + assert_eq!(4, decl_macro!(4)); + + let r#match = 5; + assert_eq!(5, passthrough!(r#match)); + + assert_eq!("r#struct", stringify!(r#struct)); + + assert_eq!(6, test_pat_match!(a)); + assert_eq!(7, test_pat_match!(r#a)); +} diff --git a/src/test/ui/raw-literal-keywords.rs b/src/test/ui/raw-literal-keywords.rs new file mode 100644 index 00000000000..8b3747dbe15 --- /dev/null +++ b/src/test/ui/raw-literal-keywords.rs @@ -0,0 +1,25 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +#![feature(dyn_trait)] + +fn test_if() { + r#if true { } //~ ERROR found `true` +} + +fn test_struct() { + r#struct Test; //~ ERROR found `Test` +} + +fn test_union() { + r#union Test; //~ ERROR found `Test` +} diff --git a/src/test/ui/raw-literal-keywords.stderr b/src/test/ui/raw-literal-keywords.stderr new file mode 100644 index 00000000000..022f80ae8a4 --- /dev/null +++ b/src/test/ui/raw-literal-keywords.stderr @@ -0,0 +1,20 @@ +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true` + --> $DIR/raw-literal-keywords.rs:16:10 + | +LL | r#if true { } //~ ERROR found `true` + | ^^^^ expected one of 8 possible tokens here + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:20:14 + | +LL | r#struct Test; //~ ERROR found `Test` + | ^^^^ expected one of 8 possible tokens here + +error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` + --> $DIR/raw-literal-keywords.rs:24:13 + | +LL | r#union Test; //~ ERROR found `Test` + | ^^^^ expected one of 8 possible tokens here + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/raw-literal-self.rs b/src/test/ui/raw-literal-self.rs new file mode 100644 index 00000000000..17496d767b6 --- /dev/null +++ b/src/test/ui/raw-literal-self.rs @@ -0,0 +1,15 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn self_test(r#self: u32) { + //~^ ERROR `r#self` is not currently supported. +} diff --git a/src/test/ui/raw-literal-self.stderr b/src/test/ui/raw-literal-self.stderr new file mode 100644 index 00000000000..f4b75937247 --- /dev/null +++ b/src/test/ui/raw-literal-self.stderr @@ -0,0 +1,8 @@ +error: `r#self` is not currently supported. + --> $DIR/raw-literal-self.rs:13:14 + | +LL | fn self_test(r#self: u32) { + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/raw-literal-underscore.rs b/src/test/ui/raw-literal-underscore.rs new file mode 100644 index 00000000000..ec33e486195 --- /dev/null +++ b/src/test/ui/raw-literal-underscore.rs @@ -0,0 +1,15 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +fn underscore_test(r#_: u32) { + //~^ ERROR `r#_` is not currently supported. +} diff --git a/src/test/ui/raw-literal-underscore.stderr b/src/test/ui/raw-literal-underscore.stderr new file mode 100644 index 00000000000..8072eee4f06 --- /dev/null +++ b/src/test/ui/raw-literal-underscore.stderr @@ -0,0 +1,8 @@ +error: `r#_` is not currently supported. + --> $DIR/raw-literal-underscore.rs:13:20 + | +LL | fn underscore_test(r#_: u32) { + | ^^^ + +error: aborting due to previous error + -- cgit 1.4.1-3-g733a5 From 7d5c29b9eae5857c040bf6f1b2d729596c8af3ae Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Wed, 14 Mar 2018 02:00:41 -0500 Subject: Feature gate raw identifiers. --- src/libsyntax/feature_gate.rs | 14 ++++++++++++++ src/libsyntax/parse/lexer/mod.rs | 1 + src/libsyntax/parse/mod.rs | 4 ++++ src/libsyntax/parse/parser.rs | 5 ++++- src/test/run-pass/rfc-2151-raw-identifiers/attr.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/basic.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/items.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/macros.rs | 1 + src/test/ui/feature-gate-raw-identifiers.rs | 14 ++++++++++++++ src/test/ui/feature-gate-raw-identifiers.stderr | 11 +++++++++++ src/test/ui/raw-literal-keywords.rs | 1 + src/test/ui/raw-literal-keywords.stderr | 6 +++--- src/test/ui/raw-literal-self.rs | 2 ++ src/test/ui/raw-literal-self.stderr | 2 +- 14 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/feature-gate-raw-identifiers.rs create mode 100644 src/test/ui/feature-gate-raw-identifiers.stderr diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index fa600cd6860..153e42c8214 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -452,6 +452,9 @@ declare_features! ( // `use path as _;` and `extern crate c as _;` (active, underscore_imports, "1.26.0", Some(48216), None), + + // Raw identifiers allowing keyword names to be used + (active, raw_identifiers, "1.26.0", Some(48589), None), ); declare_features! ( @@ -1932,6 +1935,17 @@ pub fn check_crate(krate: &ast::Crate, parse_sess: sess, plugin_attributes, }; + + if !features.raw_identifiers { + for &span in sess.raw_identifier_spans.borrow().iter() { + if !span.allows_unstable() { + gate_feature!(&ctx, raw_identifiers, span, + "raw identifiers are experimental and subject to change" + ); + } + } + } + let visitor = &mut PostExpansionVisitor { context: &ctx }; visitor.whole_crate_feature_gates(krate); visit::walk_crate(visitor, krate); diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0596fb44abe..8e746ea69e7 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1796,6 +1796,7 @@ mod tests { included_mod_stack: RefCell::new(Vec::new()), code_map: cm, missing_fragment_specifiers: RefCell::new(HashSet::new()), + raw_identifier_spans: RefCell::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), non_modrs_mods: RefCell::new(vec![]), } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4acfdab53c0..03ac1e8b5a9 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -48,6 +48,9 @@ pub struct ParseSess { pub unstable_features: UnstableFeatures, pub config: CrateConfig, pub missing_fragment_specifiers: RefCell>, + /// Places where raw identifiers were used. This is used for feature gating + /// raw identifiers + pub raw_identifier_spans: RefCell>, /// The registered diagnostics codes pub registered_diagnostics: Lock, // Spans where a `mod foo;` statement was included in a non-mod.rs file. @@ -74,6 +77,7 @@ impl ParseSess { unstable_features: UnstableFeatures::from_environment(), config: HashSet::new(), missing_fragment_specifiers: RefCell::new(HashSet::new()), + raw_identifier_spans: RefCell::new(Vec::new()), registered_diagnostics: Lock::new(ErrorMap::new()), included_mod_stack: RefCell::new(vec![]), code_map, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4c1575cf589..c2ee78e9e9d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -784,7 +784,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i, _) => { + token::Ident(i, is_raw) => { if self.token.is_reserved_ident() { let mut err = self.expected_ident_found(); if recover { @@ -793,6 +793,9 @@ impl<'a> Parser<'a> { return Err(err); } } + if is_raw { + self.sess.raw_identifier_spans.borrow_mut().push(self.span); + } self.bump(); Ok(i) } diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs index 2ef9fba2076..6cea75cf1d1 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(raw_identifiers)] + use std::mem; #[r#repr(r#C, r#packed)] diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs index eefce3981be..5d495c4e9e5 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(raw_identifiers)] + fn r#fn(r#match: u32) -> u32 { r#match } diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs index 4306ffe2042..256bd263d38 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(raw_identifiers)] + #[derive(Debug, PartialEq, Eq)] struct IntWrapper(u32); diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs index 9e89b79266c..4bd16ded52f 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(decl_macro)] +#![feature(raw_identifiers)] r#macro_rules! r#struct { ($r#struct:expr) => { $r#struct } diff --git a/src/test/ui/feature-gate-raw-identifiers.rs b/src/test/ui/feature-gate-raw-identifiers.rs new file mode 100644 index 00000000000..38024feb432 --- /dev/null +++ b/src/test/ui/feature-gate-raw-identifiers.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let r#foo = 3; //~ ERROR raw identifiers are experimental and subject to change + println!("{}", foo); +} diff --git a/src/test/ui/feature-gate-raw-identifiers.stderr b/src/test/ui/feature-gate-raw-identifiers.stderr new file mode 100644 index 00000000000..02eff7247c4 --- /dev/null +++ b/src/test/ui/feature-gate-raw-identifiers.stderr @@ -0,0 +1,11 @@ +error[E0658]: raw identifiers are experimental and subject to change (see issue #48589) + --> $DIR/feature-gate-raw-identifiers.rs:12:9 + | +LL | let r#foo = 3; //~ ERROR raw identifiers are experimental and subject to change + | ^^^^^ + | + = help: add #![feature(raw_identifiers)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/raw-literal-keywords.rs b/src/test/ui/raw-literal-keywords.rs index 8b3747dbe15..9b28aa0b151 100644 --- a/src/test/ui/raw-literal-keywords.rs +++ b/src/test/ui/raw-literal-keywords.rs @@ -11,6 +11,7 @@ // compile-flags: -Z parse-only #![feature(dyn_trait)] +#![feature(raw_identifiers)] fn test_if() { r#if true { } //~ ERROR found `true` diff --git a/src/test/ui/raw-literal-keywords.stderr b/src/test/ui/raw-literal-keywords.stderr index 022f80ae8a4..3758568323c 100644 --- a/src/test/ui/raw-literal-keywords.stderr +++ b/src/test/ui/raw-literal-keywords.stderr @@ -1,17 +1,17 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `true` - --> $DIR/raw-literal-keywords.rs:16:10 + --> $DIR/raw-literal-keywords.rs:17:10 | LL | r#if true { } //~ ERROR found `true` | ^^^^ expected one of 8 possible tokens here error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:20:14 + --> $DIR/raw-literal-keywords.rs:21:14 | LL | r#struct Test; //~ ERROR found `Test` | ^^^^ expected one of 8 possible tokens here error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `Test` - --> $DIR/raw-literal-keywords.rs:24:13 + --> $DIR/raw-literal-keywords.rs:25:13 | LL | r#union Test; //~ ERROR found `Test` | ^^^^ expected one of 8 possible tokens here diff --git a/src/test/ui/raw-literal-self.rs b/src/test/ui/raw-literal-self.rs index 17496d767b6..f88d6cf9a67 100644 --- a/src/test/ui/raw-literal-self.rs +++ b/src/test/ui/raw-literal-self.rs @@ -10,6 +10,8 @@ // compile-flags: -Z parse-only +#![feature(raw_identifiers)] + fn self_test(r#self: u32) { //~^ ERROR `r#self` is not currently supported. } diff --git a/src/test/ui/raw-literal-self.stderr b/src/test/ui/raw-literal-self.stderr index f4b75937247..e3345847aa8 100644 --- a/src/test/ui/raw-literal-self.stderr +++ b/src/test/ui/raw-literal-self.stderr @@ -1,5 +1,5 @@ error: `r#self` is not currently supported. - --> $DIR/raw-literal-self.rs:13:14 + --> $DIR/raw-literal-self.rs:15:14 | LL | fn self_test(r#self: u32) { | ^^^^^^ -- cgit 1.4.1-3-g733a5 From a23f685296b2edd59acc998411340184b958ec82 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 18 Mar 2018 16:58:38 +0100 Subject: num::NonZero* types now have their own tracking issue: #49137 Fixes #27730 --- src/libcore/nonzero.rs | 7 +------ src/libcore/num/mod.rs | 4 ++-- src/libstd/num.rs | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index 59aaef9d66a..19836d98844 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -9,9 +9,7 @@ // except according to those terms. //! Exposes the NonZero lang item which provides optimization hints. -#![unstable(feature = "nonzero", - reason = "deprecated", - issue = "27730")] +#![unstable(feature = "nonzero", reason = "deprecated", issue = "49137")] #![rustc_deprecated(reason = "use `std::ptr::NonNull` or `std::num::NonZero*` instead", since = "1.26.0")] #![allow(deprecated)] @@ -70,9 +68,6 @@ pub struct NonZero(pub(crate) T); impl NonZero { /// Creates an instance of NonZero with the provided value. /// You must indeed ensure that the value is actually "non-zero". - #[unstable(feature = "nonzero", - reason = "needs an RFC to flesh out the design", - issue = "27730")] #[inline] pub const unsafe fn new_unchecked(inner: T) -> Self { NonZero(inner) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 84f6ab9b764..2ffcb9e95e2 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -92,7 +92,7 @@ macro_rules! nonzero_integers { } nonzero_integers! { - #[unstable(feature = "nonzero", issue = "27730")] + #[unstable(feature = "nonzero", issue = "49137")] NonZeroU8(u8); NonZeroI8(i8); NonZeroU16(u16); NonZeroI16(i16); NonZeroU32(u32); NonZeroI32(i32); @@ -103,7 +103,7 @@ nonzero_integers! { nonzero_integers! { // Change this to `#[unstable(feature = "i128", issue = "35118")]` // if other NonZero* integer types are stabilizied before 128-bit integers - #[unstable(feature = "nonzero", issue = "27730")] + #[unstable(feature = "nonzero", issue = "49137")] NonZeroU128(u128); NonZeroI128(i128); } diff --git a/src/libstd/num.rs b/src/libstd/num.rs index 5e0406ca220..0c618370ac2 100644 --- a/src/libstd/num.rs +++ b/src/libstd/num.rs @@ -21,7 +21,7 @@ pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError} #[stable(feature = "rust1", since = "1.0.0")] pub use core::num::Wrapping; -#[unstable(feature = "nonzero", issue = "27730")] +#[unstable(feature = "nonzero", issue = "49137")] pub use core::num::{ NonZeroU8, NonZeroI8, NonZeroU16, NonZeroI16, NonZeroU32, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroUsize, NonZeroIsize, @@ -29,7 +29,7 @@ pub use core::num::{ // Change this to `#[unstable(feature = "i128", issue = "35118")]` // if other NonZero* integer types are stabilizied before 128-bit integers -#[unstable(feature = "nonzero", issue = "27730")] +#[unstable(feature = "nonzero", issue = "49137")] pub use core::num::{NonZeroU128, NonZeroI128}; #[cfg(test)] use fmt; -- cgit 1.4.1-3-g733a5 From d2e7953d1325b1a1fe1cef526dbe8d23fa3e00a1 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Sun, 18 Mar 2018 11:21:38 -0500 Subject: Move raw_identifiers check to the lexer. --- src/libsyntax/parse/lexer/mod.rs | 4 ++++ src/libsyntax/parse/parser.rs | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 8e746ea69e7..068929c8948 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1155,6 +1155,10 @@ impl<'a> StringReader<'a> { &format!("`r#{}` is not currently supported.", ident.name) ).raise(); } + if is_raw_ident { + let span = self.mk_sp(raw_start, self.pos); + self.sess.raw_identifier_spans.borrow_mut().push(span); + } token::Ident(ident, is_raw_ident) })); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c2ee78e9e9d..4c1575cf589 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -784,7 +784,7 @@ impl<'a> Parser<'a> { fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i, is_raw) => { + token::Ident(i, _) => { if self.token.is_reserved_ident() { let mut err = self.expected_ident_found(); if recover { @@ -793,9 +793,6 @@ impl<'a> Parser<'a> { return Err(err); } } - if is_raw { - self.sess.raw_identifier_spans.borrow_mut().push(self.span); - } self.bump(); Ok(i) } -- cgit 1.4.1-3-g733a5 From 5c3d6320deb20f78d83d12fb3a319b9dd6b15290 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Sun, 18 Mar 2018 12:16:02 -0500 Subject: Return a is_raw parameter from Token::ident rather than having separate methods. --- src/libsyntax/ext/tt/macro_parser.rs | 4 ++-- src/libsyntax/ext/tt/quoted.rs | 4 ++-- src/libsyntax/parse/token.rs | 45 ++++++++++++------------------------ 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 714b7ca981d..8cb331c65da 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -364,8 +364,8 @@ pub fn parse_failure_msg(tok: Token) -> String { /// Perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) fn token_name_eq(t1: &Token, t2: &Token) -> bool { - if let (Some(id1), Some(id2)) = (t1.ident(), t2.ident()) { - id1.name == id2.name && t1.is_raw_ident() == t2.is_raw_ident() + if let (Some((id1, is_raw1)), Some((id2, is_raw2))) = (t1.ident(), t2.ident()) { + id1.name == id2.name && is_raw1 == is_raw2 } else if let (&token::Lifetime(id1), &token::Lifetime(id2)) = (t1, t2) { id1.name == id2.name } else { diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 11eb9b940ae..f324edeb117 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -200,7 +200,7 @@ pub fn parse( let span = match trees.next() { Some(tokenstream::TokenTree::Token(span, token::Colon)) => match trees.next() { Some(tokenstream::TokenTree::Token(end_sp, ref tok)) => match tok.ident() { - Some(kind) => { + Some((kind, _)) => { let span = end_sp.with_lo(start_sp.lo()); result.push(TokenTree::MetaVarDecl(span, ident, kind)); continue; @@ -289,7 +289,7 @@ where // `tree` is followed by an `ident`. This could be `$meta_var` or the `$crate` special // metavariable that names the crate of the invokation. Some(tokenstream::TokenTree::Token(ident_span, ref token)) if token.is_ident() => { - let ident = token.ident().unwrap(); + let (ident, _) = token.ident().unwrap(); let span = ident_span.with_lo(span.lo()); if ident.name == keywords::Crate.name() { let ident = ast::Ident { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 6406651bcba..4e7a282adc5 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -310,32 +310,17 @@ impl Token { } } - fn ident_common(&self, allow_raw: bool) -> Option { + pub fn ident(&self) -> Option<(ast::Ident, bool)> { match *self { - Ident(ident, is_raw) if !is_raw || allow_raw => Some(ident), + Ident(ident, is_raw) => Some((ident, is_raw)), Interpolated(ref nt) => match nt.0 { - NtIdent(ident, is_raw) if !is_raw || allow_raw => Some(ident.node), + NtIdent(ident, is_raw) => Some((ident.node, is_raw)), _ => None, }, _ => None, } } - pub fn nonraw_ident(&self) -> Option { - self.ident_common(false) - } - - pub fn is_raw_ident(&self) -> bool { - match *self { - Ident(_, true) => true, - _ => false, - } - } - - pub fn ident(&self) -> Option { - self.ident_common(true) - } - /// Returns `true` if the token is an identifier. pub fn is_ident(&self) -> bool { self.ident().is_some() @@ -404,37 +389,37 @@ impl Token { /// Returns `true` if the token is a given keyword, `kw`. pub fn is_keyword(&self, kw: keywords::Keyword) -> bool { - self.nonraw_ident().map(|ident| ident.name == kw.name()).unwrap_or(false) + self.ident().map(|(ident, is_raw)| ident.name == kw.name() && !is_raw).unwrap_or(false) } pub fn is_path_segment_keyword(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_path_segment_keyword(id), - None => false, + match self.ident() { + Some((id, false)) => is_path_segment_keyword(id), + _ => false, } } // Returns true for reserved identifiers used internally for elided lifetimes, // unnamed method parameters, crate root module, error recovery etc. pub fn is_special_ident(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_special_ident(id), + match self.ident() { + Some((id, false)) => is_special_ident(id), _ => false, } } /// Returns `true` if the token is a keyword used in the language. pub fn is_used_keyword(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_used_keyword(id), + match self.ident() { + Some((id, false)) => is_used_keyword(id), _ => false, } } /// Returns `true` if the token is a keyword reserved for possible future use. pub fn is_unused_keyword(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_unused_keyword(id), + match self.ident() { + Some((id, false)) => is_unused_keyword(id), _ => false, } } @@ -507,8 +492,8 @@ impl Token { /// Returns `true` if the token is either a special identifier or a keyword. pub fn is_reserved_ident(&self) -> bool { - match self.nonraw_ident() { - Some(id) => is_reserved_ident(id), + match self.ident() { + Some((id, false)) => is_reserved_ident(id), _ => false, } } -- cgit 1.4.1-3-g733a5 From ce84a41936e367dfeb7d348564f2337819395ca6 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Sun, 18 Mar 2018 13:27:56 -0500 Subject: Allow raw identifiers in diagnostic macros. --- src/libsyntax/diagnostics/plugin.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs index c7e453c9e10..aecf32ab6af 100644 --- a/src/libsyntax/diagnostics/plugin.rs +++ b/src/libsyntax/diagnostics/plugin.rs @@ -44,7 +44,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt, token_tree: &[TokenTree]) -> Box { let code = match (token_tree.len(), token_tree.get(0)) { - (1, Some(&TokenTree::Token(_, token::Ident(code, false)))) => code, + (1, Some(&TokenTree::Token(_, token::Ident(code, _)))) => code, _ => unreachable!() }; @@ -82,10 +82,10 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt, token_tree.get(1), token_tree.get(2) ) { - (1, Some(&TokenTree::Token(_, token::Ident(ref code, false))), None, None) => { + (1, Some(&TokenTree::Token(_, token::Ident(ref code, _))), None, None) => { (code, None) }, - (3, Some(&TokenTree::Token(_, token::Ident(ref code, false))), + (3, Some(&TokenTree::Token(_, token::Ident(ref code, _))), Some(&TokenTree::Token(_, token::Comma)), Some(&TokenTree::Token(_, token::Literal(token::StrRaw(description, _), None)))) => { (code, Some(description)) @@ -150,9 +150,9 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt, let (crate_name, name) = match (&token_tree[0], &token_tree[2]) { ( // Crate name. - &TokenTree::Token(_, token::Ident(ref crate_name, false)), + &TokenTree::Token(_, token::Ident(ref crate_name, _)), // DIAGNOSTICS ident. - &TokenTree::Token(_, token::Ident(ref name, false)) + &TokenTree::Token(_, token::Ident(ref name, _)) ) => (*&crate_name, name), _ => unreachable!() }; -- cgit 1.4.1-3-g733a5 From 685c3c1b4a7c1949048177409ca43fc05daefd3f Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Sun, 18 Mar 2018 23:01:11 -0700 Subject: Reduce the diagnostic span when multiple fields are missing in pattern --- src/librustc_typeck/check/_match.rs | 70 +++++++++++++++---------- src/test/ui/missing-fields-in-struct-pattern.rs | 17 ++++++ 2 files changed, 59 insertions(+), 28 deletions(-) create mode 100644 src/test/ui/missing-fields-in-struct-pattern.rs diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 379fd93ba2b..0b5383f1f8d 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -904,6 +904,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); // Keep track of which fields have already appeared in the pattern. let mut used_fields = FxHashMap(); + let mut inexistent_fields = vec![]; // Typecheck each field. for &Spanned { node: ref field, span } in fields { let field_ty = match used_fields.entry(field.name) { @@ -927,34 +928,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); self.field_ty(span, f, substs) }) .unwrap_or_else(|| { - let mut err = struct_span_err!( - tcx.sess, - span, - E0026, - "{} `{}` does not have a field named `{}`", - kind_name, - tcx.item_path_str(variant.did), - field.name - ); - err.span_label(span, - format!("{} `{}` does not have field `{}`", - kind_name, - tcx.item_path_str(variant.did), - field.name)); - if tcx.sess.teach(&err.get_code().unwrap()) { - err.note( - "This error indicates that a struct pattern attempted to \ - extract a non-existent field from a struct. Struct fields \ - are identified by the name used before the colon : so struct \ - patterns should resemble the declaration of the struct type \ - being matched.\n\n\ - If you are using shorthand field patterns but want to refer \ - to the struct field by a different name, you should rename \ - it explicitly." - ); - } - err.emit(); - + inexistent_fields.push((span, field.name)); tcx.types.err }) } @@ -963,6 +937,46 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); self.check_pat_walk(&field.pat, field_ty, def_bm, true); } + if inexistent_fields.len() > 0 { + let field_names = if inexistent_fields.len() == 1 { + format!("a field named `{}`", inexistent_fields[0].1) + } else { + format!("fields named {}", + inexistent_fields.iter() + .map(|(_, name)| format!("`{}`", name)) + .collect::>() + .join(", ")) + }; + let spans = inexistent_fields.iter().map(|(span, _)| *span).collect::>(); + let mut err = struct_span_err!(tcx.sess, + spans, + E0026, + "{} `{}` does not have {}", + kind_name, + tcx.item_path_str(variant.did), + field_names); + for (span, name) in &inexistent_fields { + err.span_label(*span, + format!("{} `{}` does not have field `{}`", + kind_name, + tcx.item_path_str(variant.did), + name)); + } + if tcx.sess.teach(&err.get_code().unwrap()) { + err.note( + "This error indicates that a struct pattern attempted to \ + extract a non-existent field from a struct. Struct fields \ + are identified by the name used before the colon : so struct \ + patterns should resemble the declaration of the struct type \ + being matched.\n\n\ + If you are using shorthand field patterns but want to refer \ + to the struct field by a different name, you should rename \ + it explicitly." + ); + } + err.emit(); + } + // Require `..` if struct has non_exhaustive attribute. if adt.is_struct() && adt.is_non_exhaustive() && !adt.did.is_local() && !etc { span_err!(tcx.sess, span, E0638, diff --git a/src/test/ui/missing-fields-in-struct-pattern.rs b/src/test/ui/missing-fields-in-struct-pattern.rs new file mode 100644 index 00000000000..2469f245345 --- /dev/null +++ b/src/test/ui/missing-fields-in-struct-pattern.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct S(usize, usize, usize, usize); + +fn main() { + if let S { a, b, c, d } = S(1, 2, 3, 4) { + println!("hi"); + } +} -- cgit 1.4.1-3-g733a5 From 8236e431ce67f0cd32e0584a826586648842eaa3 Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Mon, 19 Mar 2018 22:09:47 +0900 Subject: Document only-X test header --- src/test/COMPILER_TESTS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/COMPILER_TESTS.md b/src/test/COMPILER_TESTS.md index c255294e790..8553665c017 100644 --- a/src/test/COMPILER_TESTS.md +++ b/src/test/COMPILER_TESTS.md @@ -54,6 +54,8 @@ be compiled or run. * `ignore-test` always ignores the test * `ignore-lldb` and `ignore-gdb` will skip a debuginfo test on that debugger. +`only-X` is the opposite. The test will run only when `X` matches. + Some examples of `X` in `ignore-X`: * Architecture: `aarch64`, `arm`, `asmjs`, `mips`, `wasm32`, `x86_64`, `x86`, ... -- cgit 1.4.1-3-g733a5 From 37ff4736c790f87ab957235c65e93ff8351daa80 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 19 Mar 2018 18:01:14 +0100 Subject: wording nits --- src/librustc_lint/builtin.rs | 8 ++++---- src/test/ui/type-alias-bounds.stderr | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 2ea13b2cb6d..f6acc085861 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1356,9 +1356,9 @@ impl TypeAliasBounds { fn suggest_changing_assoc_types(ty: &hir::Ty, err: &mut DiagnosticBuilder) { // Access to associates types should use `::Assoc`, which does not need a - // bound. Let's see of this type does that. + // bound. Let's see if this type does that. - // We use an AST visitor to walk the type. + // We use a HIR visitor to walk the type. use rustc::hir::intravisit::{self, Visitor}; use syntax::ast::NodeId; struct WalkAssocTypes<'a, 'db> where 'db: 'a { @@ -1373,8 +1373,8 @@ impl TypeAliasBounds { fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: NodeId, span: Span) { if TypeAliasBounds::is_type_variable_assoc(qpath) { self.err.span_help(span, - "use absolute paths (i.e., ::Assoc) to refer to associated \ - types in type aliases"); + "use fully disambiguated paths (i.e., `::Assoc`) to refer to \ + associated types in type aliases"); } intravisit::walk_qpath(self, qpath, id, span) } diff --git a/src/test/ui/type-alias-bounds.stderr b/src/test/ui/type-alias-bounds.stderr index 5288dca79be..2a2b0b0f26e 100644 --- a/src/test/ui/type-alias-bounds.stderr +++ b/src/test/ui/type-alias-bounds.stderr @@ -46,7 +46,7 @@ LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases | ^^^^^ | = help: the bound will not be checked when the type alias is used, and should be removed -help: use absolute paths (i.e., ::Assoc) to refer to associated types in type aliases +help: use fully disambiguated paths (i.e., `::Assoc`) to refer to associated types in type aliases --> $DIR/type-alias-bounds.rs:57:21 | LL | type T1 = U::Assoc; //~ WARN not enforced in type aliases @@ -59,7 +59,7 @@ LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliase | ^^^^^^^^ | = help: the clause will not be checked when the type alias is used, and should be removed -help: use absolute paths (i.e., ::Assoc) to refer to associated types in type aliases +help: use fully disambiguated paths (i.e., `::Assoc`) to refer to associated types in type aliases --> $DIR/type-alias-bounds.rs:58:29 | LL | type T2 where U: Bound = U::Assoc; //~ WARN not enforced in type aliases -- cgit 1.4.1-3-g733a5 From c05d23406ead7b5747256c02127097807db45b83 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 19 Mar 2018 18:08:12 +0100 Subject: update compile-fail tests: fewer warnings because this is now a HIR lint --- src/test/compile-fail/issue-17994.rs | 1 - src/test/compile-fail/private-in-public-warn.rs | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/test/compile-fail/issue-17994.rs b/src/test/compile-fail/issue-17994.rs index 7c3811e2ef2..25141b9b825 100644 --- a/src/test/compile-fail/issue-17994.rs +++ b/src/test/compile-fail/issue-17994.rs @@ -10,5 +10,4 @@ trait Tr {} type Huh where T: Tr = isize; //~ ERROR type parameter `T` is unused - //~| WARNING where clauses are not enforced in type aliases fn main() {} diff --git a/src/test/compile-fail/private-in-public-warn.rs b/src/test/compile-fail/private-in-public-warn.rs index 8bd9b0a901d..6eeb14638e7 100644 --- a/src/test/compile-fail/private-in-public-warn.rs +++ b/src/test/compile-fail/private-in-public-warn.rs @@ -58,7 +58,6 @@ mod traits { pub trait PubTr {} pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARNING bounds on generic parameters are not enforced in type aliases //~| WARNING hard error pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error @@ -85,7 +84,6 @@ mod traits_where { pub type Alias where T: PrivTr = T; //~^ ERROR private trait `traits_where::PrivTr` in public interface //~| WARNING hard error - //~| WARNING where clauses are not enforced in type aliases pub trait Tr2 where T: PrivTr {} //~^ ERROR private trait `traits_where::PrivTr` in public interface //~| WARNING hard error -- cgit 1.4.1-3-g733a5 From f332a9ce5676859f0f07c4d6bf2d2c415be67066 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Sun, 18 Mar 2018 23:26:57 -0700 Subject: Single diagnostic for all non-mentioned fields in a pattern --- src/librustc_typeck/check/_match.rs | 22 +++++++++++++++++----- src/test/ui/missing-fields-in-struct-pattern.rs | 2 ++ .../ui/missing-fields-in-struct-pattern.stderr | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/test/ui/missing-fields-in-struct-pattern.stderr diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 0b5383f1f8d..cc72a565ba2 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -993,13 +993,25 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); tcx.sess.span_err(span, "`..` cannot be used in union patterns"); } } else if !etc { - for field in variant.fields + let unmentioned_fields = variant.fields .iter() - .filter(|field| !used_fields.contains_key(&field.name)) { + .map(|field| field.name) + .filter(|field| !used_fields.contains_key(&field)) + .collect::>(); + if unmentioned_fields.len() > 0 { + let field_names = if unmentioned_fields.len() == 1 { + format!("field `{}`", unmentioned_fields[0]) + } else { + format!("fields {}", + unmentioned_fields.iter() + .map(|name| format!("`{}`", name)) + .collect::>() + .join(", ")) + }; let mut diag = struct_span_err!(tcx.sess, span, E0027, - "pattern does not mention field `{}`", - field.name); - diag.span_label(span, format!("missing field `{}`", field.name)); + "pattern does not mention {}", + field_names); + diag.span_label(span, format!("missing {}", field_names)); if variant.ctor_kind == CtorKind::Fn { diag.note("trying to match a tuple variant with a struct variant pattern"); } diff --git a/src/test/ui/missing-fields-in-struct-pattern.rs b/src/test/ui/missing-fields-in-struct-pattern.rs index 2469f245345..28ed151b986 100644 --- a/src/test/ui/missing-fields-in-struct-pattern.rs +++ b/src/test/ui/missing-fields-in-struct-pattern.rs @@ -12,6 +12,8 @@ struct S(usize, usize, usize, usize); fn main() { if let S { a, b, c, d } = S(1, 2, 3, 4) { + //~^ ERROR struct `S` does not have fields named `a`, `b`, `c`, `d` [E0026] + //~^ ERROR pattern does not mention fields `0`, `1`, `2`, `3` [E0027] println!("hi"); } } diff --git a/src/test/ui/missing-fields-in-struct-pattern.stderr b/src/test/ui/missing-fields-in-struct-pattern.stderr new file mode 100644 index 00000000000..88fba19d14e --- /dev/null +++ b/src/test/ui/missing-fields-in-struct-pattern.stderr @@ -0,0 +1,22 @@ +error[E0026]: struct `S` does not have fields named `a`, `b`, `c`, `d` + --> $DIR/missing-fields-in-struct-pattern.rs:14:16 + | +LL | if let S { a, b, c, d } = S(1, 2, 3, 4) { + | ^ ^ ^ ^ struct `S` does not have field `d` + | | | | + | | | struct `S` does not have field `c` + | | struct `S` does not have field `b` + | struct `S` does not have field `a` + +error[E0027]: pattern does not mention fields `0`, `1`, `2`, `3` + --> $DIR/missing-fields-in-struct-pattern.rs:14:12 + | +LL | if let S { a, b, c, d } = S(1, 2, 3, 4) { + | ^^^^^^^^^^^^^^^^ missing fields `0`, `1`, `2`, `3` + | + = note: trying to match a tuple variant with a struct variant pattern + +error: aborting due to 2 previous errors + +Some errors occurred: E0026, E0027. +For more information about an error, try `rustc --explain E0026`. -- cgit 1.4.1-3-g733a5 From 6212904dd800864ca20ede8690fc827a1169fa26 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 19 Mar 2018 15:40:09 -0700 Subject: Don't use posix_spawn() if PATH was modified in the environment. The expected behavior is that the environment's PATH should be used to find the process. posix_spawn() could be used if we iterated PATH to search for the binary to execute. For now just skip posix_spawn() if PATH is modified. --- src/libstd/sys/unix/process/process_common.rs | 3 +++ src/libstd/sys/unix/process/process_unix.rs | 1 + src/libstd/sys_common/process.rs | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index d0486f06a14..48255489dd9 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -184,6 +184,9 @@ impl Command { let maybe_env = self.env.capture_if_changed(); maybe_env.map(|env| construct_envp(env, &mut self.saw_nul)) } + pub fn env_saw_path(&self) -> bool { + self.env.have_changed_path() + } pub fn setup_io(&self, default: Stdio, needs_stdin: bool) -> io::Result<(StdioPipes, ChildPipes)> { diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index 29e33ee822e..9d6d607e3f3 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -256,6 +256,7 @@ impl Command { if self.get_cwd().is_some() || self.get_gid().is_some() || self.get_uid().is_some() || + self.env_saw_path() || self.get_closures().len() != 0 { return Ok(None) } diff --git a/src/libstd/sys_common/process.rs b/src/libstd/sys_common/process.rs index fd1a5fdb410..775491d762c 100644 --- a/src/libstd/sys_common/process.rs +++ b/src/libstd/sys_common/process.rs @@ -47,6 +47,7 @@ impl EnvKey for DefaultEnvKey {} #[derive(Clone, Debug)] pub struct CommandEnv { clear: bool, + saw_path: bool, vars: BTreeMap> } @@ -54,6 +55,7 @@ impl Default for CommandEnv { fn default() -> Self { CommandEnv { clear: false, + saw_path: false, vars: Default::default() } } @@ -108,9 +110,11 @@ impl CommandEnv { // The following functions build up changes pub fn set(&mut self, key: &OsStr, value: &OsStr) { + self.maybe_saw_path(&key); self.vars.insert(key.to_owned().into(), Some(value.to_owned())); } pub fn remove(&mut self, key: &OsStr) { + self.maybe_saw_path(&key); if self.clear { self.vars.remove(key); } else { @@ -121,4 +125,12 @@ impl CommandEnv { self.clear = true; self.vars.clear(); } + pub fn have_changed_path(&self) -> bool { + self.saw_path || self.clear + } + fn maybe_saw_path(&mut self, key: &OsStr) { + if !self.saw_path && key.to_os_string() == OsString::from("PATH") { + self.saw_path = true; + } + } } -- cgit 1.4.1-3-g733a5 From 8e0faf79c0859f22d4e11268f272247a6ef73709 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Mon, 19 Mar 2018 16:15:26 -0700 Subject: Simplify PATH key comparison --- src/libstd/sys_common/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys_common/process.rs b/src/libstd/sys_common/process.rs index 775491d762c..d0c5951bd6c 100644 --- a/src/libstd/sys_common/process.rs +++ b/src/libstd/sys_common/process.rs @@ -129,7 +129,7 @@ impl CommandEnv { self.saw_path || self.clear } fn maybe_saw_path(&mut self, key: &OsStr) { - if !self.saw_path && key.to_os_string() == OsString::from("PATH") { + if !self.saw_path && key == "PATH" { self.saw_path = true; } } -- cgit 1.4.1-3-g733a5 From 062a46fdd1d49b1ccdc4f713433521463224d7d9 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Mon, 19 Mar 2018 14:13:57 -0700 Subject: Reduce diagnostic verbosity by removing labels --- src/librustc_typeck/check/_match.rs | 17 +++++++++-------- src/test/compile-fail/struct-pat-derived-error.rs | 6 ++---- src/test/ui/error-codes/E0026-teach.stderr | 2 +- src/test/ui/error-codes/E0026.stderr | 2 +- src/test/ui/missing-fields-in-struct-pattern.rs | 2 +- src/test/ui/missing-fields-in-struct-pattern.stderr | 6 +----- src/test/ui/numeric-fields.stderr | 2 +- src/test/ui/type-check/issue-41314.stderr | 2 +- src/test/ui/union/union-fields-2.stderr | 2 +- 9 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index cc72a565ba2..7965806af5d 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -938,14 +938,14 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); } if inexistent_fields.len() > 0 { - let field_names = if inexistent_fields.len() == 1 { - format!("a field named `{}`", inexistent_fields[0].1) + let (field_names, t, plural) = if inexistent_fields.len() == 1 { + (format!("a field named `{}`", inexistent_fields[0].1), "this", "") } else { - format!("fields named {}", - inexistent_fields.iter() + (format!("fields named {}", + inexistent_fields.iter() .map(|(_, name)| format!("`{}`", name)) .collect::>() - .join(", ")) + .join(", ")), "these", "s") }; let spans = inexistent_fields.iter().map(|(span, _)| *span).collect::>(); let mut err = struct_span_err!(tcx.sess, @@ -955,12 +955,13 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); kind_name, tcx.item_path_str(variant.did), field_names); - for (span, name) in &inexistent_fields { + if let Some((span, _)) = inexistent_fields.last() { err.span_label(*span, - format!("{} `{}` does not have field `{}`", + format!("{} `{}` does not have {} field{}", kind_name, tcx.item_path_str(variant.did), - name)); + t, + plural)); } if tcx.sess.teach(&err.get_code().unwrap()) { err.note( diff --git a/src/test/compile-fail/struct-pat-derived-error.rs b/src/test/compile-fail/struct-pat-derived-error.rs index f525ec37375..d3130c4e831 100644 --- a/src/test/compile-fail/struct-pat-derived-error.rs +++ b/src/test/compile-fail/struct-pat-derived-error.rs @@ -16,10 +16,8 @@ struct a { impl a { fn foo(&self) { let a { x, y } = self.d; //~ ERROR no field `d` on type `&a` - //~^ ERROR struct `a` does not have a field named `x` - //~^^ ERROR struct `a` does not have a field named `y` - //~^^^ ERROR pattern does not mention field `b` - //~^^^^ ERROR pattern does not mention field `c` + //~^ ERROR struct `a` does not have fields named `x`, `y` + //~| ERROR pattern does not mention fields `b`, `c` } } diff --git a/src/test/ui/error-codes/E0026-teach.stderr b/src/test/ui/error-codes/E0026-teach.stderr index 63d072fe03d..67ea32fba86 100644 --- a/src/test/ui/error-codes/E0026-teach.stderr +++ b/src/test/ui/error-codes/E0026-teach.stderr @@ -2,7 +2,7 @@ error[E0026]: struct `Thing` does not have a field named `z` --> $DIR/E0026-teach.rs:21:23 | LL | Thing { x, y, z } => {} - | ^ struct `Thing` does not have field `z` + | ^ struct `Thing` does not have this field | = note: This error indicates that a struct pattern attempted to extract a non-existent field from a struct. Struct fields are identified by the name used before the colon : so struct patterns should resemble the declaration of the struct type being matched. diff --git a/src/test/ui/error-codes/E0026.stderr b/src/test/ui/error-codes/E0026.stderr index af851951127..9dabbc8a775 100644 --- a/src/test/ui/error-codes/E0026.stderr +++ b/src/test/ui/error-codes/E0026.stderr @@ -2,7 +2,7 @@ error[E0026]: struct `Thing` does not have a field named `z` --> $DIR/E0026.rs:19:23 | LL | Thing { x, y, z } => {} - | ^ struct `Thing` does not have field `z` + | ^ struct `Thing` does not have this field error: aborting due to previous error diff --git a/src/test/ui/missing-fields-in-struct-pattern.rs b/src/test/ui/missing-fields-in-struct-pattern.rs index 28ed151b986..dfde3799499 100644 --- a/src/test/ui/missing-fields-in-struct-pattern.rs +++ b/src/test/ui/missing-fields-in-struct-pattern.rs @@ -13,7 +13,7 @@ struct S(usize, usize, usize, usize); fn main() { if let S { a, b, c, d } = S(1, 2, 3, 4) { //~^ ERROR struct `S` does not have fields named `a`, `b`, `c`, `d` [E0026] - //~^ ERROR pattern does not mention fields `0`, `1`, `2`, `3` [E0027] + //~| ERROR pattern does not mention fields `0`, `1`, `2`, `3` [E0027] println!("hi"); } } diff --git a/src/test/ui/missing-fields-in-struct-pattern.stderr b/src/test/ui/missing-fields-in-struct-pattern.stderr index 88fba19d14e..d1c3260f11e 100644 --- a/src/test/ui/missing-fields-in-struct-pattern.stderr +++ b/src/test/ui/missing-fields-in-struct-pattern.stderr @@ -2,11 +2,7 @@ error[E0026]: struct `S` does not have fields named `a`, `b`, `c`, `d` --> $DIR/missing-fields-in-struct-pattern.rs:14:16 | LL | if let S { a, b, c, d } = S(1, 2, 3, 4) { - | ^ ^ ^ ^ struct `S` does not have field `d` - | | | | - | | | struct `S` does not have field `c` - | | struct `S` does not have field `b` - | struct `S` does not have field `a` + | ^ ^ ^ ^ struct `S` does not have these fields error[E0027]: pattern does not mention fields `0`, `1`, `2`, `3` --> $DIR/missing-fields-in-struct-pattern.rs:14:12 diff --git a/src/test/ui/numeric-fields.stderr b/src/test/ui/numeric-fields.stderr index 607980ba3bf..68a87da8ded 100644 --- a/src/test/ui/numeric-fields.stderr +++ b/src/test/ui/numeric-fields.stderr @@ -10,7 +10,7 @@ error[E0026]: struct `S` does not have a field named `0x1` --> $DIR/numeric-fields.rs:17:17 | LL | S{0: a, 0x1: b, ..} => {} - | ^^^^^^ struct `S` does not have field `0x1` + | ^^^^^^ struct `S` does not have this field error: aborting due to 2 previous errors diff --git a/src/test/ui/type-check/issue-41314.stderr b/src/test/ui/type-check/issue-41314.stderr index bcb0f9a99a7..f7d4bb9a02f 100644 --- a/src/test/ui/type-check/issue-41314.stderr +++ b/src/test/ui/type-check/issue-41314.stderr @@ -2,7 +2,7 @@ error[E0026]: variant `X::Y` does not have a field named `number` --> $DIR/issue-41314.rs:17:16 | LL | X::Y { number } => {} //~ ERROR does not have a field named `number` - | ^^^^^^ variant `X::Y` does not have field `number` + | ^^^^^^ variant `X::Y` does not have this field error[E0027]: pattern does not mention field `0` --> $DIR/issue-41314.rs:17:9 diff --git a/src/test/ui/union/union-fields-2.stderr b/src/test/ui/union/union-fields-2.stderr index 3ea4d3426da..cfb5bc7520b 100644 --- a/src/test/ui/union/union-fields-2.stderr +++ b/src/test/ui/union/union-fields-2.stderr @@ -52,7 +52,7 @@ error[E0026]: union `U` does not have a field named `c` --> $DIR/union-fields-2.rs:28:19 | LL | let U { a, b, c } = u; //~ ERROR union patterns should have exactly one field - | ^ union `U` does not have field `c` + | ^ union `U` does not have this field error: union patterns should have exactly one field --> $DIR/union-fields-2.rs:28:9 -- cgit 1.4.1-3-g733a5 From df76629da77b58cd9a63d41b7bc1cc987dcc2bb8 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 20 Mar 2018 17:14:33 +0100 Subject: Remove outdated comment --- src/librustc/ty/sty.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index bb5c7b5fd2a..3fe310c54bf 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1667,7 +1667,6 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { pub struct Const<'tcx> { pub ty: Ty<'tcx>, - // FIXME(eddyb) Replace this with a miri value. pub val: ConstVal<'tcx>, } -- cgit 1.4.1-3-g733a5 From 5e93394d321823ec2f54e130150791ab95b6f755 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 20 Mar 2018 11:18:42 -0500 Subject: talk about --display-warnings --- src/doc/rustdoc/src/unstable-features.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 93489f89626..6a786c19851 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -329,3 +329,19 @@ When rendering docs, `rustdoc` creates several CSS and JavaScript files as part all these files are linked from every page, changing where they are can be cumbersome if you need to specially cache them. This flag will rename all these files in the output to include the suffix in the filename. For example, `main.css` would become `main-suf.css` with the above command. + +### `--display-warnings`: display warnings when documenting or running documentation tests + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --display-warnings +$ rustdoc --test src/lib.rs -Z unstable-options --display-warnings +``` + +The intent behind this flag is to allow the user to see warnings that occur within their library or +their documentation tests, which are usually suppressed. However, [due to a +bug][issue-display-warnings], this flag doesn't 100% work as intended. See the linked issue for +details. + +[issue-display-warnings]: https://github.com/rust-lang/rust/issues/41574 -- cgit 1.4.1-3-g733a5 From 83e9f395d17afc95d259febe8d675084f1baf497 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 20 Mar 2018 11:23:48 -0500 Subject: talk about force-unstable-if-unmarked --- src/doc/rustdoc/src/unstable-features.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 6a786c19851..ac69cc1007d 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -345,3 +345,16 @@ bug][issue-display-warnings], this flag doesn't 100% work as intended. See the l details. [issue-display-warnings]: https://github.com/rust-lang/rust/issues/41574 + +### `-Z force-unstable-if-unmarked` + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z force-unstable-if-unmarked +``` + +This is an internal flag intended for the standard library and compiler that applies an +`#[unstable]` attribute to any dependent crate that doesn't have another stability attribute. This +allows `rustdoc` to be able to generate documentation for the compiler crates and the standard +library, as an equivalent command-line argument is provided to `rustc` when building those crates. -- cgit 1.4.1-3-g733a5 From 3c8d55549728ec117fb6e3de93ce3d96fb6622d4 Mon Sep 17 00:00:00 2001 From: Kurtis Nusbaum Date: Wed, 14 Mar 2018 20:30:06 -0700 Subject: rename epoch to edition --- src/librustc/lint/context.rs | 12 ++-- src/librustc/lint/mod.rs | 20 +++---- src/librustc/session/config.rs | 24 ++++---- src/librustc/session/mod.rs | 10 ++-- src/librustc_driver/driver.rs | 2 +- src/librustc_lint/lib.rs | 34 +++++------ src/librustc_typeck/check/method/probe.rs | 2 +- src/libsyntax/config.rs | 6 +- src/libsyntax/edition.rs | 69 ++++++++++++++++++++++ src/libsyntax/epoch.rs | 69 ---------------------- src/libsyntax/feature_gate.rs | 20 +++---- src/libsyntax/lib.rs | 2 +- .../edition-raw-pointer-method-2015.rs | 23 ++++++++ .../edition-raw-pointer-method-2018.rs | 22 +++++++ .../compile-fail/epoch-raw-pointer-method-2015.rs | 23 -------- .../compile-fail/epoch-raw-pointer-method-2018.rs | 22 ------- src/test/run-pass/dyn-trait.rs | 2 +- src/test/run-pass/epoch-gate-feature.rs | 2 +- .../inference-variable-behind-raw-pointer.stderr | 2 +- 19 files changed, 183 insertions(+), 183 deletions(-) create mode 100644 src/libsyntax/edition.rs delete mode 100644 src/libsyntax/epoch.rs create mode 100644 src/test/compile-fail/edition-raw-pointer-method-2015.rs create mode 100644 src/test/compile-fail/edition-raw-pointer-method-2018.rs delete mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2015.rs delete mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2018.rs diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 4fa6594df16..936aa71f16c 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -41,7 +41,7 @@ use util::nodemap::FxHashMap; use std::default::Default as StdDefault; use std::cell::{Ref, RefCell}; use syntax::ast; -use syntax::epoch; +use syntax::edition; use syntax_pos::{MultiSpan, Span}; use errors::DiagnosticBuilder; use hir; @@ -103,9 +103,9 @@ pub struct FutureIncompatibleInfo { pub id: LintId, /// e.g., a URL for an issue/PR/RFC or error code pub reference: &'static str, - /// If this is an epoch fixing lint, the epoch in which + /// If this is an edition fixing lint, the edition in which /// this lint becomes obsolete - pub epoch: Option, + pub edition: Option, } /// The target of the `by_name` map, which accounts for renaming/deprecation. @@ -201,11 +201,11 @@ impl LintStore { sess: Option<&Session>, lints: Vec) { - for epoch in epoch::ALL_EPOCHS { - let lints = lints.iter().filter(|f| f.epoch == Some(*epoch)).map(|f| f.id) + for edition in edition::ALL_EPOCHS { + let lints = lints.iter().filter(|f| f.edition == Some(*edition)).map(|f| f.id) .collect::>(); if !lints.is_empty() { - self.register_group(sess, false, epoch.lint_name(), lints) + self.register_group(sess, false, edition.lint_name(), lints) } } diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 7c103dc2721..cd038d067a1 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -42,7 +42,7 @@ use session::{Session, DiagnosticMessageId}; use std::hash; use syntax::ast; use syntax::codemap::MultiSpan; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use syntax::symbol::Symbol; use syntax::visit as ast_visit; use syntax_pos::Span; @@ -77,8 +77,8 @@ pub struct Lint { /// e.g. "imports that are never used" pub desc: &'static str, - /// Deny lint after this epoch - pub epoch_deny: Option, + /// Deny lint after this edition + pub edition_deny: Option, } impl Lint { @@ -88,8 +88,8 @@ impl Lint { } pub fn default_level(&self, session: &Session) -> Level { - if let Some(epoch_deny) = self.epoch_deny { - if session.epoch() >= epoch_deny { + if let Some(edition_deny) = self.edition_deny { + if session.edition() >= edition_deny { return Level::Deny } } @@ -100,12 +100,12 @@ impl Lint { /// Declare a static item of type `&'static Lint`. #[macro_export] macro_rules! declare_lint { - ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $epoch: expr) => ( + ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $edition: expr) => ( $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { name: stringify!($NAME), default_level: $crate::lint::$Level, desc: $desc, - epoch_deny: Some($epoch) + edition_deny: Some($edition) }; ); ($vis: vis $NAME: ident, $Level: ident, $desc: expr) => ( @@ -113,7 +113,7 @@ macro_rules! declare_lint { name: stringify!($NAME), default_level: $crate::lint::$Level, desc: $desc, - epoch_deny: None, + edition_deny: None, }; ); } @@ -499,8 +499,8 @@ pub fn struct_lint_level<'a>(sess: &'a Session, // Check for future incompatibility lints and issue a stronger warning. let lints = sess.lint_store.borrow(); if let Some(future_incompatible) = lints.future_incompatible(LintId::of(lint)) { - let future = if let Some(epoch) = future_incompatible.epoch { - format!("the {} epoch", epoch) + let future = if let Some(edition) = future_incompatible.edition { + format!("the {} edition", edition) } else { "a future release".to_owned() }; diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 0d91074e946..4ba634f8b25 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -28,7 +28,7 @@ use middle::cstore; use syntax::ast::{self, IntTy, UintTy}; use syntax::codemap::{FileName, FilePathMapping}; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use syntax::parse::token; use syntax::parse; use syntax::symbol::Symbol; @@ -771,7 +771,7 @@ macro_rules! options { Some("`string` or `string=string`"); pub const parse_lto: Option<&'static str> = Some("one of `thin`, `fat`, or omitted"); - pub const parse_epoch: Option<&'static str> = + pub const parse_edition: Option<&'static str> = Some("one of: `2015`, `2018`"); } @@ -780,7 +780,7 @@ macro_rules! options { use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto}; use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel}; use std::path::PathBuf; - use syntax::epoch::Epoch; + use syntax::edition::Edition; $( pub fn $opt(cg: &mut $struct_name, v: Option<&str>) -> bool { @@ -983,11 +983,11 @@ macro_rules! options { true } - fn parse_epoch(slot: &mut Epoch, v: Option<&str>) -> bool { + fn parse_edition(slot: &mut Edition, v: Option<&str>) -> bool { match v { Some(s) => { - let epoch = s.parse(); - if let Ok(parsed) = epoch { + let edition = s.parse(); + if let Ok(parsed) = edition { *slot = parsed; true } else { @@ -1280,10 +1280,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, `everybody_loops` (all function bodies replaced with `loop {}`), `hir` (the HIR), `hir,identified`, or `hir,typed` (HIR with types for each node)."), - epoch: Epoch = (Epoch::Epoch2015, parse_epoch, [TRACKED], - "The epoch to build Rust with. Newer epochs may include features - that require breaking changes. The default epoch is 2015 (the first - epoch). Crates compiled with different epochs can be linked together."), + edition: Edition = (Edition::Edition2015, parse_edition, [TRACKED], + "The edition to build Rust with. Newer editions may include features + that require breaking changes. The default edition is 2015 (the first + edition). Crates compiled with different editions can be linked together."), run_dsymutil: Option = (None, parse_opt_bool, [TRACKED], "run `dsymutil` and delete intermediate object files"), ui_testing: bool = (false, parse_bool, [UNTRACKED], @@ -2258,7 +2258,7 @@ mod dep_tracking { use std::hash::Hash; use std::path::PathBuf; use std::collections::hash_map::DefaultHasher; - use super::{CrateType, DebugInfoLevel, Epoch, ErrorOutputType, Lto, OptLevel, OutputTypes, + use super::{CrateType, DebugInfoLevel, Edition, ErrorOutputType, Lto, OptLevel, OutputTypes, Passes, Sanitizer}; use syntax::feature_gate::UnstableFeatures; use rustc_back::{PanicStrategy, RelroLevel}; @@ -2320,7 +2320,7 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind); impl_dep_tracking_hash_via_hash!(Sanitizer); impl_dep_tracking_hash_via_hash!(Option); - impl_dep_tracking_hash_via_hash!(Epoch); + impl_dep_tracking_hash_via_hash!(Edition); impl_dep_tracking_hash_for_sortable_vec_of!(String); impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf); diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 3f52ecfc099..556255e06ed 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -31,7 +31,7 @@ use rustc_data_structures::sync::{Lrc, Lock}; use syntax::ast::NodeId; use errors::{self, DiagnosticBuilder, DiagnosticId}; use errors::emitter::{Emitter, EmitterWriter}; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use syntax::json::JsonEmitter; use syntax::feature_gate; use syntax::symbol::Symbol; @@ -976,13 +976,13 @@ impl Session { self.opts.debugging_opts.teach && !self.parse_sess.span_diagnostic.code_emitted(code) } - /// Are we allowed to use features from the Rust 2018 epoch? + /// Are we allowed to use features from the Rust 2018 edition? pub fn rust_2018(&self) -> bool { - self.opts.debugging_opts.epoch >= Epoch::Epoch2018 + self.opts.debugging_opts.edition >= Edition::Edition2018 } - pub fn epoch(&self) -> Epoch { - self.opts.debugging_opts.epoch + pub fn edition(&self) -> Edition { + self.opts.debugging_opts.edition } } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f2fe6542db1..a3115544f30 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -648,7 +648,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session, { let (mut krate, features) = syntax::config::features(krate, &sess.parse_sess, sess.opts.test, - sess.opts.debugging_opts.epoch); + sess.opts.debugging_opts.edition); // these need to be set "early" so that expansion sees `quote` if enabled. sess.init_features(features); diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index ce896bfb701..59d2d3e8fdc 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -48,7 +48,7 @@ use rustc::session; use rustc::util; use session::Session; -use syntax::epoch::Epoch; +use syntax::edition::Edition; use lint::LintId; use lint::FutureIncompatibleInfo; @@ -197,82 +197,82 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { FutureIncompatibleInfo { id: LintId::of(PRIVATE_IN_PUBLIC), reference: "issue #34537 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(PUB_USE_OF_PRIVATE_EXTERN_CRATE), reference: "issue #34537 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(PATTERNS_IN_FNS_WITHOUT_BODY), reference: "issue #35203 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(SAFE_EXTERN_STATICS), reference: "issue #36247 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(INVALID_TYPE_PARAM_DEFAULT), reference: "issue #36887 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP), reference: "issue #37872 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LEGACY_IMPORTS), reference: "issue #38260 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LEGACY_CONSTRUCTOR_VISIBILITY), reference: "issue #39207 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(MISSING_FRAGMENT_SPECIFIER), reference: "issue #40107 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(ILLEGAL_FLOATING_POINT_LITERAL_PATTERN), reference: "issue #41620 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(ANONYMOUS_PARAMETERS), reference: "issue #41686 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES), reference: "issue #42238 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(LATE_BOUND_LIFETIME_ARGUMENTS), reference: "issue #42868 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(SAFE_PACKED_BORROWS), reference: "issue #46043 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(INCOHERENT_FUNDAMENTAL_IMPLS), reference: "issue #46205 ", - epoch: None, + edition: None, }, FutureIncompatibleInfo { id: LintId::of(TYVAR_BEHIND_RAW_POINTER), reference: "issue #46906 ", - epoch: Some(Epoch::Epoch2018), + edition: Some(Edition::Edition2018), } ]); diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 4d344eb2799..c7921d2bd45 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -326,7 +326,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if reached_raw_pointer && !self.tcx.features().arbitrary_self_types { // this case used to be allowed by the compiler, - // so we do a future-compat lint here for the 2015 epoch + // so we do a future-compat lint here for the 2015 edition // (see https://github.com/rust-lang/rust/issues/46906) if self.tcx.sess.rust_2018() { span_err!(self.tcx.sess, span, E0908, diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 6013c20daf2..56b1306e5b3 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -13,7 +13,7 @@ use feature_gate::{feature_err, EXPLAIN_STMT_ATTR_SYNTAX, Features, get_features use {fold, attr}; use ast; use codemap::Spanned; -use epoch::Epoch; +use edition::Edition; use parse::{token, ParseSess}; use ptr::P; @@ -27,7 +27,7 @@ pub struct StripUnconfigured<'a> { } // `cfg_attr`-process the crate's attributes and compute the crate's features. -pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, epoch: Epoch) +pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, edition: Edition) -> (ast::Crate, Features) { let features; { @@ -47,7 +47,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, should_test: bool, epoc return (krate, Features::new()); } - features = get_features(&sess.span_diagnostic, &krate.attrs, epoch); + features = get_features(&sess.span_diagnostic, &krate.attrs, edition); // Avoid reconfiguring malformed `cfg_attr`s if err_count == sess.span_diagnostic.err_count() { diff --git a/src/libsyntax/edition.rs b/src/libsyntax/edition.rs new file mode 100644 index 00000000000..12ac6410ce1 --- /dev/null +++ b/src/libsyntax/edition.rs @@ -0,0 +1,69 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt; +use std::str::FromStr; + +/// The edition of the compiler (RFC 2052) +#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)] +#[non_exhaustive] +pub enum Edition { + // editions must be kept in order, newest to oldest + + /// The 2015 edition + Edition2015, + /// The 2018 edition + Edition2018, + + // when adding new editions, be sure to update: + // + // - the list in the `parse_edition` static in librustc::session::config + // - add a `rust_####()` function to the session + // - update the enum in Cargo's sources as well + // + // When -Zedition becomes --edition, there will + // also be a check for the edition being nightly-only + // somewhere. That will need to be updated + // whenever we're stabilizing/introducing a new edition + // as well as changing the default Cargo template. +} + +// must be in order from oldest to newest +pub const ALL_EPOCHS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018]; + +impl fmt::Display for Edition { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let s = match *self { + Edition::Edition2015 => "2015", + Edition::Edition2018 => "2018", + }; + write!(f, "{}", s) + } +} + +impl Edition { + pub fn lint_name(&self) -> &'static str { + match *self { + Edition::Edition2015 => "edition_2015", + Edition::Edition2018 => "edition_2018", + } + } +} + +impl FromStr for Edition { + type Err = (); + fn from_str(s: &str) -> Result { + match s { + "2015" => Ok(Edition::Edition2015), + "2018" => Ok(Edition::Edition2018), + _ => Err(()) + } + } +} diff --git a/src/libsyntax/epoch.rs b/src/libsyntax/epoch.rs deleted file mode 100644 index 32cbc79c550..00000000000 --- a/src/libsyntax/epoch.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt; -use std::str::FromStr; - -/// The epoch of the compiler (RFC 2052) -#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq, Debug)] -#[non_exhaustive] -pub enum Epoch { - // epochs must be kept in order, newest to oldest - - /// The 2015 epoch - Epoch2015, - /// The 2018 epoch - Epoch2018, - - // when adding new epochs, be sure to update: - // - // - the list in the `parse_epoch` static in librustc::session::config - // - add a `rust_####()` function to the session - // - update the enum in Cargo's sources as well - // - // When -Zepoch becomes --epoch, there will - // also be a check for the epoch being nightly-only - // somewhere. That will need to be updated - // whenever we're stabilizing/introducing a new epoch - // as well as changing the default Cargo template. -} - -// must be in order from oldest to newest -pub const ALL_EPOCHS: &[Epoch] = &[Epoch::Epoch2015, Epoch::Epoch2018]; - -impl fmt::Display for Epoch { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let s = match *self { - Epoch::Epoch2015 => "2015", - Epoch::Epoch2018 => "2018", - }; - write!(f, "{}", s) - } -} - -impl Epoch { - pub fn lint_name(&self) -> &'static str { - match *self { - Epoch::Epoch2015 => "epoch_2015", - Epoch::Epoch2018 => "epoch_2018", - } - } -} - -impl FromStr for Epoch { - type Err = (); - fn from_str(s: &str) -> Result { - match s { - "2015" => Ok(Epoch::Epoch2015), - "2018" => Ok(Epoch::Epoch2018), - _ => Err(()) - } - } -} diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 915396d29fe..8feb8d6a402 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -28,7 +28,7 @@ use self::AttributeGate::*; use abi::Abi; use ast::{self, NodeId, PatKind, RangeEnd}; use attr; -use epoch::Epoch; +use edition::Edition; use codemap::Spanned; use syntax_pos::{Span, DUMMY_SP}; use errors::{DiagnosticBuilder, Handler, FatalError}; @@ -55,13 +55,13 @@ macro_rules! set { } macro_rules! declare_features { - ($((active, $feature: ident, $ver: expr, $issue: expr, $epoch: expr),)+) => { + ($((active, $feature: ident, $ver: expr, $issue: expr, $edition: expr),)+) => { /// Represents active features that are currently being implemented or /// currently being considered for addition/removal. const ACTIVE_FEATURES: &'static [(&'static str, &'static str, Option, - Option, fn(&mut Features, Span))] = - &[$((stringify!($feature), $ver, $issue, $epoch, set!($feature))),+]; + Option, fn(&mut Features, Span))] = + &[$((stringify!($feature), $ver, $issue, $edition, set!($feature))),+]; /// A set of features to be used by later passes. #[derive(Clone)] @@ -402,7 +402,7 @@ declare_features! ( (active, match_default_bindings, "1.22.0", Some(42640), None), // Trait object syntax with `dyn` prefix - (active, dyn_trait, "1.22.0", Some(44662), Some(Epoch::Epoch2018)), + (active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)), // `crate` as visibility modifier, synonymous to `pub(crate)` (active, crate_visibility_modifier, "1.23.0", Some(45388), None), @@ -1800,16 +1800,16 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], - epoch: Epoch) -> Features { + edition: Edition) -> Features { let mut features = Features::new(); let mut feature_checker = FeatureChecker::default(); - for &(.., f_epoch, set) in ACTIVE_FEATURES.iter() { - if let Some(f_epoch) = f_epoch { - if epoch >= f_epoch { + for &(.., f_edition, set) in ACTIVE_FEATURES.iter() { + if let Some(f_edition) = f_edition { + if edition >= f_edition { // FIXME(Manishearth) there is currently no way to set - // lang features by epoch + // lang features by edition set(&mut features, DUMMY_SP); } } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 5f58b3bc3a0..74f1ee373ec 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -145,7 +145,7 @@ pub mod codemap; #[macro_use] pub mod config; pub mod entry; -pub mod epoch; +pub mod edition; pub mod feature_gate; pub mod fold; pub mod parse; diff --git a/src/test/compile-fail/edition-raw-pointer-method-2015.rs b/src/test/compile-fail/edition-raw-pointer-method-2015.rs new file mode 100644 index 00000000000..fdc9b4f704c --- /dev/null +++ b/src/test/compile-fail/edition-raw-pointer-method-2015.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// compile-flags: -Zedition=2015 -Zunstable-options + +// tests that editions work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: type annotations needed [tyvar_behind_raw_pointer] + //~^^ warning: this was previously accepted +} diff --git a/src/test/compile-fail/edition-raw-pointer-method-2018.rs b/src/test/compile-fail/edition-raw-pointer-method-2018.rs new file mode 100644 index 00000000000..58b34591029 --- /dev/null +++ b/src/test/compile-fail/edition-raw-pointer-method-2018.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// compile-flags: -Zedition=2018 -Zunstable-options + +// tests that editions work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0908] +} diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2015.rs b/src/test/compile-fail/epoch-raw-pointer-method-2015.rs deleted file mode 100644 index 6aa83a38b7e..00000000000 --- a/src/test/compile-fail/epoch-raw-pointer-method-2015.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// compile-flags: -Zepoch=2015 -Zunstable-options - -// tests that epochs work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: type annotations needed [tyvar_behind_raw_pointer] - //~^^ warning: this was previously accepted -} diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2018.rs b/src/test/compile-fail/epoch-raw-pointer-method-2018.rs deleted file mode 100644 index c4815de2306..00000000000 --- a/src/test/compile-fail/epoch-raw-pointer-method-2018.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// compile-flags: -Zepoch=2018 -Zunstable-options - -// tests that epochs work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0908] -} diff --git a/src/test/run-pass/dyn-trait.rs b/src/test/run-pass/dyn-trait.rs index fdec6a26ac9..399823ec92d 100644 --- a/src/test/run-pass/dyn-trait.rs +++ b/src/test/run-pass/dyn-trait.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-pretty `dyn ::foo` parses differently in the current epoch +// ignore-pretty `dyn ::foo` parses differently in the current edition #![feature(dyn_trait)] diff --git a/src/test/run-pass/epoch-gate-feature.rs b/src/test/run-pass/epoch-gate-feature.rs index 37d092c06e0..f3d8f216e11 100644 --- a/src/test/run-pass/epoch-gate-feature.rs +++ b/src/test/run-pass/epoch-gate-feature.rs @@ -11,7 +11,7 @@ // Checks if the correct registers are being used to pass arguments // when the sysv64 ABI is specified. -// compile-flags: -Zepoch=2018 +// compile-flags: -Zedition=2018 pub trait Foo {} diff --git a/src/test/ui/inference-variable-behind-raw-pointer.stderr b/src/test/ui/inference-variable-behind-raw-pointer.stderr index eb40151615d..fe6dc0b0748 100644 --- a/src/test/ui/inference-variable-behind-raw-pointer.stderr +++ b/src/test/ui/inference-variable-behind-raw-pointer.stderr @@ -5,6 +5,6 @@ LL | if data.is_null() {} | ^^^^^^^ | = note: #[warn(tyvar_behind_raw_pointer)] on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 epoch! + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! = note: for more information, see issue #46906 -- cgit 1.4.1-3-g733a5 From 11f14060a4da7776c5f56e7dc53cc9545e4ab25f Mon Sep 17 00:00:00 2001 From: Kurtis Nusbaum Date: Wed, 14 Mar 2018 20:56:13 -0700 Subject: change all appropriate EPOCH to EDITION --- src/librustc/lint/context.rs | 2 +- src/libsyntax/edition.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 936aa71f16c..3c833251f72 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -201,7 +201,7 @@ impl LintStore { sess: Option<&Session>, lints: Vec) { - for edition in edition::ALL_EPOCHS { + for edition in edition::ALL_EDITIONS { let lints = lints.iter().filter(|f| f.edition == Some(*edition)).map(|f| f.id) .collect::>(); if !lints.is_empty() { diff --git a/src/libsyntax/edition.rs b/src/libsyntax/edition.rs index 12ac6410ce1..61246d4493c 100644 --- a/src/libsyntax/edition.rs +++ b/src/libsyntax/edition.rs @@ -36,7 +36,7 @@ pub enum Edition { } // must be in order from oldest to newest -pub const ALL_EPOCHS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018]; +pub const ALL_EDITIONS: &[Edition] = &[Edition::Edition2015, Edition::Edition2018]; impl fmt::Display for Edition { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { -- cgit 1.4.1-3-g733a5 From b996f9d60fdb1db6bd870fc7f600be4c7660f3a2 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Wed, 21 Mar 2018 09:52:18 -0500 Subject: review comments --- src/doc/rustdoc/src/unstable-features.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index ac69cc1007d..16356c20c70 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -33,7 +33,7 @@ extern { fn some_func(x: T); } This is used by the error index to ensure that the samples that correspond to a given error number properly emit that error code. However, these error codes aren't guaranteed to be the only thing -that a piece of code emits from version to version, so this in unlikely to be stabilized in the +that a piece of code emits from version to version, so this is unlikely to be stabilized in the future. Attempting to use these error numbers on stable will result in the code sample being interpreted as @@ -134,9 +134,9 @@ pub struct UnixToken; In this sample, the tokens will only appear on their respective platforms, but they will both appear in documentation. -`#[doc(cfg(...))]` was introduced to be used by the standard library and is currently controlled by -a feature gate. For more information, see [its chapter in the Unstable Book][unstable-doc-cfg] and -[its tracking issue][issue-doc-cfg]. +`#[doc(cfg(...))]` was introduced to be used by the standard library and currently requires the +`#![feature(doc_cfg)]` feature gate. For more information, see [its chapter in the Unstable +Book][unstable-doc-cfg] and [its tracking issue][issue-doc-cfg]. [unstable-doc-cfg]: ../unstable-book/language-features/doc-cfg.html [issue-doc-cfg]: https://github.com/rust-lang/rust/issues/43781 @@ -155,8 +155,9 @@ In the standard library, the traits that qualify for inclusion are `Iterator`, ` special marker attribute on them: `#[doc(spotlight)]`. This means that you could apply this attribute to your own trait to include it in the "Important Traits" dialog in documentation. -The `#[doc(spotlight)]` attribute is controlled by a feature gate. For more information, see [its -chapter in the Unstable Book][unstable-spotlight] and [its tracking issue][issue-spotlight]. +The `#[doc(spotlight)]` attribute currently requires the `#![feature(doc_spotlight)]` feature gate. +For more information, see [its chapter in the Unstable Book][unstable-spotlight] and [its tracking +issue][issue-spotlight]. [unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html [issue-spotlight]: https://github.com/rust-lang/rust/issues/45040 @@ -174,9 +175,9 @@ To prevent internal types from being included in documentation, the standard lib attribute to their `extern crate` declarations: `#[doc(masked)]`. This causes Rustdoc to "mask out" types from these crates when building lists of trait implementations. -The `#[doc(masked)]` attribute is intended to be used internally, and is controlled by a feature -gate. For more information, see [its chapter in the Unstable Book][unstable-masked] and [its -tracking issue][issue-masked]. +The `#[doc(masked)]` attribute is intended to be used internally, and requires the +`#![feature(doc_masked)]` feature gate. For more information, see [its chapter in the Unstable +Book][unstable-masked] and [its tracking issue][issue-masked]. [unstable-masked]: ../unstable-book/language-features/doc-masked.html [issue-masked]: https://github.com/rust-lang/rust/issues/44027 @@ -191,8 +192,9 @@ as if it were written inline. [RFC 1990]: https://github.com/rust-lang/rfcs/pull/1990 -`#[doc(include = "...")]` is currently controlled by a feature gate. For more information, see [its -chapter in the Unstable Book][unstable-include] and [its tracking issue][issue-include]. +`#[doc(include = "...")]` currently requires the `#![feature(external_doc)]` feature gate. For more +information, see [its chapter in the Unstable Book][unstable-include] and [its tracking +issue][issue-include]. [unstable-include]: ../unstable-book/language-features/external-doc.html [issue-include]: https://github.com/rust-lang/rust/issues/44732 -- cgit 1.4.1-3-g733a5 From b48a26cdd1d086a3ca7ffae35b73b72f9ce85b8f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 22 Mar 2018 09:56:04 +0100 Subject: Produce nice array lengths on a best effort basis --- src/librustc/traits/error_reporting.rs | 16 ++++++++++++--- src/librustc/util/ppaux.rs | 4 ++-- src/test/ui/did_you_mean/bad-assoc-ty.stderr | 2 +- src/test/ui/unevaluated_fixed_size_array_len.rs | 23 ++++++++++++++++++++++ .../ui/unevaluated_fixed_size_array_len.stderr | 17 ++++++++++++++++ 5 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/unevaluated_fixed_size_array_len.rs create mode 100644 src/test/ui/unevaluated_fixed_size_array_len.stderr diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index ab3c619dcdc..79d5cf79359 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -443,10 +443,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } else { 4 }; + + let normalize = |candidate| self.tcx.global_tcx().infer_ctxt().enter(|ref infcx| { + let normalized = infcx + .at(&ObligationCause::dummy(), ty::ParamEnv::empty()) + .normalize(candidate) + .ok(); + match normalized { + Some(normalized) => format!("\n {:?}", normalized.value), + None => format!("\n {:?}", candidate), + } + }); + err.help(&format!("the following implementations were found:{}{}", - &impl_candidates[0..end].iter().map(|candidate| { - format!("\n {:?}", candidate) - }).collect::(), + &impl_candidates[0..end].iter().map(normalize).collect::(), if impl_candidates.len() > 5 { format!("\nand {} others", impl_candidates.len() - 4) } else { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 2c3ee1ec285..056f1278c47 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -1177,8 +1177,8 @@ define_print! { ConstVal::Value(Value::ByVal(PrimVal::Bytes(sz))) => { write!(f, "{}", sz)?; } - ConstVal::Unevaluated(_def_id, substs) => { - write!(f, "", &substs[..])?; + ConstVal::Unevaluated(_def_id, _substs) => { + write!(f, "_")?; } _ => { write!(f, "{:?}", sz)?; diff --git a/src/test/ui/did_you_mean/bad-assoc-ty.stderr b/src/test/ui/did_you_mean/bad-assoc-ty.stderr index 45dce3d8740..169a12ef92e 100644 --- a/src/test/ui/did_you_mean/bad-assoc-ty.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-ty.stderr @@ -46,7 +46,7 @@ error[E0223]: ambiguous associated type LL | type A = [u8; 4]::AssocTy; | ^^^^^^^^^^^^^^^^ ambiguous associated type | - = note: specify the type using the syntax `<[u8; ] as Trait>::AssocTy` + = note: specify the type using the syntax `<[u8; _] as Trait>::AssocTy` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:15:10 diff --git a/src/test/ui/unevaluated_fixed_size_array_len.rs b/src/test/ui/unevaluated_fixed_size_array_len.rs new file mode 100644 index 00000000000..a6ed9f32106 --- /dev/null +++ b/src/test/ui/unevaluated_fixed_size_array_len.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// https://github.com/rust-lang/rust/issues/49208 + +trait Foo { + fn foo(); +} + +impl Foo for [(); 1] { + fn foo() {} +} + +fn main() { + <[(); 0] as Foo>::foo() //~ ERROR E0277 +} diff --git a/src/test/ui/unevaluated_fixed_size_array_len.stderr b/src/test/ui/unevaluated_fixed_size_array_len.stderr new file mode 100644 index 00000000000..6e959da9939 --- /dev/null +++ b/src/test/ui/unevaluated_fixed_size_array_len.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `[(); 0]: Foo` is not satisfied + --> $DIR/unevaluated_fixed_size_array_len.rs:22:5 + | +LL | <[(); 0] as Foo>::foo() //~ ERROR E0277 + | ^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `[(); 0]` + | + = help: the following implementations were found: + <[(); 1] as Foo> +note: required by `Foo::foo` + --> $DIR/unevaluated_fixed_size_array_len.rs:14:5 + | +LL | fn foo(); + | ^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5 From de1c929adaeb5b1e466b6f8485a9f7cf92969185 Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Thu, 22 Mar 2018 11:27:59 +0100 Subject: Use GNU version of fgrep/egrep tool if available It is mostly for BSD system. Some tests (run-make/issue-35164 and run-make/cat-and-grep-sanity-check) are failing with BSD fgrep, whereas they pass with gnu version (gfgrep). --- src/etc/cat-and-grep.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/etc/cat-and-grep.sh b/src/etc/cat-and-grep.sh index ef9884d2e98..361e8d8e60e 100755 --- a/src/etc/cat-and-grep.sh +++ b/src/etc/cat-and-grep.sh @@ -63,6 +63,11 @@ done shift $((OPTIND - 1)) +# use gnu version of tool if available (for bsd) +if command -v "g${GREPPER}"; then + GREPPER="g${GREPPER}" +fi + LOG=$(mktemp -t cgrep.XXXXXX) trap "rm -f $LOG" EXIT -- cgit 1.4.1-3-g733a5 From bfb94ac5f43ac7fb0736185421f6135fe7043a2e Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Thu, 22 Mar 2018 10:34:51 -0500 Subject: Clean up raw identifier handling when recovering tokens from AST. --- src/libsyntax/ext/quote.rs | 5 +++-- src/libsyntax/ext/tt/transcribe.rs | 2 +- src/libsyntax/parse/token.rs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 090b9a35446..540a03ff032 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -238,8 +238,9 @@ pub mod rt { if i > 0 { inner.push(TokenTree::Token(self.span, token::Colon).into()); } - inner.push(TokenTree::Token(self.span, - token::Ident(segment.identifier, false)).into()); + inner.push(TokenTree::Token( + self.span, token::Token::from_ast_ident(segment.identifier) + ).into()); } inner.push(self.tokens.clone()); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 0f5855a3225..3f01d5ec6dd 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -169,7 +169,7 @@ pub fn transcribe(cx: &ExtCtxt, Ident { ctxt: ident.ctxt.apply_mark(cx.current_expansion.mark), ..ident }; sp = sp.with_ctxt(sp.ctxt().apply_mark(cx.current_expansion.mark)); result.push(TokenTree::Token(sp, token::Dollar).into()); - result.push(TokenTree::Token(sp, token::Ident(ident, false)).into()); + result.push(TokenTree::Token(sp, token::Token::from_ast_ident(ident)).into()); } } quoted::TokenTree::Delimited(mut span, delimited) => { diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 4e7a282adc5..7798a7a77ee 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -236,7 +236,7 @@ impl Token { /// Recovers a `Token` from an `ast::Ident`. This creates a raw identifier if necessary. pub fn from_ast_ident(ident: ast::Ident) -> Token { - Ident(ident, is_reserved_ident(ident)) + Ident(ident, is_reserved_ident(ident) && !is_path_segment_keyword(ident)) } /// Returns `true` if the token starts with '>'. -- cgit 1.4.1-3-g733a5 From 57f9c4d6d9ba7d48b9f64193dd037a54e11ef7b4 Mon Sep 17 00:00:00 2001 From: Lymia Aluysia Date: Thu, 22 Mar 2018 10:35:49 -0500 Subject: Clarify description of raw_identifiers feature flag. --- src/libsyntax/feature_gate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 153e42c8214..c64e0f514de 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -453,7 +453,7 @@ declare_features! ( // `use path as _;` and `extern crate c as _;` (active, underscore_imports, "1.26.0", Some(48216), None), - // Raw identifiers allowing keyword names to be used + // Allows keywords to be escaped for use as identifiers (active, raw_identifiers, "1.26.0", Some(48589), None), ); -- cgit 1.4.1-3-g733a5 From 70559c54ce2a493a15f447436e281e16fc55b291 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Thu, 22 Mar 2018 09:49:20 -0700 Subject: Command::env_saw_path() may be unused on platforms not using posix_spawn() --- src/libstd/sys/unix/process/process_common.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 48255489dd9..b7f30600b8a 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -184,6 +184,7 @@ impl Command { let maybe_env = self.env.capture_if_changed(); maybe_env.map(|env| construct_envp(env, &mut self.saw_nul)) } + #[allow(dead_code)] pub fn env_saw_path(&self) -> bool { self.env.have_changed_path() } -- cgit 1.4.1-3-g733a5 From 7df6f4161cdc13a19216b5f1087081f490f06cdb Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 9 Mar 2018 09:26:15 -0800 Subject: rustc: Add a `#[wasm_custom_section]` attribute This commit is an implementation of adding custom sections to wasm artifacts in rustc. The intention here is to expose the ability of the wasm binary format to contain custom sections with arbitrary user-defined data. Currently neither our version of LLVM nor LLD supports this so the implementation is currently custom to rustc itself. The implementation here is to attach a `#[wasm_custom_section = "foo"]` attribute to any `const` which has a type like `[u8; N]`. Other types of constants aren't supported yet but may be added one day! This should hopefully be enough to get off the ground with *some* custom section support. The current semantics are that any constant tagged with `#[wasm_custom_section]` section will be *appended* to the corresponding section in the final output wasm artifact (and this affects dependencies linked in as well, not just the final crate). This means that whatever is interpreting the contents must be able to interpret binary-concatenated sections (or each constant needs to be in its own custom section). To test this change the existing `run-make` test suite was moved to a `run-make-fulldeps` folder and a new `run-make` test suite was added which applies to all targets by default. This test suite currently only has one test which only runs for the wasm target (using a node.js script to use `WebAssembly` in JS to parse the wasm output). --- src/bootstrap/builder.rs | 1 + src/bootstrap/compile.rs | 2 +- src/bootstrap/test.rs | 19 +- src/librustc/dep_graph/dep_node.rs | 2 + src/librustc/hir/check_attr.rs | 13 + src/librustc/middle/dead.rs | 5 + src/librustc/ty/maps/config.rs | 6 + src/librustc/ty/maps/mod.rs | 2 + src/librustc/ty/maps/plumbing.rs | 1 + src/librustc_metadata/cstore_impl.rs | 2 + src/librustc_metadata/decoder.rs | 10 + src/librustc_metadata/encoder.rs | 12 + src/librustc_metadata/schema.rs | 1 + src/librustc_trans/attributes.rs | 32 +- src/librustc_trans/back/link.rs | 6 + src/librustc_trans/back/wasm.rs | 44 ++ src/librustc_trans/base.rs | 66 +++ src/librustc_trans/lib.rs | 3 + src/librustc_typeck/check/mod.rs | 23 +- src/libsyntax/feature_gate.rs | 8 + .../run-make-fulldeps/a-b-a-linker-guard/Makefile | 12 + src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs | 18 + src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs | 17 + .../run-make-fulldeps/alloc-extern-crates/Makefile | 5 + .../alloc-extern-crates/fakealloc.rs | 33 ++ .../allow-non-lint-warnings-cmdline/Makefile | 11 + .../allow-non-lint-warnings-cmdline/foo.rs | 15 + .../allow-warnings-cmdline-stability/Makefile | 15 + .../allow-warnings-cmdline-stability/bar.rs | 15 + .../allow-warnings-cmdline-stability/foo.rs | 15 + .../archive-duplicate-names/Makefile | 11 + .../archive-duplicate-names/bar.c | 11 + .../archive-duplicate-names/bar.rs | 15 + .../archive-duplicate-names/foo.c | 11 + .../archive-duplicate-names/foo.rs | 24 ++ .../run-make-fulldeps/atomic-lock-free/Makefile | 46 ++ .../atomic-lock-free/atomic_lock_free.rs | 66 +++ src/test/run-make-fulldeps/bare-outfile/Makefile | 6 + src/test/run-make-fulldeps/bare-outfile/foo.rs | 12 + .../run-make-fulldeps/c-dynamic-dylib/Makefile | 14 + src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs | 15 + src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c | 5 + src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs | 20 + src/test/run-make-fulldeps/c-dynamic-rlib/Makefile | 17 + src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs | 15 + src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c | 6 + src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs | 20 + .../c-link-to-rust-dylib/Makefile | 17 + .../run-make-fulldeps/c-link-to-rust-dylib/bar.c | 7 + .../run-make-fulldeps/c-link-to-rust-dylib/foo.rs | 14 + .../c-link-to-rust-staticlib/Makefile | 16 + .../c-link-to-rust-staticlib/bar.c | 7 + .../c-link-to-rust-staticlib/foo.rs | 14 + src/test/run-make-fulldeps/c-static-dylib/Makefile | 9 + src/test/run-make-fulldeps/c-static-dylib/bar.rs | 15 + src/test/run-make-fulldeps/c-static-dylib/cfoo.c | 2 + src/test/run-make-fulldeps/c-static-dylib/foo.rs | 20 + src/test/run-make-fulldeps/c-static-rlib/Makefile | 8 + src/test/run-make-fulldeps/c-static-rlib/bar.rs | 15 + src/test/run-make-fulldeps/c-static-rlib/cfoo.c | 2 + src/test/run-make-fulldeps/c-static-rlib/foo.rs | 20 + .../cat-and-grep-sanity-check/Makefile | 46 ++ .../cdylib-fewer-symbols/Makefile | 15 + .../run-make-fulldeps/cdylib-fewer-symbols/foo.rs | 16 + src/test/run-make-fulldeps/cdylib/Makefile | 19 + src/test/run-make-fulldeps/cdylib/bar.rs | 15 + src/test/run-make-fulldeps/cdylib/foo.c | 20 + src/test/run-make-fulldeps/cdylib/foo.rs | 23 + .../codegen-options-parsing/Makefile | 31 ++ .../codegen-options-parsing/dummy.rs | 11 + src/test/run-make-fulldeps/compile-stdin/Makefile | 5 + .../compiler-lookup-paths-2/Makefile | 8 + .../run-make-fulldeps/compiler-lookup-paths-2/a.rs | 11 + .../run-make-fulldeps/compiler-lookup-paths-2/b.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths-2/c.rs | 13 + .../compiler-lookup-paths/Makefile | 38 ++ .../run-make-fulldeps/compiler-lookup-paths/a.rs | 11 + .../run-make-fulldeps/compiler-lookup-paths/b.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths/c.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths/d.rs | 14 + .../run-make-fulldeps/compiler-lookup-paths/e.rs | 12 + .../run-make-fulldeps/compiler-lookup-paths/e2.rs | 14 + .../run-make-fulldeps/compiler-lookup-paths/f.rs | 12 + .../compiler-lookup-paths/native.c | 9 + .../compiler-rt-works-on-mingw/Makefile | 17 + .../compiler-rt-works-on-mingw/foo.cpp | 5 + .../compiler-rt-works-on-mingw/foo.rs | 16 + .../run-make-fulldeps/crate-data-smoke/Makefile | 10 + .../run-make-fulldeps/crate-data-smoke/crate.rs | 17 + src/test/run-make-fulldeps/crate-data-smoke/lib.rs | 12 + .../run-make-fulldeps/crate-data-smoke/rlib.rs | 12 + .../run-make-fulldeps/crate-name-priority/Makefile | 11 + .../run-make-fulldeps/crate-name-priority/foo.rs | 11 + .../run-make-fulldeps/crate-name-priority/foo1.rs | 13 + .../run-make-fulldeps/debug-assertions/Makefile | 25 ++ .../run-make-fulldeps/debug-assertions/debug.rs | 43 ++ .../dep-info-doesnt-run-much/Makefile | 4 + .../dep-info-doesnt-run-much/foo.rs | 15 + .../run-make-fulldeps/dep-info-spaces/Makefile | 28 ++ .../run-make-fulldeps/dep-info-spaces/Makefile.foo | 7 + src/test/run-make-fulldeps/dep-info-spaces/bar.rs | 11 + .../run-make-fulldeps/dep-info-spaces/foo foo.rs | 11 + src/test/run-make-fulldeps/dep-info-spaces/lib.rs | 14 + src/test/run-make-fulldeps/dep-info/Makefile | 34 ++ src/test/run-make-fulldeps/dep-info/Makefile.foo | 7 + src/test/run-make-fulldeps/dep-info/bar.rs | 11 + src/test/run-make-fulldeps/dep-info/foo.rs | 11 + src/test/run-make-fulldeps/dep-info/lib.rs | 14 + src/test/run-make-fulldeps/dep-info/lib2.rs | 13 + .../duplicate-output-flavors/Makefile | 5 + .../duplicate-output-flavors/foo.rs | 11 + src/test/run-make-fulldeps/dylib-chain/Makefile | 12 + src/test/run-make-fulldeps/dylib-chain/m1.rs | 12 + src/test/run-make-fulldeps/dylib-chain/m2.rs | 14 + src/test/run-make-fulldeps/dylib-chain/m3.rs | 14 + src/test/run-make-fulldeps/dylib-chain/m4.rs | 13 + src/test/run-make-fulldeps/emit/Makefile | 21 + src/test/run-make-fulldeps/emit/test-24876.rs | 19 + src/test/run-make-fulldeps/emit/test-26235.rs | 56 +++ .../error-found-staticlib-instead-crate/Makefile | 5 + .../error-found-staticlib-instead-crate/bar.rs | 15 + .../error-found-staticlib-instead-crate/foo.rs | 11 + .../error-writing-dependencies/Makefile | 8 + .../error-writing-dependencies/foo.rs | 11 + .../extern-diff-internal-name/Makefile | 5 + .../extern-diff-internal-name/lib.rs | 12 + .../extern-diff-internal-name/test.rs | 15 + .../extern-flag-disambiguates/Makefile | 25 ++ .../extern-flag-disambiguates/a.rs | 16 + .../extern-flag-disambiguates/b.rs | 19 + .../extern-flag-disambiguates/c.rs | 19 + .../extern-flag-disambiguates/d.rs | 21 + .../run-make-fulldeps/extern-flag-fun/Makefile | 17 + .../run-make-fulldeps/extern-flag-fun/bar-alt.rs | 11 + src/test/run-make-fulldeps/extern-flag-fun/bar.rs | 9 + src/test/run-make-fulldeps/extern-flag-fun/foo.rs | 13 + .../run-make-fulldeps/extern-fn-generic/Makefile | 6 + .../run-make-fulldeps/extern-fn-generic/test.c | 17 + .../run-make-fulldeps/extern-fn-generic/test.rs | 32 ++ .../extern-fn-generic/testcrate.rs | 24 ++ .../run-make-fulldeps/extern-fn-mangle/Makefile | 5 + src/test/run-make-fulldeps/extern-fn-mangle/test.c | 9 + .../run-make-fulldeps/extern-fn-mangle/test.rs | 25 ++ .../run-make-fulldeps/extern-fn-reachable/Makefile | 9 + .../run-make-fulldeps/extern-fn-reachable/dylib.rs | 24 ++ .../run-make-fulldeps/extern-fn-reachable/main.rs | 28 ++ .../extern-fn-struct-passing-abi/Makefile | 5 + .../extern-fn-struct-passing-abi/test.c | 324 ++++++++++++++ .../extern-fn-struct-passing-abi/test.rs | 144 +++++++ .../extern-fn-with-extern-types/Makefile | 5 + .../extern-fn-with-extern-types/ctest.c | 17 + .../extern-fn-with-extern-types/test.rs | 27 ++ .../extern-fn-with-packed-struct/Makefile | 5 + .../extern-fn-with-packed-struct/test.c | 27 ++ .../extern-fn-with-packed-struct/test.rs | 30 ++ .../extern-fn-with-union/Makefile | 6 + .../run-make-fulldeps/extern-fn-with-union/ctest.c | 11 + .../run-make-fulldeps/extern-fn-with-union/test.rs | 33 ++ .../extern-fn-with-union/testcrate.rs | 21 + .../extern-multiple-copies/Makefile | 8 + .../extern-multiple-copies/bar.rs | 16 + .../extern-multiple-copies/foo1.rs | 11 + .../extern-multiple-copies/foo2.rs | 11 + .../extern-multiple-copies2/Makefile | 10 + .../extern-multiple-copies2/bar.rs | 18 + .../extern-multiple-copies2/foo1.rs | 17 + .../extern-multiple-copies2/foo2.rs | 18 + .../extern-overrides-distribution/Makefile | 5 + .../extern-overrides-distribution/libc.rs | 13 + .../extern-overrides-distribution/main.rs | 15 + .../extra-filename-with-temp-outputs/Makefile | 6 + .../extra-filename-with-temp-outputs/foo.rs | 11 + src/test/run-make-fulldeps/fpic/Makefile | 13 + src/test/run-make-fulldeps/fpic/hello.rs | 11 + src/test/run-make-fulldeps/hir-tree/Makefile | 8 + src/test/run-make-fulldeps/hir-tree/input.rs | 13 + .../hotplug_codegen_backend/Makefile | 9 + .../hotplug_codegen_backend/some_crate.rs | 13 + .../hotplug_codegen_backend/the_backend.rs | 82 ++++ .../run-make-fulldeps/include_bytes_deps/Makefile | 20 + .../run-make-fulldeps/include_bytes_deps/input.bin | 1 + .../run-make-fulldeps/include_bytes_deps/input.md | 1 + .../run-make-fulldeps/include_bytes_deps/input.txt | 1 + .../run-make-fulldeps/include_bytes_deps/main.rs | 22 + .../inline-always-many-cgu/Makefile | 8 + .../inline-always-many-cgu/foo.rs | 25 ++ .../interdependent-c-libraries/Makefile | 14 + .../interdependent-c-libraries/bar.c | 4 + .../interdependent-c-libraries/bar.rs | 22 + .../interdependent-c-libraries/foo.c | 2 + .../interdependent-c-libraries/foo.rs | 20 + .../interdependent-c-libraries/main.rs | 16 + .../intrinsic-unreachable/Makefile | 15 + .../intrinsic-unreachable/exit-ret.rs | 25 ++ .../intrinsic-unreachable/exit-unreachable.rs | 27 ++ .../run-make-fulldeps/invalid-library/Makefile | 6 + src/test/run-make-fulldeps/invalid-library/foo.rs | 13 + .../run-make-fulldeps/invalid-staticlib/Makefile | 5 + src/test/run-make-fulldeps/issue-11908/Makefile | 21 + src/test/run-make-fulldeps/issue-11908/bar.rs | 13 + src/test/run-make-fulldeps/issue-11908/foo.rs | 11 + src/test/run-make-fulldeps/issue-14500/Makefile | 17 + src/test/run-make-fulldeps/issue-14500/bar.rs | 11 + src/test/run-make-fulldeps/issue-14500/foo.c | 17 + src/test/run-make-fulldeps/issue-14500/foo.rs | 15 + src/test/run-make-fulldeps/issue-14698/Makefile | 4 + src/test/run-make-fulldeps/issue-14698/foo.rs | 11 + src/test/run-make-fulldeps/issue-15460/Makefile | 6 + src/test/run-make-fulldeps/issue-15460/bar.rs | 14 + src/test/run-make-fulldeps/issue-15460/foo.c | 6 + src/test/run-make-fulldeps/issue-15460/foo.rs | 16 + src/test/run-make-fulldeps/issue-18943/Makefile | 7 + src/test/run-make-fulldeps/issue-18943/foo.rs | 16 + src/test/run-make-fulldeps/issue-19371/Makefile | 9 + src/test/run-make-fulldeps/issue-19371/foo.rs | 88 ++++ src/test/run-make-fulldeps/issue-20626/Makefile | 8 + src/test/run-make-fulldeps/issue-20626/foo.rs | 23 + src/test/run-make-fulldeps/issue-22131/Makefile | 7 + src/test/run-make-fulldeps/issue-22131/foo.rs | 15 + src/test/run-make-fulldeps/issue-24445/Makefile | 12 + src/test/run-make-fulldeps/issue-24445/foo.c | 16 + src/test/run-make-fulldeps/issue-24445/foo.rs | 25 ++ src/test/run-make-fulldeps/issue-25581/Makefile | 5 + src/test/run-make-fulldeps/issue-25581/test.c | 16 + src/test/run-make-fulldeps/issue-25581/test.rs | 32 ++ src/test/run-make-fulldeps/issue-26006/Makefile | 18 + .../run-make-fulldeps/issue-26006/in/libc/lib.rs | 12 + .../run-make-fulldeps/issue-26006/in/time/lib.rs | 13 + src/test/run-make-fulldeps/issue-26092/Makefile | 4 + src/test/run-make-fulldeps/issue-26092/blank.rs | 11 + src/test/run-make-fulldeps/issue-28595/Makefile | 6 + src/test/run-make-fulldeps/issue-28595/a.c | 11 + src/test/run-make-fulldeps/issue-28595/a.rs | 16 + src/test/run-make-fulldeps/issue-28595/b.c | 16 + src/test/run-make-fulldeps/issue-28595/b.rs | 21 + src/test/run-make-fulldeps/issue-28766/Makefile | 5 + src/test/run-make-fulldeps/issue-28766/foo.rs | 18 + src/test/run-make-fulldeps/issue-28766/main.rs | 17 + src/test/run-make-fulldeps/issue-30063/Makefile | 35 ++ src/test/run-make-fulldeps/issue-30063/foo.rs | 11 + src/test/run-make-fulldeps/issue-33329/Makefile | 5 + src/test/run-make-fulldeps/issue-33329/main.rs | 11 + src/test/run-make-fulldeps/issue-35164/Makefile | 4 + src/test/run-make-fulldeps/issue-35164/main.rs | 15 + .../run-make-fulldeps/issue-35164/submodule/mod.rs | 13 + src/test/run-make-fulldeps/issue-37839/Makefile | 12 + src/test/run-make-fulldeps/issue-37839/a.rs | 12 + src/test/run-make-fulldeps/issue-37839/b.rs | 12 + src/test/run-make-fulldeps/issue-37839/c.rs | 12 + src/test/run-make-fulldeps/issue-37893/Makefile | 10 + src/test/run-make-fulldeps/issue-37893/a.rs | 12 + src/test/run-make-fulldeps/issue-37893/b.rs | 12 + src/test/run-make-fulldeps/issue-37893/c.rs | 13 + src/test/run-make-fulldeps/issue-38237/Makefile | 11 + src/test/run-make-fulldeps/issue-38237/bar.rs | 14 + src/test/run-make-fulldeps/issue-38237/baz.rs | 18 + src/test/run-make-fulldeps/issue-38237/foo.rs | 19 + src/test/run-make-fulldeps/issue-40535/Makefile | 13 + src/test/run-make-fulldeps/issue-40535/bar.rs | 13 + src/test/run-make-fulldeps/issue-40535/baz.rs | 11 + src/test/run-make-fulldeps/issue-40535/foo.rs | 14 + src/test/run-make-fulldeps/issue-46239/Makefile | 5 + src/test/run-make-fulldeps/issue-46239/main.rs | 18 + src/test/run-make-fulldeps/issue-7349/Makefile | 11 + src/test/run-make-fulldeps/issue-7349/foo.rs | 32 ++ .../run-make-fulldeps/issues-41478-43796/Makefile | 8 + src/test/run-make-fulldeps/issues-41478-43796/a.rs | 19 + src/test/run-make-fulldeps/libs-and-bins/Makefile | 6 + src/test/run-make-fulldeps/libs-and-bins/foo.rs | 14 + .../libs-through-symlinks/Makefile | 14 + .../run-make-fulldeps/libs-through-symlinks/bar.rs | 13 + .../run-make-fulldeps/libs-through-symlinks/foo.rs | 12 + src/test/run-make-fulldeps/libtest-json/Makefile | 14 + src/test/run-make-fulldeps/libtest-json/f.rs | 32 ++ .../run-make-fulldeps/libtest-json/output.json | 10 + .../libtest-json/validate_json.py | 18 + src/test/run-make-fulldeps/link-arg/Makefile | 5 + src/test/run-make-fulldeps/link-arg/empty.rs | 11 + src/test/run-make-fulldeps/link-cfg/Makefile | 22 + .../link-cfg/dep-with-staticlib.rs | 18 + src/test/run-make-fulldeps/link-cfg/dep.rs | 18 + src/test/run-make-fulldeps/link-cfg/no-deps.rs | 30 ++ src/test/run-make-fulldeps/link-cfg/return1.c | 16 + src/test/run-make-fulldeps/link-cfg/return2.c | 16 + src/test/run-make-fulldeps/link-cfg/return3.c | 16 + src/test/run-make-fulldeps/link-cfg/with-deps.rs | 24 ++ .../link-cfg/with-staticlib-deps.rs | 24 ++ .../run-make-fulldeps/link-path-order/Makefile | 18 + .../run-make-fulldeps/link-path-order/correct.c | 2 + src/test/run-make-fulldeps/link-path-order/main.rs | 28 ++ src/test/run-make-fulldeps/link-path-order/wrong.c | 2 + .../linkage-attr-on-static/Makefile | 5 + .../linkage-attr-on-static/bar.rs | 26 ++ .../run-make-fulldeps/linkage-attr-on-static/foo.c | 8 + .../linker-output-non-utf8/Makefile | 32 ++ .../linker-output-non-utf8/exec.rs | 16 + .../linker-output-non-utf8/library.rs | 20 + src/test/run-make-fulldeps/llvm-pass/Makefile | 28 ++ .../llvm-pass/llvm-function-pass.so.cc | 61 +++ .../llvm-pass/llvm-module-pass.so.cc | 60 +++ src/test/run-make-fulldeps/llvm-pass/main.rs | 14 + src/test/run-make-fulldeps/llvm-pass/plugin.rs | 28 ++ .../long-linker-command-lines-cmd-exe/Makefile | 6 + .../long-linker-command-lines-cmd-exe/foo.bat | 1 + .../long-linker-command-lines-cmd-exe/foo.rs | 111 +++++ .../long-linker-command-lines/Makefile | 5 + .../long-linker-command-lines/foo.rs | 101 +++++ .../run-make-fulldeps/longjmp-across-rust/Makefile | 5 + .../run-make-fulldeps/longjmp-across-rust/foo.c | 28 ++ .../run-make-fulldeps/longjmp-across-rust/main.rs | 40 ++ src/test/run-make-fulldeps/ls-metadata/Makefile | 7 + src/test/run-make-fulldeps/ls-metadata/foo.rs | 11 + .../lto-no-link-whole-rlib/Makefile | 18 + .../run-make-fulldeps/lto-no-link-whole-rlib/bar.c | 13 + .../run-make-fulldeps/lto-no-link-whole-rlib/foo.c | 13 + .../lto-no-link-whole-rlib/lib1.rs | 20 + .../lto-no-link-whole-rlib/lib2.rs | 23 + .../lto-no-link-whole-rlib/main.rs | 17 + .../run-make-fulldeps/lto-readonly-lib/Makefile | 12 + src/test/run-make-fulldeps/lto-readonly-lib/lib.rs | 11 + .../run-make-fulldeps/lto-readonly-lib/main.rs | 13 + src/test/run-make-fulldeps/lto-smoke-c/Makefile | 11 + src/test/run-make-fulldeps/lto-smoke-c/bar.c | 7 + src/test/run-make-fulldeps/lto-smoke-c/foo.rs | 14 + src/test/run-make-fulldeps/lto-smoke/Makefile | 6 + src/test/run-make-fulldeps/lto-smoke/lib.rs | 11 + src/test/run-make-fulldeps/lto-smoke/main.rs | 13 + .../run-make-fulldeps/manual-crate-name/Makefile | 5 + .../run-make-fulldeps/manual-crate-name/bar.rs | 11 + src/test/run-make-fulldeps/manual-link/Makefile | 6 + src/test/run-make-fulldeps/manual-link/bar.c | 2 + src/test/run-make-fulldeps/manual-link/foo.c | 2 + src/test/run-make-fulldeps/manual-link/foo.rs | 19 + src/test/run-make-fulldeps/manual-link/main.rs | 15 + .../many-crates-but-no-match/Makefile | 36 ++ .../many-crates-but-no-match/crateA1.rs | 14 + .../many-crates-but-no-match/crateA2.rs | 14 + .../many-crates-but-no-match/crateA3.rs | 14 + .../many-crates-but-no-match/crateB.rs | 11 + .../many-crates-but-no-match/crateC.rs | 13 + .../metadata-flag-frobs-symbols/Makefile | 10 + .../metadata-flag-frobs-symbols/bar.rs | 18 + .../metadata-flag-frobs-symbols/foo.rs | 16 + .../run-make-fulldeps/min-global-align/Makefile | 22 + .../min-global-align/min_global_align.rs | 38 ++ .../mismatching-target-triples/Makefile | 11 + .../mismatching-target-triples/bar.rs | 13 + .../mismatching-target-triples/foo.rs | 13 + .../missing-crate-dependency/Makefile | 9 + .../missing-crate-dependency/crateA.rs | 12 + .../missing-crate-dependency/crateB.rs | 11 + .../missing-crate-dependency/crateC.rs | 13 + src/test/run-make-fulldeps/mixing-deps/Makefile | 7 + src/test/run-make-fulldeps/mixing-deps/both.rs | 14 + src/test/run-make-fulldeps/mixing-deps/dylib.rs | 16 + src/test/run-make-fulldeps/mixing-deps/prog.rs | 19 + src/test/run-make-fulldeps/mixing-formats/Makefile | 74 ++++ src/test/run-make-fulldeps/mixing-formats/bar1.rs | 11 + src/test/run-make-fulldeps/mixing-formats/bar2.rs | 11 + src/test/run-make-fulldeps/mixing-formats/baz.rs | 13 + src/test/run-make-fulldeps/mixing-formats/baz2.rs | 14 + src/test/run-make-fulldeps/mixing-formats/foo.rs | 9 + src/test/run-make-fulldeps/mixing-libs/Makefile | 9 + src/test/run-make-fulldeps/mixing-libs/dylib.rs | 14 + src/test/run-make-fulldeps/mixing-libs/prog.rs | 17 + src/test/run-make-fulldeps/mixing-libs/rlib.rs | 12 + .../run-make-fulldeps/msvc-opt-minsize/Makefile | 5 + src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs | 29 ++ src/test/run-make-fulldeps/multiple-emits/Makefile | 7 + src/test/run-make-fulldeps/multiple-emits/foo.rs | 11 + .../run-make-fulldeps/no-builtins-lto/Makefile | 9 + src/test/run-make-fulldeps/no-builtins-lto/main.rs | 13 + .../no-builtins-lto/no_builtins.rs | 12 + .../run-make-fulldeps/no-duplicate-libs/Makefile | 10 + src/test/run-make-fulldeps/no-duplicate-libs/bar.c | 15 + src/test/run-make-fulldeps/no-duplicate-libs/foo.c | 11 + .../run-make-fulldeps/no-duplicate-libs/main.rs | 20 + .../run-make-fulldeps/no-integrated-as/Makefile | 7 + .../run-make-fulldeps/no-integrated-as/hello.rs | 13 + .../no-intermediate-extras/Makefile | 7 + .../no-intermediate-extras/foo.rs | 9 + .../obey-crate-type-flag/Makefile | 13 + .../run-make-fulldeps/obey-crate-type-flag/test.rs | 12 + .../Makefile | 7 + .../foo.rs | 11 + .../output-filename-overwrites-input/Makefile | 13 + .../output-filename-overwrites-input/bar.rs | 11 + .../output-filename-overwrites-input/foo.rs | 11 + .../output-type-permutations/Makefile | 146 +++++++ .../output-type-permutations/foo.rs | 13 + .../run-make-fulldeps/output-with-hyphens/Makefile | 6 + .../output-with-hyphens/foo-bar.rs | 14 + src/test/run-make-fulldeps/prefer-dylib/Makefile | 8 + src/test/run-make-fulldeps/prefer-dylib/bar.rs | 11 + src/test/run-make-fulldeps/prefer-dylib/foo.rs | 15 + src/test/run-make-fulldeps/prefer-rlib/Makefile | 8 + src/test/run-make-fulldeps/prefer-rlib/bar.rs | 11 + src/test/run-make-fulldeps/prefer-rlib/foo.rs | 15 + .../pretty-expanded-hygiene/Makefile | 21 + .../pretty-expanded-hygiene/input.pp.rs | 19 + .../pretty-expanded-hygiene/input.rs | 24 ++ .../run-make-fulldeps/pretty-expanded/Makefile | 5 + .../run-make-fulldeps/pretty-expanded/input.rs | 22 + .../pretty-print-path-suffix/Makefile | 9 + .../pretty-print-path-suffix/foo.pp | 15 + .../pretty-print-path-suffix/foo_method.pp | 17 + .../pretty-print-path-suffix/input.rs | 28 ++ .../pretty-print-path-suffix/nest_foo.pp | 14 + .../pretty-print-to-file/Makefile | 5 + .../pretty-print-to-file/input.pp | 13 + .../pretty-print-to-file/input.rs | 15 + src/test/run-make-fulldeps/print-cfg/Makefile | 16 + .../run-make-fulldeps/print-target-list/Makefile | 15 + src/test/run-make-fulldeps/profile/Makefile | 9 + src/test/run-make-fulldeps/profile/test.rs | 11 + .../run-make-fulldeps/prune-link-args/Makefile | 11 + .../run-make-fulldeps/prune-link-args/empty.rs | 11 + .../run-make-fulldeps/relocation-model/Makefile | 19 + src/test/run-make-fulldeps/relocation-model/foo.rs | 11 + src/test/run-make-fulldeps/relro-levels/Makefile | 21 + src/test/run-make-fulldeps/relro-levels/hello.rs | 13 + .../run-make-fulldeps/reproducible-build/Makefile | 74 ++++ .../run-make-fulldeps/reproducible-build/linker.rs | 54 +++ .../reproducible-build/reproducible-build-aux.rs | 38 ++ .../reproducible-build/reproducible-build.rs | 126 ++++++ src/test/run-make-fulldeps/rlib-chain/Makefile | 10 + src/test/run-make-fulldeps/rlib-chain/m1.rs | 12 + src/test/run-make-fulldeps/rlib-chain/m2.rs | 14 + src/test/run-make-fulldeps/rlib-chain/m3.rs | 14 + src/test/run-make-fulldeps/rlib-chain/m4.rs | 13 + .../rustc-macro-dep-files/Makefile | 12 + .../run-make-fulldeps/rustc-macro-dep-files/bar.rs | 19 + .../run-make-fulldeps/rustc-macro-dep-files/foo.rs | 22 + .../run-make-fulldeps/rustdoc-error-lines/Makefile | 8 + .../run-make-fulldeps/rustdoc-error-lines/input.rs | 21 + .../run-make-fulldeps/rustdoc-output-path/Makefile | 4 + .../run-make-fulldeps/rustdoc-output-path/foo.rs | 11 + .../run-make-fulldeps/sanitizer-address/Makefile | 29 ++ .../sanitizer-address/overflow.rs | 14 + .../sanitizer-cdylib-link/Makefile | 22 + .../sanitizer-cdylib-link/library.rs | 15 + .../sanitizer-cdylib-link/program.rs | 17 + .../sanitizer-dylib-link/Makefile | 22 + .../sanitizer-dylib-link/library.rs | 15 + .../sanitizer-dylib-link/program.rs | 17 + .../sanitizer-invalid-cratetype/Makefile | 18 + .../sanitizer-invalid-cratetype/hello.rs | 13 + .../sanitizer-invalid-target/Makefile | 5 + .../sanitizer-invalid-target/hello.rs | 13 + src/test/run-make-fulldeps/sanitizer-leak/Makefile | 16 + src/test/run-make-fulldeps/sanitizer-leak/leak.rs | 16 + .../run-make-fulldeps/sanitizer-memory/Makefile | 10 + .../run-make-fulldeps/sanitizer-memory/uninit.rs | 16 + .../sanitizer-staticlib-link/Makefile | 18 + .../sanitizer-staticlib-link/library.rs | 15 + .../sanitizer-staticlib-link/program.c | 8 + .../run-make-fulldeps/save-analysis-fail/Makefile | 6 + .../save-analysis-fail/SameDir.rs | 15 + .../save-analysis-fail/SameDir3.rs | 13 + .../save-analysis-fail/SubDir/mod.rs | 37 ++ .../run-make-fulldeps/save-analysis-fail/foo.rs | 468 +++++++++++++++++++++ .../run-make-fulldeps/save-analysis-fail/krate2.rs | 18 + src/test/run-make-fulldeps/save-analysis/Makefile | 6 + .../run-make-fulldeps/save-analysis/SameDir.rs | 15 + .../run-make-fulldeps/save-analysis/SameDir3.rs | 13 + .../run-make-fulldeps/save-analysis/SubDir/mod.rs | 37 ++ .../run-make-fulldeps/save-analysis/extra-docs.md | 1 + src/test/run-make-fulldeps/save-analysis/foo.rs | 467 ++++++++++++++++++++ src/test/run-make-fulldeps/save-analysis/krate2.rs | 18 + .../run-make-fulldeps/sepcomp-cci-copies/Makefile | 12 + .../sepcomp-cci-copies/cci_lib.rs | 16 + .../run-make-fulldeps/sepcomp-cci-copies/foo.rs | 35 ++ .../run-make-fulldeps/sepcomp-inlining/Makefile | 15 + src/test/run-make-fulldeps/sepcomp-inlining/foo.rs | 40 ++ .../run-make-fulldeps/sepcomp-separate/Makefile | 9 + src/test/run-make-fulldeps/sepcomp-separate/foo.rs | 33 ++ src/test/run-make-fulldeps/simd-ffi/Makefile | 47 +++ src/test/run-make-fulldeps/simd-ffi/simd.rs | 83 ++++ src/test/run-make-fulldeps/simple-dylib/Makefile | 5 + src/test/run-make-fulldeps/simple-dylib/bar.rs | 11 + src/test/run-make-fulldeps/simple-dylib/foo.rs | 15 + src/test/run-make-fulldeps/simple-rlib/Makefile | 5 + src/test/run-make-fulldeps/simple-rlib/bar.rs | 11 + src/test/run-make-fulldeps/simple-rlib/foo.rs | 15 + .../run-make-fulldeps/stable-symbol-names/Makefile | 40 ++ .../stable-symbol-names/stable-symbol-names1.rs | 41 ++ .../stable-symbol-names/stable-symbol-names2.rs | 28 ++ .../static-dylib-by-default/Makefile | 16 + .../static-dylib-by-default/bar.rs | 18 + .../static-dylib-by-default/foo.rs | 14 + .../static-dylib-by-default/main.c | 16 + .../run-make-fulldeps/static-nobundle/Makefile | 21 + src/test/run-make-fulldeps/static-nobundle/aaa.c | 11 + src/test/run-make-fulldeps/static-nobundle/bbb.rs | 23 + src/test/run-make-fulldeps/static-nobundle/ccc.rs | 23 + src/test/run-make-fulldeps/static-nobundle/ddd.rs | 17 + .../run-make-fulldeps/static-unwinding/Makefile | 6 + src/test/run-make-fulldeps/static-unwinding/lib.rs | 25 ++ .../run-make-fulldeps/static-unwinding/main.rs | 34 ++ .../run-make-fulldeps/staticlib-blank-lib/Makefile | 6 + .../run-make-fulldeps/staticlib-blank-lib/foo.rs | 16 + src/test/run-make-fulldeps/stdin-non-utf8/Makefile | 6 + src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 | 1 + .../run-make-fulldeps/suspicious-library/Makefile | 7 + .../run-make-fulldeps/suspicious-library/bar.rs | 13 + .../run-make-fulldeps/suspicious-library/foo.rs | 13 + .../run-make-fulldeps/symbol-visibility/Makefile | 60 +++ .../symbol-visibility/a_cdylib.rs | 22 + .../symbol-visibility/a_rust_dylib.rs | 20 + .../symbol-visibility/an_executable.rs | 17 + .../run-make-fulldeps/symbol-visibility/an_rlib.rs | 16 + .../symbols-are-reasonable/Makefile | 13 + .../symbols-are-reasonable/lib.rs | 21 + .../symbols-include-type-name/Makefile | 9 + .../symbols-include-type-name/lib.rs | 24 ++ .../run-make-fulldeps/symlinked-extern/Makefile | 16 + src/test/run-make-fulldeps/symlinked-extern/bar.rs | 16 + src/test/run-make-fulldeps/symlinked-extern/baz.rs | 16 + src/test/run-make-fulldeps/symlinked-extern/foo.rs | 15 + .../run-make-fulldeps/symlinked-libraries/Makefile | 15 + .../run-make-fulldeps/symlinked-libraries/bar.rs | 15 + .../run-make-fulldeps/symlinked-libraries/foo.rs | 13 + src/test/run-make-fulldeps/symlinked-rlib/Makefile | 14 + src/test/run-make-fulldeps/symlinked-rlib/bar.rs | 15 + src/test/run-make-fulldeps/symlinked-rlib/foo.rs | 11 + .../sysroot-crates-are-unstable/Makefile | 2 + .../sysroot-crates-are-unstable/test.py | 71 ++++ .../run-make-fulldeps/target-cpu-native/Makefile | 5 + .../run-make-fulldeps/target-cpu-native/foo.rs | 12 + src/test/run-make-fulldeps/target-specs/Makefile | 9 + src/test/run-make-fulldeps/target-specs/foo.rs | 32 ++ .../target-specs/my-awesome-platform.json | 11 + .../target-specs/my-incomplete-platform.json | 10 + .../target-specs/my-invalid-platform.json | 1 + .../my-x86_64-unknown-linux-gnu-platform.json | 12 + .../target-without-atomics/Makefile | 5 + src/test/run-make-fulldeps/test-harness/Makefile | 8 + .../test-harness/test-ignore-cfg.rs | 19 + src/test/run-make-fulldeps/tools.mk | 134 ++++++ .../run-make-fulldeps/treat-err-as-bug/Makefile | 5 + src/test/run-make-fulldeps/treat-err-as-bug/err.rs | 13 + .../type-mismatch-same-crate-name/Makefile | 19 + .../type-mismatch-same-crate-name/crateA.rs | 26 ++ .../type-mismatch-same-crate-name/crateB.rs | 14 + .../type-mismatch-same-crate-name/crateC.rs | 35 ++ .../use-extern-for-plugins/Makefile | 21 + .../use-extern-for-plugins/bar.rs | 19 + .../use-extern-for-plugins/baz.rs | 18 + .../use-extern-for-plugins/foo.rs | 18 + src/test/run-make-fulldeps/used/Makefile | 11 + src/test/run-make-fulldeps/used/used.rs | 17 + src/test/run-make-fulldeps/version/Makefile | 6 + .../run-make-fulldeps/volatile-intrinsics/Makefile | 9 + .../run-make-fulldeps/volatile-intrinsics/main.rs | 27 ++ .../weird-output-filenames/Makefile | 15 + .../weird-output-filenames/foo.rs | 11 + src/test/run-make-fulldeps/windows-spawn/Makefile | 14 + src/test/run-make-fulldeps/windows-spawn/hello.rs | 13 + src/test/run-make-fulldeps/windows-spawn/spawn.rs | 22 + .../run-make-fulldeps/windows-subsystem/Makefile | 5 + .../run-make-fulldeps/windows-subsystem/console.rs | 14 + .../run-make-fulldeps/windows-subsystem/windows.rs | 13 + src/test/run-make/a-b-a-linker-guard/Makefile | 12 - src/test/run-make/a-b-a-linker-guard/a.rs | 18 - src/test/run-make/a-b-a-linker-guard/b.rs | 17 - src/test/run-make/alloc-extern-crates/Makefile | 5 - src/test/run-make/alloc-extern-crates/fakealloc.rs | 33 -- .../allow-non-lint-warnings-cmdline/Makefile | 11 - .../allow-non-lint-warnings-cmdline/foo.rs | 15 - .../allow-warnings-cmdline-stability/Makefile | 15 - .../allow-warnings-cmdline-stability/bar.rs | 15 - .../allow-warnings-cmdline-stability/foo.rs | 15 - src/test/run-make/archive-duplicate-names/Makefile | 11 - src/test/run-make/archive-duplicate-names/bar.c | 11 - src/test/run-make/archive-duplicate-names/bar.rs | 15 - src/test/run-make/archive-duplicate-names/foo.c | 11 - src/test/run-make/archive-duplicate-names/foo.rs | 24 -- src/test/run-make/atomic-lock-free/Makefile | 46 -- .../run-make/atomic-lock-free/atomic_lock_free.rs | 66 --- src/test/run-make/bare-outfile/Makefile | 6 - src/test/run-make/bare-outfile/foo.rs | 12 - src/test/run-make/c-dynamic-dylib/Makefile | 14 - src/test/run-make/c-dynamic-dylib/bar.rs | 15 - src/test/run-make/c-dynamic-dylib/cfoo.c | 5 - src/test/run-make/c-dynamic-dylib/foo.rs | 20 - src/test/run-make/c-dynamic-rlib/Makefile | 17 - src/test/run-make/c-dynamic-rlib/bar.rs | 15 - src/test/run-make/c-dynamic-rlib/cfoo.c | 6 - src/test/run-make/c-dynamic-rlib/foo.rs | 20 - src/test/run-make/c-link-to-rust-dylib/Makefile | 17 - src/test/run-make/c-link-to-rust-dylib/bar.c | 7 - src/test/run-make/c-link-to-rust-dylib/foo.rs | 14 - .../run-make/c-link-to-rust-staticlib/Makefile | 16 - src/test/run-make/c-link-to-rust-staticlib/bar.c | 7 - src/test/run-make/c-link-to-rust-staticlib/foo.rs | 14 - src/test/run-make/c-static-dylib/Makefile | 9 - src/test/run-make/c-static-dylib/bar.rs | 15 - src/test/run-make/c-static-dylib/cfoo.c | 2 - src/test/run-make/c-static-dylib/foo.rs | 20 - src/test/run-make/c-static-rlib/Makefile | 8 - src/test/run-make/c-static-rlib/bar.rs | 15 - src/test/run-make/c-static-rlib/cfoo.c | 2 - src/test/run-make/c-static-rlib/foo.rs | 20 - .../run-make/cat-and-grep-sanity-check/Makefile | 46 -- src/test/run-make/cdylib-fewer-symbols/Makefile | 15 - src/test/run-make/cdylib-fewer-symbols/foo.rs | 16 - src/test/run-make/cdylib/Makefile | 19 - src/test/run-make/cdylib/bar.rs | 15 - src/test/run-make/cdylib/foo.c | 20 - src/test/run-make/cdylib/foo.rs | 23 - src/test/run-make/codegen-options-parsing/Makefile | 31 -- src/test/run-make/codegen-options-parsing/dummy.rs | 11 - src/test/run-make/compile-stdin/Makefile | 5 - src/test/run-make/compiler-lookup-paths-2/Makefile | 8 - src/test/run-make/compiler-lookup-paths-2/a.rs | 11 - src/test/run-make/compiler-lookup-paths-2/b.rs | 12 - src/test/run-make/compiler-lookup-paths-2/c.rs | 13 - src/test/run-make/compiler-lookup-paths/Makefile | 38 -- src/test/run-make/compiler-lookup-paths/a.rs | 11 - src/test/run-make/compiler-lookup-paths/b.rs | 12 - src/test/run-make/compiler-lookup-paths/c.rs | 12 - src/test/run-make/compiler-lookup-paths/d.rs | 14 - src/test/run-make/compiler-lookup-paths/e.rs | 12 - src/test/run-make/compiler-lookup-paths/e2.rs | 14 - src/test/run-make/compiler-lookup-paths/f.rs | 12 - src/test/run-make/compiler-lookup-paths/native.c | 9 - .../run-make/compiler-rt-works-on-mingw/Makefile | 17 - .../run-make/compiler-rt-works-on-mingw/foo.cpp | 5 - .../run-make/compiler-rt-works-on-mingw/foo.rs | 16 - src/test/run-make/crate-data-smoke/Makefile | 10 - src/test/run-make/crate-data-smoke/crate.rs | 17 - src/test/run-make/crate-data-smoke/lib.rs | 12 - src/test/run-make/crate-data-smoke/rlib.rs | 12 - src/test/run-make/crate-name-priority/Makefile | 11 - src/test/run-make/crate-name-priority/foo.rs | 11 - src/test/run-make/crate-name-priority/foo1.rs | 13 - src/test/run-make/debug-assertions/Makefile | 25 -- src/test/run-make/debug-assertions/debug.rs | 43 -- .../run-make/dep-info-doesnt-run-much/Makefile | 4 - src/test/run-make/dep-info-doesnt-run-much/foo.rs | 15 - src/test/run-make/dep-info-spaces/Makefile | 28 -- src/test/run-make/dep-info-spaces/Makefile.foo | 7 - src/test/run-make/dep-info-spaces/bar.rs | 11 - src/test/run-make/dep-info-spaces/foo foo.rs | 11 - src/test/run-make/dep-info-spaces/lib.rs | 14 - src/test/run-make/dep-info/Makefile | 34 -- src/test/run-make/dep-info/Makefile.foo | 7 - src/test/run-make/dep-info/bar.rs | 11 - src/test/run-make/dep-info/foo.rs | 11 - src/test/run-make/dep-info/lib.rs | 14 - src/test/run-make/dep-info/lib2.rs | 13 - .../run-make/duplicate-output-flavors/Makefile | 5 - src/test/run-make/duplicate-output-flavors/foo.rs | 11 - src/test/run-make/dylib-chain/Makefile | 12 - src/test/run-make/dylib-chain/m1.rs | 12 - src/test/run-make/dylib-chain/m2.rs | 14 - src/test/run-make/dylib-chain/m3.rs | 14 - src/test/run-make/dylib-chain/m4.rs | 13 - src/test/run-make/emit/Makefile | 21 - src/test/run-make/emit/test-24876.rs | 19 - src/test/run-make/emit/test-26235.rs | 56 --- .../error-found-staticlib-instead-crate/Makefile | 5 - .../error-found-staticlib-instead-crate/bar.rs | 15 - .../error-found-staticlib-instead-crate/foo.rs | 11 - .../run-make/error-writing-dependencies/Makefile | 8 - .../run-make/error-writing-dependencies/foo.rs | 11 - .../run-make/extern-diff-internal-name/Makefile | 5 - src/test/run-make/extern-diff-internal-name/lib.rs | 12 - .../run-make/extern-diff-internal-name/test.rs | 15 - .../run-make/extern-flag-disambiguates/Makefile | 25 -- src/test/run-make/extern-flag-disambiguates/a.rs | 16 - src/test/run-make/extern-flag-disambiguates/b.rs | 19 - src/test/run-make/extern-flag-disambiguates/c.rs | 19 - src/test/run-make/extern-flag-disambiguates/d.rs | 21 - src/test/run-make/extern-flag-fun/Makefile | 17 - src/test/run-make/extern-flag-fun/bar-alt.rs | 11 - src/test/run-make/extern-flag-fun/bar.rs | 9 - src/test/run-make/extern-flag-fun/foo.rs | 13 - src/test/run-make/extern-fn-generic/Makefile | 6 - src/test/run-make/extern-fn-generic/test.c | 17 - src/test/run-make/extern-fn-generic/test.rs | 32 -- src/test/run-make/extern-fn-generic/testcrate.rs | 24 -- src/test/run-make/extern-fn-mangle/Makefile | 5 - src/test/run-make/extern-fn-mangle/test.c | 9 - src/test/run-make/extern-fn-mangle/test.rs | 25 -- src/test/run-make/extern-fn-reachable/Makefile | 9 - src/test/run-make/extern-fn-reachable/dylib.rs | 24 -- src/test/run-make/extern-fn-reachable/main.rs | 28 -- .../run-make/extern-fn-struct-passing-abi/Makefile | 5 - .../run-make/extern-fn-struct-passing-abi/test.c | 324 -------------- .../run-make/extern-fn-struct-passing-abi/test.rs | 144 ------- .../run-make/extern-fn-with-extern-types/Makefile | 5 - .../run-make/extern-fn-with-extern-types/ctest.c | 17 - .../run-make/extern-fn-with-extern-types/test.rs | 27 -- .../run-make/extern-fn-with-packed-struct/Makefile | 5 - .../run-make/extern-fn-with-packed-struct/test.c | 27 -- .../run-make/extern-fn-with-packed-struct/test.rs | 30 -- src/test/run-make/extern-fn-with-union/Makefile | 6 - src/test/run-make/extern-fn-with-union/ctest.c | 11 - src/test/run-make/extern-fn-with-union/test.rs | 33 -- .../run-make/extern-fn-with-union/testcrate.rs | 21 - src/test/run-make/extern-multiple-copies/Makefile | 8 - src/test/run-make/extern-multiple-copies/bar.rs | 16 - src/test/run-make/extern-multiple-copies/foo1.rs | 11 - src/test/run-make/extern-multiple-copies/foo2.rs | 11 - src/test/run-make/extern-multiple-copies2/Makefile | 10 - src/test/run-make/extern-multiple-copies2/bar.rs | 18 - src/test/run-make/extern-multiple-copies2/foo1.rs | 17 - src/test/run-make/extern-multiple-copies2/foo2.rs | 18 - .../extern-overrides-distribution/Makefile | 5 - .../run-make/extern-overrides-distribution/libc.rs | 13 - .../run-make/extern-overrides-distribution/main.rs | 15 - .../extra-filename-with-temp-outputs/Makefile | 6 - .../extra-filename-with-temp-outputs/foo.rs | 11 - src/test/run-make/fpic/Makefile | 13 - src/test/run-make/fpic/hello.rs | 11 - src/test/run-make/hir-tree/Makefile | 8 - src/test/run-make/hir-tree/input.rs | 13 - src/test/run-make/hotplug_codegen_backend/Makefile | 9 - .../run-make/hotplug_codegen_backend/some_crate.rs | 13 - .../hotplug_codegen_backend/the_backend.rs | 82 ---- src/test/run-make/include_bytes_deps/Makefile | 20 - src/test/run-make/include_bytes_deps/input.bin | 1 - src/test/run-make/include_bytes_deps/input.md | 1 - src/test/run-make/include_bytes_deps/input.txt | 1 - src/test/run-make/include_bytes_deps/main.rs | 22 - src/test/run-make/inline-always-many-cgu/Makefile | 8 - src/test/run-make/inline-always-many-cgu/foo.rs | 25 -- .../run-make/interdependent-c-libraries/Makefile | 14 - src/test/run-make/interdependent-c-libraries/bar.c | 4 - .../run-make/interdependent-c-libraries/bar.rs | 22 - src/test/run-make/interdependent-c-libraries/foo.c | 2 - .../run-make/interdependent-c-libraries/foo.rs | 20 - .../run-make/interdependent-c-libraries/main.rs | 16 - src/test/run-make/intrinsic-unreachable/Makefile | 15 - .../run-make/intrinsic-unreachable/exit-ret.rs | 25 -- .../intrinsic-unreachable/exit-unreachable.rs | 27 -- src/test/run-make/invalid-library/Makefile | 6 - src/test/run-make/invalid-library/foo.rs | 13 - src/test/run-make/invalid-staticlib/Makefile | 5 - src/test/run-make/issue-11908/Makefile | 21 - src/test/run-make/issue-11908/bar.rs | 13 - src/test/run-make/issue-11908/foo.rs | 11 - src/test/run-make/issue-14500/Makefile | 17 - src/test/run-make/issue-14500/bar.rs | 11 - src/test/run-make/issue-14500/foo.c | 17 - src/test/run-make/issue-14500/foo.rs | 15 - src/test/run-make/issue-14698/Makefile | 4 - src/test/run-make/issue-14698/foo.rs | 11 - src/test/run-make/issue-15460/Makefile | 6 - src/test/run-make/issue-15460/bar.rs | 14 - src/test/run-make/issue-15460/foo.c | 6 - src/test/run-make/issue-15460/foo.rs | 16 - src/test/run-make/issue-18943/Makefile | 7 - src/test/run-make/issue-18943/foo.rs | 16 - src/test/run-make/issue-19371/Makefile | 9 - src/test/run-make/issue-19371/foo.rs | 88 ---- src/test/run-make/issue-20626/Makefile | 8 - src/test/run-make/issue-20626/foo.rs | 23 - src/test/run-make/issue-22131/Makefile | 7 - src/test/run-make/issue-22131/foo.rs | 15 - src/test/run-make/issue-24445/Makefile | 12 - src/test/run-make/issue-24445/foo.c | 16 - src/test/run-make/issue-24445/foo.rs | 25 -- src/test/run-make/issue-25581/Makefile | 5 - src/test/run-make/issue-25581/test.c | 16 - src/test/run-make/issue-25581/test.rs | 32 -- src/test/run-make/issue-26006/Makefile | 18 - src/test/run-make/issue-26006/in/libc/lib.rs | 12 - src/test/run-make/issue-26006/in/time/lib.rs | 13 - src/test/run-make/issue-26092/Makefile | 4 - src/test/run-make/issue-26092/blank.rs | 11 - src/test/run-make/issue-28595/Makefile | 6 - src/test/run-make/issue-28595/a.c | 11 - src/test/run-make/issue-28595/a.rs | 16 - src/test/run-make/issue-28595/b.c | 16 - src/test/run-make/issue-28595/b.rs | 21 - src/test/run-make/issue-28766/Makefile | 5 - src/test/run-make/issue-28766/foo.rs | 18 - src/test/run-make/issue-28766/main.rs | 17 - src/test/run-make/issue-30063/Makefile | 35 -- src/test/run-make/issue-30063/foo.rs | 11 - src/test/run-make/issue-33329/Makefile | 5 - src/test/run-make/issue-33329/main.rs | 11 - src/test/run-make/issue-35164/Makefile | 4 - src/test/run-make/issue-35164/main.rs | 15 - src/test/run-make/issue-35164/submodule/mod.rs | 13 - src/test/run-make/issue-37839/Makefile | 12 - src/test/run-make/issue-37839/a.rs | 12 - src/test/run-make/issue-37839/b.rs | 12 - src/test/run-make/issue-37839/c.rs | 12 - src/test/run-make/issue-37893/Makefile | 10 - src/test/run-make/issue-37893/a.rs | 12 - src/test/run-make/issue-37893/b.rs | 12 - src/test/run-make/issue-37893/c.rs | 13 - src/test/run-make/issue-38237/Makefile | 11 - src/test/run-make/issue-38237/bar.rs | 14 - src/test/run-make/issue-38237/baz.rs | 18 - src/test/run-make/issue-38237/foo.rs | 19 - src/test/run-make/issue-40535/Makefile | 13 - src/test/run-make/issue-40535/bar.rs | 13 - src/test/run-make/issue-40535/baz.rs | 11 - src/test/run-make/issue-40535/foo.rs | 14 - src/test/run-make/issue-46239/Makefile | 5 - src/test/run-make/issue-46239/main.rs | 18 - src/test/run-make/issue-7349/Makefile | 11 - src/test/run-make/issue-7349/foo.rs | 32 -- src/test/run-make/issues-41478-43796/Makefile | 8 - src/test/run-make/issues-41478-43796/a.rs | 19 - src/test/run-make/libs-and-bins/Makefile | 6 - src/test/run-make/libs-and-bins/foo.rs | 14 - src/test/run-make/libs-through-symlinks/Makefile | 14 - src/test/run-make/libs-through-symlinks/bar.rs | 13 - src/test/run-make/libs-through-symlinks/foo.rs | 12 - src/test/run-make/libtest-json/Makefile | 14 - src/test/run-make/libtest-json/f.rs | 32 -- src/test/run-make/libtest-json/output.json | 10 - src/test/run-make/libtest-json/validate_json.py | 18 - src/test/run-make/link-arg/Makefile | 5 - src/test/run-make/link-arg/empty.rs | 11 - src/test/run-make/link-cfg/Makefile | 22 - src/test/run-make/link-cfg/dep-with-staticlib.rs | 18 - src/test/run-make/link-cfg/dep.rs | 18 - src/test/run-make/link-cfg/no-deps.rs | 30 -- src/test/run-make/link-cfg/return1.c | 16 - src/test/run-make/link-cfg/return2.c | 16 - src/test/run-make/link-cfg/return3.c | 16 - src/test/run-make/link-cfg/with-deps.rs | 24 -- src/test/run-make/link-cfg/with-staticlib-deps.rs | 24 -- src/test/run-make/link-path-order/Makefile | 18 - src/test/run-make/link-path-order/correct.c | 2 - src/test/run-make/link-path-order/main.rs | 28 -- src/test/run-make/link-path-order/wrong.c | 2 - src/test/run-make/linkage-attr-on-static/Makefile | 5 - src/test/run-make/linkage-attr-on-static/bar.rs | 26 -- src/test/run-make/linkage-attr-on-static/foo.c | 8 - src/test/run-make/linker-output-non-utf8/Makefile | 32 -- src/test/run-make/linker-output-non-utf8/exec.rs | 16 - .../run-make/linker-output-non-utf8/library.rs | 20 - src/test/run-make/llvm-pass/Makefile | 28 -- .../run-make/llvm-pass/llvm-function-pass.so.cc | 61 --- src/test/run-make/llvm-pass/llvm-module-pass.so.cc | 60 --- src/test/run-make/llvm-pass/main.rs | 14 - src/test/run-make/llvm-pass/plugin.rs | 28 -- .../long-linker-command-lines-cmd-exe/Makefile | 6 - .../long-linker-command-lines-cmd-exe/foo.bat | 1 - .../long-linker-command-lines-cmd-exe/foo.rs | 111 ----- .../run-make/long-linker-command-lines/Makefile | 5 - src/test/run-make/long-linker-command-lines/foo.rs | 101 ----- src/test/run-make/longjmp-across-rust/Makefile | 5 - src/test/run-make/longjmp-across-rust/foo.c | 28 -- src/test/run-make/longjmp-across-rust/main.rs | 40 -- src/test/run-make/ls-metadata/Makefile | 7 - src/test/run-make/ls-metadata/foo.rs | 11 - src/test/run-make/lto-no-link-whole-rlib/Makefile | 18 - src/test/run-make/lto-no-link-whole-rlib/bar.c | 13 - src/test/run-make/lto-no-link-whole-rlib/foo.c | 13 - src/test/run-make/lto-no-link-whole-rlib/lib1.rs | 20 - src/test/run-make/lto-no-link-whole-rlib/lib2.rs | 23 - src/test/run-make/lto-no-link-whole-rlib/main.rs | 17 - src/test/run-make/lto-readonly-lib/Makefile | 12 - src/test/run-make/lto-readonly-lib/lib.rs | 11 - src/test/run-make/lto-readonly-lib/main.rs | 13 - src/test/run-make/lto-smoke-c/Makefile | 11 - src/test/run-make/lto-smoke-c/bar.c | 7 - src/test/run-make/lto-smoke-c/foo.rs | 14 - src/test/run-make/lto-smoke/Makefile | 6 - src/test/run-make/lto-smoke/lib.rs | 11 - src/test/run-make/lto-smoke/main.rs | 13 - src/test/run-make/manual-crate-name/Makefile | 5 - src/test/run-make/manual-crate-name/bar.rs | 11 - src/test/run-make/manual-link/Makefile | 6 - src/test/run-make/manual-link/bar.c | 2 - src/test/run-make/manual-link/foo.c | 2 - src/test/run-make/manual-link/foo.rs | 19 - src/test/run-make/manual-link/main.rs | 15 - .../run-make/many-crates-but-no-match/Makefile | 36 -- .../run-make/many-crates-but-no-match/crateA1.rs | 14 - .../run-make/many-crates-but-no-match/crateA2.rs | 14 - .../run-make/many-crates-but-no-match/crateA3.rs | 14 - .../run-make/many-crates-but-no-match/crateB.rs | 11 - .../run-make/many-crates-but-no-match/crateC.rs | 13 - .../run-make/metadata-flag-frobs-symbols/Makefile | 10 - .../run-make/metadata-flag-frobs-symbols/bar.rs | 18 - .../run-make/metadata-flag-frobs-symbols/foo.rs | 16 - src/test/run-make/min-global-align/Makefile | 22 - .../run-make/min-global-align/min_global_align.rs | 38 -- .../run-make/mismatching-target-triples/Makefile | 11 - .../run-make/mismatching-target-triples/bar.rs | 13 - .../run-make/mismatching-target-triples/foo.rs | 13 - .../run-make/missing-crate-dependency/Makefile | 9 - .../run-make/missing-crate-dependency/crateA.rs | 12 - .../run-make/missing-crate-dependency/crateB.rs | 11 - .../run-make/missing-crate-dependency/crateC.rs | 13 - src/test/run-make/mixing-deps/Makefile | 7 - src/test/run-make/mixing-deps/both.rs | 14 - src/test/run-make/mixing-deps/dylib.rs | 16 - src/test/run-make/mixing-deps/prog.rs | 19 - src/test/run-make/mixing-formats/Makefile | 74 ---- src/test/run-make/mixing-formats/bar1.rs | 11 - src/test/run-make/mixing-formats/bar2.rs | 11 - src/test/run-make/mixing-formats/baz.rs | 13 - src/test/run-make/mixing-formats/baz2.rs | 14 - src/test/run-make/mixing-formats/foo.rs | 9 - src/test/run-make/mixing-libs/Makefile | 9 - src/test/run-make/mixing-libs/dylib.rs | 14 - src/test/run-make/mixing-libs/prog.rs | 17 - src/test/run-make/mixing-libs/rlib.rs | 12 - src/test/run-make/msvc-opt-minsize/Makefile | 5 - src/test/run-make/msvc-opt-minsize/foo.rs | 29 -- src/test/run-make/multiple-emits/Makefile | 7 - src/test/run-make/multiple-emits/foo.rs | 11 - src/test/run-make/no-builtins-lto/Makefile | 9 - src/test/run-make/no-builtins-lto/main.rs | 13 - src/test/run-make/no-builtins-lto/no_builtins.rs | 12 - src/test/run-make/no-duplicate-libs/Makefile | 10 - src/test/run-make/no-duplicate-libs/bar.c | 15 - src/test/run-make/no-duplicate-libs/foo.c | 11 - src/test/run-make/no-duplicate-libs/main.rs | 20 - src/test/run-make/no-integrated-as/Makefile | 7 - src/test/run-make/no-integrated-as/hello.rs | 13 - src/test/run-make/no-intermediate-extras/Makefile | 7 - src/test/run-make/no-intermediate-extras/foo.rs | 9 - src/test/run-make/obey-crate-type-flag/Makefile | 13 - src/test/run-make/obey-crate-type-flag/test.rs | 12 - .../Makefile | 7 - .../foo.rs | 11 - .../output-filename-overwrites-input/Makefile | 13 - .../output-filename-overwrites-input/bar.rs | 11 - .../output-filename-overwrites-input/foo.rs | 11 - .../run-make/output-type-permutations/Makefile | 146 ------- src/test/run-make/output-type-permutations/foo.rs | 13 - src/test/run-make/output-with-hyphens/Makefile | 6 - src/test/run-make/output-with-hyphens/foo-bar.rs | 14 - src/test/run-make/prefer-dylib/Makefile | 8 - src/test/run-make/prefer-dylib/bar.rs | 11 - src/test/run-make/prefer-dylib/foo.rs | 15 - src/test/run-make/prefer-rlib/Makefile | 8 - src/test/run-make/prefer-rlib/bar.rs | 11 - src/test/run-make/prefer-rlib/foo.rs | 15 - src/test/run-make/pretty-expanded-hygiene/Makefile | 21 - .../run-make/pretty-expanded-hygiene/input.pp.rs | 19 - src/test/run-make/pretty-expanded-hygiene/input.rs | 24 -- src/test/run-make/pretty-expanded/Makefile | 5 - src/test/run-make/pretty-expanded/input.rs | 22 - .../run-make/pretty-print-path-suffix/Makefile | 9 - src/test/run-make/pretty-print-path-suffix/foo.pp | 15 - .../pretty-print-path-suffix/foo_method.pp | 17 - .../run-make/pretty-print-path-suffix/input.rs | 28 -- .../run-make/pretty-print-path-suffix/nest_foo.pp | 14 - src/test/run-make/pretty-print-to-file/Makefile | 5 - src/test/run-make/pretty-print-to-file/input.pp | 13 - src/test/run-make/pretty-print-to-file/input.rs | 15 - src/test/run-make/print-cfg/Makefile | 16 - src/test/run-make/print-target-list/Makefile | 15 - src/test/run-make/profile/Makefile | 9 - src/test/run-make/profile/test.rs | 11 - src/test/run-make/prune-link-args/Makefile | 11 - src/test/run-make/prune-link-args/empty.rs | 11 - src/test/run-make/relocation-model/Makefile | 19 - src/test/run-make/relocation-model/foo.rs | 11 - src/test/run-make/relro-levels/Makefile | 21 - src/test/run-make/relro-levels/hello.rs | 13 - src/test/run-make/reproducible-build/Makefile | 74 ---- src/test/run-make/reproducible-build/linker.rs | 54 --- .../reproducible-build/reproducible-build-aux.rs | 38 -- .../reproducible-build/reproducible-build.rs | 126 ------ src/test/run-make/rlib-chain/Makefile | 10 - src/test/run-make/rlib-chain/m1.rs | 12 - src/test/run-make/rlib-chain/m2.rs | 14 - src/test/run-make/rlib-chain/m3.rs | 14 - src/test/run-make/rlib-chain/m4.rs | 13 - src/test/run-make/rustc-macro-dep-files/Makefile | 12 - src/test/run-make/rustc-macro-dep-files/bar.rs | 19 - src/test/run-make/rustc-macro-dep-files/foo.rs | 22 - src/test/run-make/rustdoc-error-lines/Makefile | 8 - src/test/run-make/rustdoc-error-lines/input.rs | 21 - src/test/run-make/rustdoc-output-path/Makefile | 4 - src/test/run-make/rustdoc-output-path/foo.rs | 11 - src/test/run-make/sanitizer-address/Makefile | 29 -- src/test/run-make/sanitizer-address/overflow.rs | 14 - src/test/run-make/sanitizer-cdylib-link/Makefile | 22 - src/test/run-make/sanitizer-cdylib-link/library.rs | 15 - src/test/run-make/sanitizer-cdylib-link/program.rs | 17 - src/test/run-make/sanitizer-dylib-link/Makefile | 22 - src/test/run-make/sanitizer-dylib-link/library.rs | 15 - src/test/run-make/sanitizer-dylib-link/program.rs | 17 - .../run-make/sanitizer-invalid-cratetype/Makefile | 18 - .../run-make/sanitizer-invalid-cratetype/hello.rs | 13 - .../run-make/sanitizer-invalid-target/Makefile | 5 - .../run-make/sanitizer-invalid-target/hello.rs | 13 - src/test/run-make/sanitizer-leak/Makefile | 16 - src/test/run-make/sanitizer-leak/leak.rs | 16 - src/test/run-make/sanitizer-memory/Makefile | 10 - src/test/run-make/sanitizer-memory/uninit.rs | 16 - .../run-make/sanitizer-staticlib-link/Makefile | 18 - .../run-make/sanitizer-staticlib-link/library.rs | 15 - .../run-make/sanitizer-staticlib-link/program.c | 8 - src/test/run-make/save-analysis-fail/Makefile | 6 - src/test/run-make/save-analysis-fail/SameDir.rs | 15 - src/test/run-make/save-analysis-fail/SameDir3.rs | 13 - src/test/run-make/save-analysis-fail/SubDir/mod.rs | 37 -- src/test/run-make/save-analysis-fail/foo.rs | 468 --------------------- src/test/run-make/save-analysis-fail/krate2.rs | 18 - src/test/run-make/save-analysis/Makefile | 6 - src/test/run-make/save-analysis/SameDir.rs | 15 - src/test/run-make/save-analysis/SameDir3.rs | 13 - src/test/run-make/save-analysis/SubDir/mod.rs | 37 -- src/test/run-make/save-analysis/extra-docs.md | 1 - src/test/run-make/save-analysis/foo.rs | 467 -------------------- src/test/run-make/save-analysis/krate2.rs | 18 - src/test/run-make/sepcomp-cci-copies/Makefile | 12 - src/test/run-make/sepcomp-cci-copies/cci_lib.rs | 16 - src/test/run-make/sepcomp-cci-copies/foo.rs | 35 -- src/test/run-make/sepcomp-inlining/Makefile | 15 - src/test/run-make/sepcomp-inlining/foo.rs | 40 -- src/test/run-make/sepcomp-separate/Makefile | 9 - src/test/run-make/sepcomp-separate/foo.rs | 33 -- src/test/run-make/simd-ffi/Makefile | 47 --- src/test/run-make/simd-ffi/simd.rs | 83 ---- src/test/run-make/simple-dylib/Makefile | 5 - src/test/run-make/simple-dylib/bar.rs | 11 - src/test/run-make/simple-dylib/foo.rs | 15 - src/test/run-make/simple-rlib/Makefile | 5 - src/test/run-make/simple-rlib/bar.rs | 11 - src/test/run-make/simple-rlib/foo.rs | 15 - src/test/run-make/stable-symbol-names/Makefile | 40 -- .../stable-symbol-names/stable-symbol-names1.rs | 41 -- .../stable-symbol-names/stable-symbol-names2.rs | 28 -- src/test/run-make/static-dylib-by-default/Makefile | 16 - src/test/run-make/static-dylib-by-default/bar.rs | 18 - src/test/run-make/static-dylib-by-default/foo.rs | 14 - src/test/run-make/static-dylib-by-default/main.c | 16 - src/test/run-make/static-nobundle/Makefile | 21 - src/test/run-make/static-nobundle/aaa.c | 11 - src/test/run-make/static-nobundle/bbb.rs | 23 - src/test/run-make/static-nobundle/ccc.rs | 23 - src/test/run-make/static-nobundle/ddd.rs | 17 - src/test/run-make/static-unwinding/Makefile | 6 - src/test/run-make/static-unwinding/lib.rs | 25 -- src/test/run-make/static-unwinding/main.rs | 34 -- src/test/run-make/staticlib-blank-lib/Makefile | 6 - src/test/run-make/staticlib-blank-lib/foo.rs | 16 - src/test/run-make/stdin-non-utf8/Makefile | 6 - src/test/run-make/stdin-non-utf8/non-utf8 | 1 - src/test/run-make/suspicious-library/Makefile | 7 - src/test/run-make/suspicious-library/bar.rs | 13 - src/test/run-make/suspicious-library/foo.rs | 13 - src/test/run-make/symbol-visibility/Makefile | 60 --- src/test/run-make/symbol-visibility/a_cdylib.rs | 22 - .../run-make/symbol-visibility/a_rust_dylib.rs | 20 - .../run-make/symbol-visibility/an_executable.rs | 17 - src/test/run-make/symbol-visibility/an_rlib.rs | 16 - src/test/run-make/symbols-are-reasonable/Makefile | 13 - src/test/run-make/symbols-are-reasonable/lib.rs | 21 - .../run-make/symbols-include-type-name/Makefile | 9 - src/test/run-make/symbols-include-type-name/lib.rs | 24 -- src/test/run-make/symlinked-extern/Makefile | 16 - src/test/run-make/symlinked-extern/bar.rs | 16 - src/test/run-make/symlinked-extern/baz.rs | 16 - src/test/run-make/symlinked-extern/foo.rs | 15 - src/test/run-make/symlinked-libraries/Makefile | 15 - src/test/run-make/symlinked-libraries/bar.rs | 15 - src/test/run-make/symlinked-libraries/foo.rs | 13 - src/test/run-make/symlinked-rlib/Makefile | 14 - src/test/run-make/symlinked-rlib/bar.rs | 15 - src/test/run-make/symlinked-rlib/foo.rs | 11 - .../run-make/sysroot-crates-are-unstable/Makefile | 2 - .../run-make/sysroot-crates-are-unstable/test.py | 71 ---- src/test/run-make/target-cpu-native/Makefile | 5 - src/test/run-make/target-cpu-native/foo.rs | 12 - src/test/run-make/target-specs/Makefile | 9 - src/test/run-make/target-specs/foo.rs | 32 -- .../run-make/target-specs/my-awesome-platform.json | 11 - .../target-specs/my-incomplete-platform.json | 10 - .../run-make/target-specs/my-invalid-platform.json | 1 - .../my-x86_64-unknown-linux-gnu-platform.json | 12 - src/test/run-make/target-without-atomics/Makefile | 5 - src/test/run-make/test-harness/Makefile | 8 - src/test/run-make/test-harness/test-ignore-cfg.rs | 19 - src/test/run-make/tools.mk | 134 ------ src/test/run-make/treat-err-as-bug/Makefile | 5 - src/test/run-make/treat-err-as-bug/err.rs | 13 - .../type-mismatch-same-crate-name/Makefile | 19 - .../type-mismatch-same-crate-name/crateA.rs | 26 -- .../type-mismatch-same-crate-name/crateB.rs | 14 - .../type-mismatch-same-crate-name/crateC.rs | 35 -- src/test/run-make/use-extern-for-plugins/Makefile | 21 - src/test/run-make/use-extern-for-plugins/bar.rs | 19 - src/test/run-make/use-extern-for-plugins/baz.rs | 18 - src/test/run-make/use-extern-for-plugins/foo.rs | 18 - src/test/run-make/used/Makefile | 11 - src/test/run-make/used/used.rs | 17 - src/test/run-make/version/Makefile | 6 - src/test/run-make/volatile-intrinsics/Makefile | 9 - src/test/run-make/volatile-intrinsics/main.rs | 27 -- src/test/run-make/wasm-custom-section/Makefile | 10 + src/test/run-make/wasm-custom-section/bar.rs | 24 ++ src/test/run-make/wasm-custom-section/foo.js | 46 ++ src/test/run-make/wasm-custom-section/foo.rs | 19 + src/test/run-make/weird-output-filenames/Makefile | 15 - src/test/run-make/weird-output-filenames/foo.rs | 11 - src/test/run-make/windows-spawn/Makefile | 14 - src/test/run-make/windows-spawn/hello.rs | 13 - src/test/run-make/windows-spawn/spawn.rs | 22 - src/test/run-make/windows-subsystem/Makefile | 5 - src/test/run-make/windows-subsystem/console.rs | 14 - src/test/run-make/windows-subsystem/windows.rs | 13 - src/test/ui/feature-gate-wasm_custom_section.rs | 14 + .../ui/feature-gate-wasm_custom_section.stderr | 11 + src/test/ui/wasm-custom-section/malformed.rs | 19 + src/test/ui/wasm-custom-section/malformed.stderr | 14 + src/test/ui/wasm-custom-section/not-const.rs | 29 ++ src/test/ui/wasm-custom-section/not-const.stderr | 38 ++ src/test/ui/wasm-custom-section/not-slice.rs | 22 + src/test/ui/wasm-custom-section/not-slice.stderr | 20 + src/tools/compiletest/src/runtest.rs | 15 +- 1117 files changed, 11000 insertions(+), 10495 deletions(-) create mode 100644 src/librustc_trans/back/wasm.rs create mode 100644 src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile create mode 100644 src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs create mode 100644 src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs create mode 100644 src/test/run-make-fulldeps/alloc-extern-crates/Makefile create mode 100644 src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs create mode 100644 src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile create mode 100644 src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs create mode 100644 src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile create mode 100644 src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs create mode 100644 src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/Makefile create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/bar.c create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/bar.rs create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/foo.c create mode 100644 src/test/run-make-fulldeps/archive-duplicate-names/foo.rs create mode 100644 src/test/run-make-fulldeps/atomic-lock-free/Makefile create mode 100644 src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs create mode 100644 src/test/run-make-fulldeps/bare-outfile/Makefile create mode 100644 src/test/run-make-fulldeps/bare-outfile/foo.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c create mode 100644 src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-static-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/c-static-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-static-dylib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-static-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/c-static-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/c-static-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/c-static-rlib/cfoo.c create mode 100644 src/test/run-make-fulldeps/c-static-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile create mode 100644 src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile create mode 100644 src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs create mode 100644 src/test/run-make-fulldeps/cdylib/Makefile create mode 100644 src/test/run-make-fulldeps/cdylib/bar.rs create mode 100644 src/test/run-make-fulldeps/cdylib/foo.c create mode 100644 src/test/run-make-fulldeps/cdylib/foo.rs create mode 100644 src/test/run-make-fulldeps/codegen-options-parsing/Makefile create mode 100644 src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs create mode 100644 src/test/run-make-fulldeps/compile-stdin/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/a.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/b.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/c.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/d.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/e.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/f.rs create mode 100644 src/test/run-make-fulldeps/compiler-lookup-paths/native.c create mode 100644 src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile create mode 100644 src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp create mode 100644 src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/Makefile create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/crate.rs create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/lib.rs create mode 100644 src/test/run-make-fulldeps/crate-data-smoke/rlib.rs create mode 100644 src/test/run-make-fulldeps/crate-name-priority/Makefile create mode 100644 src/test/run-make-fulldeps/crate-name-priority/foo.rs create mode 100644 src/test/run-make-fulldeps/crate-name-priority/foo1.rs create mode 100644 src/test/run-make-fulldeps/debug-assertions/Makefile create mode 100644 src/test/run-make-fulldeps/debug-assertions/debug.rs create mode 100644 src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile create mode 100644 src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/Makefile create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/bar.rs create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs create mode 100644 src/test/run-make-fulldeps/dep-info-spaces/lib.rs create mode 100644 src/test/run-make-fulldeps/dep-info/Makefile create mode 100644 src/test/run-make-fulldeps/dep-info/Makefile.foo create mode 100644 src/test/run-make-fulldeps/dep-info/bar.rs create mode 100644 src/test/run-make-fulldeps/dep-info/foo.rs create mode 100644 src/test/run-make-fulldeps/dep-info/lib.rs create mode 100644 src/test/run-make-fulldeps/dep-info/lib2.rs create mode 100644 src/test/run-make-fulldeps/duplicate-output-flavors/Makefile create mode 100644 src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/Makefile create mode 100644 src/test/run-make-fulldeps/dylib-chain/m1.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/m2.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/m3.rs create mode 100644 src/test/run-make-fulldeps/dylib-chain/m4.rs create mode 100644 src/test/run-make-fulldeps/emit/Makefile create mode 100644 src/test/run-make-fulldeps/emit/test-24876.rs create mode 100644 src/test/run-make-fulldeps/emit/test-26235.rs create mode 100644 src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile create mode 100644 src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs create mode 100644 src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs create mode 100644 src/test/run-make-fulldeps/error-writing-dependencies/Makefile create mode 100644 src/test/run-make-fulldeps/error-writing-dependencies/foo.rs create mode 100644 src/test/run-make-fulldeps/extern-diff-internal-name/Makefile create mode 100644 src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs create mode 100644 src/test/run-make-fulldeps/extern-diff-internal-name/test.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/Makefile create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/bar.rs create mode 100644 src/test/run-make-fulldeps/extern-flag-fun/foo.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-mangle/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-mangle/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-mangle/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-reachable/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-reachable/main.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c create mode 100644 src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c create mode 100644 src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/Makefile create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/ctest.c create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/test.rs create mode 100644 src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/Makefile create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/bar.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/Makefile create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs create mode 100644 src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs create mode 100644 src/test/run-make-fulldeps/extern-overrides-distribution/Makefile create mode 100644 src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs create mode 100644 src/test/run-make-fulldeps/extern-overrides-distribution/main.rs create mode 100644 src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile create mode 100644 src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs create mode 100644 src/test/run-make-fulldeps/fpic/Makefile create mode 100644 src/test/run-make-fulldeps/fpic/hello.rs create mode 100644 src/test/run-make-fulldeps/hir-tree/Makefile create mode 100644 src/test/run-make-fulldeps/hir-tree/input.rs create mode 100644 src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile create mode 100644 src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs create mode 100644 src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/Makefile create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/input.bin create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/input.md create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/input.txt create mode 100644 src/test/run-make-fulldeps/include_bytes_deps/main.rs create mode 100644 src/test/run-make-fulldeps/inline-always-many-cgu/Makefile create mode 100644 src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/Makefile create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/bar.c create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/foo.c create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs create mode 100644 src/test/run-make-fulldeps/interdependent-c-libraries/main.rs create mode 100644 src/test/run-make-fulldeps/intrinsic-unreachable/Makefile create mode 100644 src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs create mode 100644 src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs create mode 100644 src/test/run-make-fulldeps/invalid-library/Makefile create mode 100644 src/test/run-make-fulldeps/invalid-library/foo.rs create mode 100644 src/test/run-make-fulldeps/invalid-staticlib/Makefile create mode 100644 src/test/run-make-fulldeps/issue-11908/Makefile create mode 100644 src/test/run-make-fulldeps/issue-11908/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-11908/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-14500/Makefile create mode 100644 src/test/run-make-fulldeps/issue-14500/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-14500/foo.c create mode 100644 src/test/run-make-fulldeps/issue-14500/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-14698/Makefile create mode 100644 src/test/run-make-fulldeps/issue-14698/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-15460/Makefile create mode 100644 src/test/run-make-fulldeps/issue-15460/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-15460/foo.c create mode 100644 src/test/run-make-fulldeps/issue-15460/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-18943/Makefile create mode 100644 src/test/run-make-fulldeps/issue-18943/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-19371/Makefile create mode 100644 src/test/run-make-fulldeps/issue-19371/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-20626/Makefile create mode 100644 src/test/run-make-fulldeps/issue-20626/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-22131/Makefile create mode 100644 src/test/run-make-fulldeps/issue-22131/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-24445/Makefile create mode 100644 src/test/run-make-fulldeps/issue-24445/foo.c create mode 100644 src/test/run-make-fulldeps/issue-24445/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-25581/Makefile create mode 100644 src/test/run-make-fulldeps/issue-25581/test.c create mode 100644 src/test/run-make-fulldeps/issue-25581/test.rs create mode 100644 src/test/run-make-fulldeps/issue-26006/Makefile create mode 100644 src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs create mode 100644 src/test/run-make-fulldeps/issue-26006/in/time/lib.rs create mode 100644 src/test/run-make-fulldeps/issue-26092/Makefile create mode 100644 src/test/run-make-fulldeps/issue-26092/blank.rs create mode 100644 src/test/run-make-fulldeps/issue-28595/Makefile create mode 100644 src/test/run-make-fulldeps/issue-28595/a.c create mode 100644 src/test/run-make-fulldeps/issue-28595/a.rs create mode 100644 src/test/run-make-fulldeps/issue-28595/b.c create mode 100644 src/test/run-make-fulldeps/issue-28595/b.rs create mode 100644 src/test/run-make-fulldeps/issue-28766/Makefile create mode 100644 src/test/run-make-fulldeps/issue-28766/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-28766/main.rs create mode 100644 src/test/run-make-fulldeps/issue-30063/Makefile create mode 100644 src/test/run-make-fulldeps/issue-30063/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-33329/Makefile create mode 100644 src/test/run-make-fulldeps/issue-33329/main.rs create mode 100644 src/test/run-make-fulldeps/issue-35164/Makefile create mode 100644 src/test/run-make-fulldeps/issue-35164/main.rs create mode 100644 src/test/run-make-fulldeps/issue-35164/submodule/mod.rs create mode 100644 src/test/run-make-fulldeps/issue-37839/Makefile create mode 100644 src/test/run-make-fulldeps/issue-37839/a.rs create mode 100644 src/test/run-make-fulldeps/issue-37839/b.rs create mode 100644 src/test/run-make-fulldeps/issue-37839/c.rs create mode 100644 src/test/run-make-fulldeps/issue-37893/Makefile create mode 100644 src/test/run-make-fulldeps/issue-37893/a.rs create mode 100644 src/test/run-make-fulldeps/issue-37893/b.rs create mode 100644 src/test/run-make-fulldeps/issue-37893/c.rs create mode 100644 src/test/run-make-fulldeps/issue-38237/Makefile create mode 100644 src/test/run-make-fulldeps/issue-38237/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-38237/baz.rs create mode 100644 src/test/run-make-fulldeps/issue-38237/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-40535/Makefile create mode 100644 src/test/run-make-fulldeps/issue-40535/bar.rs create mode 100644 src/test/run-make-fulldeps/issue-40535/baz.rs create mode 100644 src/test/run-make-fulldeps/issue-40535/foo.rs create mode 100644 src/test/run-make-fulldeps/issue-46239/Makefile create mode 100644 src/test/run-make-fulldeps/issue-46239/main.rs create mode 100644 src/test/run-make-fulldeps/issue-7349/Makefile create mode 100644 src/test/run-make-fulldeps/issue-7349/foo.rs create mode 100644 src/test/run-make-fulldeps/issues-41478-43796/Makefile create mode 100644 src/test/run-make-fulldeps/issues-41478-43796/a.rs create mode 100644 src/test/run-make-fulldeps/libs-and-bins/Makefile create mode 100644 src/test/run-make-fulldeps/libs-and-bins/foo.rs create mode 100644 src/test/run-make-fulldeps/libs-through-symlinks/Makefile create mode 100644 src/test/run-make-fulldeps/libs-through-symlinks/bar.rs create mode 100644 src/test/run-make-fulldeps/libs-through-symlinks/foo.rs create mode 100644 src/test/run-make-fulldeps/libtest-json/Makefile create mode 100644 src/test/run-make-fulldeps/libtest-json/f.rs create mode 100644 src/test/run-make-fulldeps/libtest-json/output.json create mode 100755 src/test/run-make-fulldeps/libtest-json/validate_json.py create mode 100644 src/test/run-make-fulldeps/link-arg/Makefile create mode 100644 src/test/run-make-fulldeps/link-arg/empty.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/Makefile create mode 100644 src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/dep.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/no-deps.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/return1.c create mode 100644 src/test/run-make-fulldeps/link-cfg/return2.c create mode 100644 src/test/run-make-fulldeps/link-cfg/return3.c create mode 100644 src/test/run-make-fulldeps/link-cfg/with-deps.rs create mode 100644 src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs create mode 100644 src/test/run-make-fulldeps/link-path-order/Makefile create mode 100644 src/test/run-make-fulldeps/link-path-order/correct.c create mode 100644 src/test/run-make-fulldeps/link-path-order/main.rs create mode 100644 src/test/run-make-fulldeps/link-path-order/wrong.c create mode 100644 src/test/run-make-fulldeps/linkage-attr-on-static/Makefile create mode 100644 src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs create mode 100644 src/test/run-make-fulldeps/linkage-attr-on-static/foo.c create mode 100644 src/test/run-make-fulldeps/linker-output-non-utf8/Makefile create mode 100644 src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs create mode 100644 src/test/run-make-fulldeps/linker-output-non-utf8/library.rs create mode 100644 src/test/run-make-fulldeps/llvm-pass/Makefile create mode 100644 src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc create mode 100644 src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc create mode 100644 src/test/run-make-fulldeps/llvm-pass/main.rs create mode 100644 src/test/run-make-fulldeps/llvm-pass/plugin.rs create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines/Makefile create mode 100644 src/test/run-make-fulldeps/long-linker-command-lines/foo.rs create mode 100644 src/test/run-make-fulldeps/longjmp-across-rust/Makefile create mode 100644 src/test/run-make-fulldeps/longjmp-across-rust/foo.c create mode 100644 src/test/run-make-fulldeps/longjmp-across-rust/main.rs create mode 100644 src/test/run-make-fulldeps/ls-metadata/Makefile create mode 100644 src/test/run-make-fulldeps/ls-metadata/foo.rs create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs create mode 100644 src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs create mode 100644 src/test/run-make-fulldeps/lto-readonly-lib/Makefile create mode 100644 src/test/run-make-fulldeps/lto-readonly-lib/lib.rs create mode 100644 src/test/run-make-fulldeps/lto-readonly-lib/main.rs create mode 100644 src/test/run-make-fulldeps/lto-smoke-c/Makefile create mode 100644 src/test/run-make-fulldeps/lto-smoke-c/bar.c create mode 100644 src/test/run-make-fulldeps/lto-smoke-c/foo.rs create mode 100644 src/test/run-make-fulldeps/lto-smoke/Makefile create mode 100644 src/test/run-make-fulldeps/lto-smoke/lib.rs create mode 100644 src/test/run-make-fulldeps/lto-smoke/main.rs create mode 100644 src/test/run-make-fulldeps/manual-crate-name/Makefile create mode 100644 src/test/run-make-fulldeps/manual-crate-name/bar.rs create mode 100644 src/test/run-make-fulldeps/manual-link/Makefile create mode 100644 src/test/run-make-fulldeps/manual-link/bar.c create mode 100644 src/test/run-make-fulldeps/manual-link/foo.c create mode 100644 src/test/run-make-fulldeps/manual-link/foo.rs create mode 100644 src/test/run-make-fulldeps/manual-link/main.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/Makefile create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs create mode 100644 src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs create mode 100644 src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile create mode 100644 src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs create mode 100644 src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs create mode 100644 src/test/run-make-fulldeps/min-global-align/Makefile create mode 100644 src/test/run-make-fulldeps/min-global-align/min_global_align.rs create mode 100644 src/test/run-make-fulldeps/mismatching-target-triples/Makefile create mode 100644 src/test/run-make-fulldeps/mismatching-target-triples/bar.rs create mode 100644 src/test/run-make-fulldeps/mismatching-target-triples/foo.rs create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/Makefile create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs create mode 100644 src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs create mode 100644 src/test/run-make-fulldeps/mixing-deps/Makefile create mode 100644 src/test/run-make-fulldeps/mixing-deps/both.rs create mode 100644 src/test/run-make-fulldeps/mixing-deps/dylib.rs create mode 100644 src/test/run-make-fulldeps/mixing-deps/prog.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/Makefile create mode 100644 src/test/run-make-fulldeps/mixing-formats/bar1.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/bar2.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/baz.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/baz2.rs create mode 100644 src/test/run-make-fulldeps/mixing-formats/foo.rs create mode 100644 src/test/run-make-fulldeps/mixing-libs/Makefile create mode 100644 src/test/run-make-fulldeps/mixing-libs/dylib.rs create mode 100644 src/test/run-make-fulldeps/mixing-libs/prog.rs create mode 100644 src/test/run-make-fulldeps/mixing-libs/rlib.rs create mode 100644 src/test/run-make-fulldeps/msvc-opt-minsize/Makefile create mode 100644 src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs create mode 100644 src/test/run-make-fulldeps/multiple-emits/Makefile create mode 100644 src/test/run-make-fulldeps/multiple-emits/foo.rs create mode 100644 src/test/run-make-fulldeps/no-builtins-lto/Makefile create mode 100644 src/test/run-make-fulldeps/no-builtins-lto/main.rs create mode 100644 src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/Makefile create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/bar.c create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/foo.c create mode 100644 src/test/run-make-fulldeps/no-duplicate-libs/main.rs create mode 100644 src/test/run-make-fulldeps/no-integrated-as/Makefile create mode 100644 src/test/run-make-fulldeps/no-integrated-as/hello.rs create mode 100644 src/test/run-make-fulldeps/no-intermediate-extras/Makefile create mode 100644 src/test/run-make-fulldeps/no-intermediate-extras/foo.rs create mode 100644 src/test/run-make-fulldeps/obey-crate-type-flag/Makefile create mode 100644 src/test/run-make-fulldeps/obey-crate-type-flag/test.rs create mode 100644 src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile create mode 100644 src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs create mode 100644 src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile create mode 100644 src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs create mode 100644 src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs create mode 100644 src/test/run-make-fulldeps/output-type-permutations/Makefile create mode 100644 src/test/run-make-fulldeps/output-type-permutations/foo.rs create mode 100644 src/test/run-make-fulldeps/output-with-hyphens/Makefile create mode 100644 src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs create mode 100644 src/test/run-make-fulldeps/prefer-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/prefer-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/prefer-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/prefer-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/prefer-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/prefer-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs create mode 100644 src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs create mode 100644 src/test/run-make-fulldeps/pretty-expanded/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-expanded/input.rs create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs create mode 100644 src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-to-file/Makefile create mode 100644 src/test/run-make-fulldeps/pretty-print-to-file/input.pp create mode 100644 src/test/run-make-fulldeps/pretty-print-to-file/input.rs create mode 100644 src/test/run-make-fulldeps/print-cfg/Makefile create mode 100644 src/test/run-make-fulldeps/print-target-list/Makefile create mode 100644 src/test/run-make-fulldeps/profile/Makefile create mode 100644 src/test/run-make-fulldeps/profile/test.rs create mode 100644 src/test/run-make-fulldeps/prune-link-args/Makefile create mode 100644 src/test/run-make-fulldeps/prune-link-args/empty.rs create mode 100644 src/test/run-make-fulldeps/relocation-model/Makefile create mode 100644 src/test/run-make-fulldeps/relocation-model/foo.rs create mode 100644 src/test/run-make-fulldeps/relro-levels/Makefile create mode 100644 src/test/run-make-fulldeps/relro-levels/hello.rs create mode 100644 src/test/run-make-fulldeps/reproducible-build/Makefile create mode 100644 src/test/run-make-fulldeps/reproducible-build/linker.rs create mode 100644 src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs create mode 100644 src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/Makefile create mode 100644 src/test/run-make-fulldeps/rlib-chain/m1.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/m2.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/m3.rs create mode 100644 src/test/run-make-fulldeps/rlib-chain/m4.rs create mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile create mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs create mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs create mode 100644 src/test/run-make-fulldeps/rustdoc-error-lines/Makefile create mode 100644 src/test/run-make-fulldeps/rustdoc-error-lines/input.rs create mode 100644 src/test/run-make-fulldeps/rustdoc-output-path/Makefile create mode 100644 src/test/run-make-fulldeps/rustdoc-output-path/foo.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-address/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-address/overflow.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-leak/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-leak/leak.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-memory/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-memory/uninit.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs create mode 100644 src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/Makefile create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/foo.rs create mode 100644 src/test/run-make-fulldeps/save-analysis-fail/krate2.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/Makefile create mode 100644 src/test/run-make-fulldeps/save-analysis/SameDir.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/SameDir3.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/extra-docs.md create mode 100644 src/test/run-make-fulldeps/save-analysis/foo.rs create mode 100644 src/test/run-make-fulldeps/save-analysis/krate2.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile create mode 100644 src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-inlining/Makefile create mode 100644 src/test/run-make-fulldeps/sepcomp-inlining/foo.rs create mode 100644 src/test/run-make-fulldeps/sepcomp-separate/Makefile create mode 100644 src/test/run-make-fulldeps/sepcomp-separate/foo.rs create mode 100644 src/test/run-make-fulldeps/simd-ffi/Makefile create mode 100644 src/test/run-make-fulldeps/simd-ffi/simd.rs create mode 100644 src/test/run-make-fulldeps/simple-dylib/Makefile create mode 100644 src/test/run-make-fulldeps/simple-dylib/bar.rs create mode 100644 src/test/run-make-fulldeps/simple-dylib/foo.rs create mode 100644 src/test/run-make-fulldeps/simple-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/simple-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/simple-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/stable-symbol-names/Makefile create mode 100644 src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs create mode 100644 src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/Makefile create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/bar.rs create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/foo.rs create mode 100644 src/test/run-make-fulldeps/static-dylib-by-default/main.c create mode 100644 src/test/run-make-fulldeps/static-nobundle/Makefile create mode 100644 src/test/run-make-fulldeps/static-nobundle/aaa.c create mode 100644 src/test/run-make-fulldeps/static-nobundle/bbb.rs create mode 100644 src/test/run-make-fulldeps/static-nobundle/ccc.rs create mode 100644 src/test/run-make-fulldeps/static-nobundle/ddd.rs create mode 100644 src/test/run-make-fulldeps/static-unwinding/Makefile create mode 100644 src/test/run-make-fulldeps/static-unwinding/lib.rs create mode 100644 src/test/run-make-fulldeps/static-unwinding/main.rs create mode 100644 src/test/run-make-fulldeps/staticlib-blank-lib/Makefile create mode 100644 src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs create mode 100644 src/test/run-make-fulldeps/stdin-non-utf8/Makefile create mode 100644 src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 create mode 100644 src/test/run-make-fulldeps/suspicious-library/Makefile create mode 100644 src/test/run-make-fulldeps/suspicious-library/bar.rs create mode 100644 src/test/run-make-fulldeps/suspicious-library/foo.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/Makefile create mode 100644 src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/an_executable.rs create mode 100644 src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs create mode 100644 src/test/run-make-fulldeps/symbols-are-reasonable/Makefile create mode 100644 src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs create mode 100644 src/test/run-make-fulldeps/symbols-include-type-name/Makefile create mode 100644 src/test/run-make-fulldeps/symbols-include-type-name/lib.rs create mode 100644 src/test/run-make-fulldeps/symlinked-extern/Makefile create mode 100644 src/test/run-make-fulldeps/symlinked-extern/bar.rs create mode 100644 src/test/run-make-fulldeps/symlinked-extern/baz.rs create mode 100644 src/test/run-make-fulldeps/symlinked-extern/foo.rs create mode 100644 src/test/run-make-fulldeps/symlinked-libraries/Makefile create mode 100644 src/test/run-make-fulldeps/symlinked-libraries/bar.rs create mode 100644 src/test/run-make-fulldeps/symlinked-libraries/foo.rs create mode 100644 src/test/run-make-fulldeps/symlinked-rlib/Makefile create mode 100644 src/test/run-make-fulldeps/symlinked-rlib/bar.rs create mode 100644 src/test/run-make-fulldeps/symlinked-rlib/foo.rs create mode 100644 src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile create mode 100644 src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py create mode 100644 src/test/run-make-fulldeps/target-cpu-native/Makefile create mode 100644 src/test/run-make-fulldeps/target-cpu-native/foo.rs create mode 100644 src/test/run-make-fulldeps/target-specs/Makefile create mode 100644 src/test/run-make-fulldeps/target-specs/foo.rs create mode 100644 src/test/run-make-fulldeps/target-specs/my-awesome-platform.json create mode 100644 src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json create mode 100644 src/test/run-make-fulldeps/target-specs/my-invalid-platform.json create mode 100644 src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json create mode 100644 src/test/run-make-fulldeps/target-without-atomics/Makefile create mode 100644 src/test/run-make-fulldeps/test-harness/Makefile create mode 100644 src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs create mode 100644 src/test/run-make-fulldeps/tools.mk create mode 100644 src/test/run-make-fulldeps/treat-err-as-bug/Makefile create mode 100644 src/test/run-make-fulldeps/treat-err-as-bug/err.rs create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs create mode 100644 src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/Makefile create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs create mode 100644 src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs create mode 100644 src/test/run-make-fulldeps/used/Makefile create mode 100644 src/test/run-make-fulldeps/used/used.rs create mode 100644 src/test/run-make-fulldeps/version/Makefile create mode 100644 src/test/run-make-fulldeps/volatile-intrinsics/Makefile create mode 100644 src/test/run-make-fulldeps/volatile-intrinsics/main.rs create mode 100644 src/test/run-make-fulldeps/weird-output-filenames/Makefile create mode 100644 src/test/run-make-fulldeps/weird-output-filenames/foo.rs create mode 100644 src/test/run-make-fulldeps/windows-spawn/Makefile create mode 100644 src/test/run-make-fulldeps/windows-spawn/hello.rs create mode 100644 src/test/run-make-fulldeps/windows-spawn/spawn.rs create mode 100644 src/test/run-make-fulldeps/windows-subsystem/Makefile create mode 100644 src/test/run-make-fulldeps/windows-subsystem/console.rs create mode 100644 src/test/run-make-fulldeps/windows-subsystem/windows.rs delete mode 100644 src/test/run-make/a-b-a-linker-guard/Makefile delete mode 100644 src/test/run-make/a-b-a-linker-guard/a.rs delete mode 100644 src/test/run-make/a-b-a-linker-guard/b.rs delete mode 100644 src/test/run-make/alloc-extern-crates/Makefile delete mode 100644 src/test/run-make/alloc-extern-crates/fakealloc.rs delete mode 100644 src/test/run-make/allow-non-lint-warnings-cmdline/Makefile delete mode 100644 src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs delete mode 100644 src/test/run-make/allow-warnings-cmdline-stability/Makefile delete mode 100644 src/test/run-make/allow-warnings-cmdline-stability/bar.rs delete mode 100644 src/test/run-make/allow-warnings-cmdline-stability/foo.rs delete mode 100644 src/test/run-make/archive-duplicate-names/Makefile delete mode 100644 src/test/run-make/archive-duplicate-names/bar.c delete mode 100644 src/test/run-make/archive-duplicate-names/bar.rs delete mode 100644 src/test/run-make/archive-duplicate-names/foo.c delete mode 100644 src/test/run-make/archive-duplicate-names/foo.rs delete mode 100644 src/test/run-make/atomic-lock-free/Makefile delete mode 100644 src/test/run-make/atomic-lock-free/atomic_lock_free.rs delete mode 100644 src/test/run-make/bare-outfile/Makefile delete mode 100644 src/test/run-make/bare-outfile/foo.rs delete mode 100644 src/test/run-make/c-dynamic-dylib/Makefile delete mode 100644 src/test/run-make/c-dynamic-dylib/bar.rs delete mode 100644 src/test/run-make/c-dynamic-dylib/cfoo.c delete mode 100644 src/test/run-make/c-dynamic-dylib/foo.rs delete mode 100644 src/test/run-make/c-dynamic-rlib/Makefile delete mode 100644 src/test/run-make/c-dynamic-rlib/bar.rs delete mode 100644 src/test/run-make/c-dynamic-rlib/cfoo.c delete mode 100644 src/test/run-make/c-dynamic-rlib/foo.rs delete mode 100644 src/test/run-make/c-link-to-rust-dylib/Makefile delete mode 100644 src/test/run-make/c-link-to-rust-dylib/bar.c delete mode 100644 src/test/run-make/c-link-to-rust-dylib/foo.rs delete mode 100644 src/test/run-make/c-link-to-rust-staticlib/Makefile delete mode 100644 src/test/run-make/c-link-to-rust-staticlib/bar.c delete mode 100644 src/test/run-make/c-link-to-rust-staticlib/foo.rs delete mode 100644 src/test/run-make/c-static-dylib/Makefile delete mode 100644 src/test/run-make/c-static-dylib/bar.rs delete mode 100644 src/test/run-make/c-static-dylib/cfoo.c delete mode 100644 src/test/run-make/c-static-dylib/foo.rs delete mode 100644 src/test/run-make/c-static-rlib/Makefile delete mode 100644 src/test/run-make/c-static-rlib/bar.rs delete mode 100644 src/test/run-make/c-static-rlib/cfoo.c delete mode 100644 src/test/run-make/c-static-rlib/foo.rs delete mode 100644 src/test/run-make/cat-and-grep-sanity-check/Makefile delete mode 100644 src/test/run-make/cdylib-fewer-symbols/Makefile delete mode 100644 src/test/run-make/cdylib-fewer-symbols/foo.rs delete mode 100644 src/test/run-make/cdylib/Makefile delete mode 100644 src/test/run-make/cdylib/bar.rs delete mode 100644 src/test/run-make/cdylib/foo.c delete mode 100644 src/test/run-make/cdylib/foo.rs delete mode 100644 src/test/run-make/codegen-options-parsing/Makefile delete mode 100644 src/test/run-make/codegen-options-parsing/dummy.rs delete mode 100644 src/test/run-make/compile-stdin/Makefile delete mode 100644 src/test/run-make/compiler-lookup-paths-2/Makefile delete mode 100644 src/test/run-make/compiler-lookup-paths-2/a.rs delete mode 100644 src/test/run-make/compiler-lookup-paths-2/b.rs delete mode 100644 src/test/run-make/compiler-lookup-paths-2/c.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/Makefile delete mode 100644 src/test/run-make/compiler-lookup-paths/a.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/b.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/c.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/d.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/e.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/e2.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/f.rs delete mode 100644 src/test/run-make/compiler-lookup-paths/native.c delete mode 100644 src/test/run-make/compiler-rt-works-on-mingw/Makefile delete mode 100644 src/test/run-make/compiler-rt-works-on-mingw/foo.cpp delete mode 100644 src/test/run-make/compiler-rt-works-on-mingw/foo.rs delete mode 100644 src/test/run-make/crate-data-smoke/Makefile delete mode 100644 src/test/run-make/crate-data-smoke/crate.rs delete mode 100644 src/test/run-make/crate-data-smoke/lib.rs delete mode 100644 src/test/run-make/crate-data-smoke/rlib.rs delete mode 100644 src/test/run-make/crate-name-priority/Makefile delete mode 100644 src/test/run-make/crate-name-priority/foo.rs delete mode 100644 src/test/run-make/crate-name-priority/foo1.rs delete mode 100644 src/test/run-make/debug-assertions/Makefile delete mode 100644 src/test/run-make/debug-assertions/debug.rs delete mode 100644 src/test/run-make/dep-info-doesnt-run-much/Makefile delete mode 100644 src/test/run-make/dep-info-doesnt-run-much/foo.rs delete mode 100644 src/test/run-make/dep-info-spaces/Makefile delete mode 100644 src/test/run-make/dep-info-spaces/Makefile.foo delete mode 100644 src/test/run-make/dep-info-spaces/bar.rs delete mode 100644 src/test/run-make/dep-info-spaces/foo foo.rs delete mode 100644 src/test/run-make/dep-info-spaces/lib.rs delete mode 100644 src/test/run-make/dep-info/Makefile delete mode 100644 src/test/run-make/dep-info/Makefile.foo delete mode 100644 src/test/run-make/dep-info/bar.rs delete mode 100644 src/test/run-make/dep-info/foo.rs delete mode 100644 src/test/run-make/dep-info/lib.rs delete mode 100644 src/test/run-make/dep-info/lib2.rs delete mode 100644 src/test/run-make/duplicate-output-flavors/Makefile delete mode 100644 src/test/run-make/duplicate-output-flavors/foo.rs delete mode 100644 src/test/run-make/dylib-chain/Makefile delete mode 100644 src/test/run-make/dylib-chain/m1.rs delete mode 100644 src/test/run-make/dylib-chain/m2.rs delete mode 100644 src/test/run-make/dylib-chain/m3.rs delete mode 100644 src/test/run-make/dylib-chain/m4.rs delete mode 100644 src/test/run-make/emit/Makefile delete mode 100644 src/test/run-make/emit/test-24876.rs delete mode 100644 src/test/run-make/emit/test-26235.rs delete mode 100644 src/test/run-make/error-found-staticlib-instead-crate/Makefile delete mode 100644 src/test/run-make/error-found-staticlib-instead-crate/bar.rs delete mode 100644 src/test/run-make/error-found-staticlib-instead-crate/foo.rs delete mode 100644 src/test/run-make/error-writing-dependencies/Makefile delete mode 100644 src/test/run-make/error-writing-dependencies/foo.rs delete mode 100644 src/test/run-make/extern-diff-internal-name/Makefile delete mode 100644 src/test/run-make/extern-diff-internal-name/lib.rs delete mode 100644 src/test/run-make/extern-diff-internal-name/test.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/Makefile delete mode 100644 src/test/run-make/extern-flag-disambiguates/a.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/b.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/c.rs delete mode 100644 src/test/run-make/extern-flag-disambiguates/d.rs delete mode 100644 src/test/run-make/extern-flag-fun/Makefile delete mode 100644 src/test/run-make/extern-flag-fun/bar-alt.rs delete mode 100644 src/test/run-make/extern-flag-fun/bar.rs delete mode 100644 src/test/run-make/extern-flag-fun/foo.rs delete mode 100644 src/test/run-make/extern-fn-generic/Makefile delete mode 100644 src/test/run-make/extern-fn-generic/test.c delete mode 100644 src/test/run-make/extern-fn-generic/test.rs delete mode 100644 src/test/run-make/extern-fn-generic/testcrate.rs delete mode 100644 src/test/run-make/extern-fn-mangle/Makefile delete mode 100644 src/test/run-make/extern-fn-mangle/test.c delete mode 100644 src/test/run-make/extern-fn-mangle/test.rs delete mode 100644 src/test/run-make/extern-fn-reachable/Makefile delete mode 100644 src/test/run-make/extern-fn-reachable/dylib.rs delete mode 100644 src/test/run-make/extern-fn-reachable/main.rs delete mode 100644 src/test/run-make/extern-fn-struct-passing-abi/Makefile delete mode 100644 src/test/run-make/extern-fn-struct-passing-abi/test.c delete mode 100644 src/test/run-make/extern-fn-struct-passing-abi/test.rs delete mode 100644 src/test/run-make/extern-fn-with-extern-types/Makefile delete mode 100644 src/test/run-make/extern-fn-with-extern-types/ctest.c delete mode 100644 src/test/run-make/extern-fn-with-extern-types/test.rs delete mode 100644 src/test/run-make/extern-fn-with-packed-struct/Makefile delete mode 100644 src/test/run-make/extern-fn-with-packed-struct/test.c delete mode 100644 src/test/run-make/extern-fn-with-packed-struct/test.rs delete mode 100644 src/test/run-make/extern-fn-with-union/Makefile delete mode 100644 src/test/run-make/extern-fn-with-union/ctest.c delete mode 100644 src/test/run-make/extern-fn-with-union/test.rs delete mode 100644 src/test/run-make/extern-fn-with-union/testcrate.rs delete mode 100644 src/test/run-make/extern-multiple-copies/Makefile delete mode 100644 src/test/run-make/extern-multiple-copies/bar.rs delete mode 100644 src/test/run-make/extern-multiple-copies/foo1.rs delete mode 100644 src/test/run-make/extern-multiple-copies/foo2.rs delete mode 100644 src/test/run-make/extern-multiple-copies2/Makefile delete mode 100644 src/test/run-make/extern-multiple-copies2/bar.rs delete mode 100644 src/test/run-make/extern-multiple-copies2/foo1.rs delete mode 100644 src/test/run-make/extern-multiple-copies2/foo2.rs delete mode 100644 src/test/run-make/extern-overrides-distribution/Makefile delete mode 100644 src/test/run-make/extern-overrides-distribution/libc.rs delete mode 100644 src/test/run-make/extern-overrides-distribution/main.rs delete mode 100644 src/test/run-make/extra-filename-with-temp-outputs/Makefile delete mode 100644 src/test/run-make/extra-filename-with-temp-outputs/foo.rs delete mode 100644 src/test/run-make/fpic/Makefile delete mode 100644 src/test/run-make/fpic/hello.rs delete mode 100644 src/test/run-make/hir-tree/Makefile delete mode 100644 src/test/run-make/hir-tree/input.rs delete mode 100644 src/test/run-make/hotplug_codegen_backend/Makefile delete mode 100644 src/test/run-make/hotplug_codegen_backend/some_crate.rs delete mode 100644 src/test/run-make/hotplug_codegen_backend/the_backend.rs delete mode 100644 src/test/run-make/include_bytes_deps/Makefile delete mode 100644 src/test/run-make/include_bytes_deps/input.bin delete mode 100644 src/test/run-make/include_bytes_deps/input.md delete mode 100644 src/test/run-make/include_bytes_deps/input.txt delete mode 100644 src/test/run-make/include_bytes_deps/main.rs delete mode 100644 src/test/run-make/inline-always-many-cgu/Makefile delete mode 100644 src/test/run-make/inline-always-many-cgu/foo.rs delete mode 100644 src/test/run-make/interdependent-c-libraries/Makefile delete mode 100644 src/test/run-make/interdependent-c-libraries/bar.c delete mode 100644 src/test/run-make/interdependent-c-libraries/bar.rs delete mode 100644 src/test/run-make/interdependent-c-libraries/foo.c delete mode 100644 src/test/run-make/interdependent-c-libraries/foo.rs delete mode 100644 src/test/run-make/interdependent-c-libraries/main.rs delete mode 100644 src/test/run-make/intrinsic-unreachable/Makefile delete mode 100644 src/test/run-make/intrinsic-unreachable/exit-ret.rs delete mode 100644 src/test/run-make/intrinsic-unreachable/exit-unreachable.rs delete mode 100644 src/test/run-make/invalid-library/Makefile delete mode 100644 src/test/run-make/invalid-library/foo.rs delete mode 100644 src/test/run-make/invalid-staticlib/Makefile delete mode 100644 src/test/run-make/issue-11908/Makefile delete mode 100644 src/test/run-make/issue-11908/bar.rs delete mode 100644 src/test/run-make/issue-11908/foo.rs delete mode 100644 src/test/run-make/issue-14500/Makefile delete mode 100644 src/test/run-make/issue-14500/bar.rs delete mode 100644 src/test/run-make/issue-14500/foo.c delete mode 100644 src/test/run-make/issue-14500/foo.rs delete mode 100644 src/test/run-make/issue-14698/Makefile delete mode 100644 src/test/run-make/issue-14698/foo.rs delete mode 100644 src/test/run-make/issue-15460/Makefile delete mode 100644 src/test/run-make/issue-15460/bar.rs delete mode 100644 src/test/run-make/issue-15460/foo.c delete mode 100644 src/test/run-make/issue-15460/foo.rs delete mode 100644 src/test/run-make/issue-18943/Makefile delete mode 100644 src/test/run-make/issue-18943/foo.rs delete mode 100644 src/test/run-make/issue-19371/Makefile delete mode 100644 src/test/run-make/issue-19371/foo.rs delete mode 100644 src/test/run-make/issue-20626/Makefile delete mode 100644 src/test/run-make/issue-20626/foo.rs delete mode 100644 src/test/run-make/issue-22131/Makefile delete mode 100644 src/test/run-make/issue-22131/foo.rs delete mode 100644 src/test/run-make/issue-24445/Makefile delete mode 100644 src/test/run-make/issue-24445/foo.c delete mode 100644 src/test/run-make/issue-24445/foo.rs delete mode 100644 src/test/run-make/issue-25581/Makefile delete mode 100644 src/test/run-make/issue-25581/test.c delete mode 100644 src/test/run-make/issue-25581/test.rs delete mode 100644 src/test/run-make/issue-26006/Makefile delete mode 100644 src/test/run-make/issue-26006/in/libc/lib.rs delete mode 100644 src/test/run-make/issue-26006/in/time/lib.rs delete mode 100644 src/test/run-make/issue-26092/Makefile delete mode 100644 src/test/run-make/issue-26092/blank.rs delete mode 100644 src/test/run-make/issue-28595/Makefile delete mode 100644 src/test/run-make/issue-28595/a.c delete mode 100644 src/test/run-make/issue-28595/a.rs delete mode 100644 src/test/run-make/issue-28595/b.c delete mode 100644 src/test/run-make/issue-28595/b.rs delete mode 100644 src/test/run-make/issue-28766/Makefile delete mode 100644 src/test/run-make/issue-28766/foo.rs delete mode 100644 src/test/run-make/issue-28766/main.rs delete mode 100644 src/test/run-make/issue-30063/Makefile delete mode 100644 src/test/run-make/issue-30063/foo.rs delete mode 100644 src/test/run-make/issue-33329/Makefile delete mode 100644 src/test/run-make/issue-33329/main.rs delete mode 100644 src/test/run-make/issue-35164/Makefile delete mode 100644 src/test/run-make/issue-35164/main.rs delete mode 100644 src/test/run-make/issue-35164/submodule/mod.rs delete mode 100644 src/test/run-make/issue-37839/Makefile delete mode 100644 src/test/run-make/issue-37839/a.rs delete mode 100644 src/test/run-make/issue-37839/b.rs delete mode 100644 src/test/run-make/issue-37839/c.rs delete mode 100644 src/test/run-make/issue-37893/Makefile delete mode 100644 src/test/run-make/issue-37893/a.rs delete mode 100644 src/test/run-make/issue-37893/b.rs delete mode 100644 src/test/run-make/issue-37893/c.rs delete mode 100644 src/test/run-make/issue-38237/Makefile delete mode 100644 src/test/run-make/issue-38237/bar.rs delete mode 100644 src/test/run-make/issue-38237/baz.rs delete mode 100644 src/test/run-make/issue-38237/foo.rs delete mode 100644 src/test/run-make/issue-40535/Makefile delete mode 100644 src/test/run-make/issue-40535/bar.rs delete mode 100644 src/test/run-make/issue-40535/baz.rs delete mode 100644 src/test/run-make/issue-40535/foo.rs delete mode 100644 src/test/run-make/issue-46239/Makefile delete mode 100644 src/test/run-make/issue-46239/main.rs delete mode 100644 src/test/run-make/issue-7349/Makefile delete mode 100644 src/test/run-make/issue-7349/foo.rs delete mode 100644 src/test/run-make/issues-41478-43796/Makefile delete mode 100644 src/test/run-make/issues-41478-43796/a.rs delete mode 100644 src/test/run-make/libs-and-bins/Makefile delete mode 100644 src/test/run-make/libs-and-bins/foo.rs delete mode 100644 src/test/run-make/libs-through-symlinks/Makefile delete mode 100644 src/test/run-make/libs-through-symlinks/bar.rs delete mode 100644 src/test/run-make/libs-through-symlinks/foo.rs delete mode 100644 src/test/run-make/libtest-json/Makefile delete mode 100644 src/test/run-make/libtest-json/f.rs delete mode 100644 src/test/run-make/libtest-json/output.json delete mode 100755 src/test/run-make/libtest-json/validate_json.py delete mode 100644 src/test/run-make/link-arg/Makefile delete mode 100644 src/test/run-make/link-arg/empty.rs delete mode 100644 src/test/run-make/link-cfg/Makefile delete mode 100644 src/test/run-make/link-cfg/dep-with-staticlib.rs delete mode 100644 src/test/run-make/link-cfg/dep.rs delete mode 100644 src/test/run-make/link-cfg/no-deps.rs delete mode 100644 src/test/run-make/link-cfg/return1.c delete mode 100644 src/test/run-make/link-cfg/return2.c delete mode 100644 src/test/run-make/link-cfg/return3.c delete mode 100644 src/test/run-make/link-cfg/with-deps.rs delete mode 100644 src/test/run-make/link-cfg/with-staticlib-deps.rs delete mode 100644 src/test/run-make/link-path-order/Makefile delete mode 100644 src/test/run-make/link-path-order/correct.c delete mode 100644 src/test/run-make/link-path-order/main.rs delete mode 100644 src/test/run-make/link-path-order/wrong.c delete mode 100644 src/test/run-make/linkage-attr-on-static/Makefile delete mode 100644 src/test/run-make/linkage-attr-on-static/bar.rs delete mode 100644 src/test/run-make/linkage-attr-on-static/foo.c delete mode 100644 src/test/run-make/linker-output-non-utf8/Makefile delete mode 100644 src/test/run-make/linker-output-non-utf8/exec.rs delete mode 100644 src/test/run-make/linker-output-non-utf8/library.rs delete mode 100644 src/test/run-make/llvm-pass/Makefile delete mode 100644 src/test/run-make/llvm-pass/llvm-function-pass.so.cc delete mode 100644 src/test/run-make/llvm-pass/llvm-module-pass.so.cc delete mode 100644 src/test/run-make/llvm-pass/main.rs delete mode 100644 src/test/run-make/llvm-pass/plugin.rs delete mode 100644 src/test/run-make/long-linker-command-lines-cmd-exe/Makefile delete mode 100644 src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat delete mode 100644 src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs delete mode 100644 src/test/run-make/long-linker-command-lines/Makefile delete mode 100644 src/test/run-make/long-linker-command-lines/foo.rs delete mode 100644 src/test/run-make/longjmp-across-rust/Makefile delete mode 100644 src/test/run-make/longjmp-across-rust/foo.c delete mode 100644 src/test/run-make/longjmp-across-rust/main.rs delete mode 100644 src/test/run-make/ls-metadata/Makefile delete mode 100644 src/test/run-make/ls-metadata/foo.rs delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/Makefile delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/bar.c delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/foo.c delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/lib1.rs delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/lib2.rs delete mode 100644 src/test/run-make/lto-no-link-whole-rlib/main.rs delete mode 100644 src/test/run-make/lto-readonly-lib/Makefile delete mode 100644 src/test/run-make/lto-readonly-lib/lib.rs delete mode 100644 src/test/run-make/lto-readonly-lib/main.rs delete mode 100644 src/test/run-make/lto-smoke-c/Makefile delete mode 100644 src/test/run-make/lto-smoke-c/bar.c delete mode 100644 src/test/run-make/lto-smoke-c/foo.rs delete mode 100644 src/test/run-make/lto-smoke/Makefile delete mode 100644 src/test/run-make/lto-smoke/lib.rs delete mode 100644 src/test/run-make/lto-smoke/main.rs delete mode 100644 src/test/run-make/manual-crate-name/Makefile delete mode 100644 src/test/run-make/manual-crate-name/bar.rs delete mode 100644 src/test/run-make/manual-link/Makefile delete mode 100644 src/test/run-make/manual-link/bar.c delete mode 100644 src/test/run-make/manual-link/foo.c delete mode 100644 src/test/run-make/manual-link/foo.rs delete mode 100644 src/test/run-make/manual-link/main.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/Makefile delete mode 100644 src/test/run-make/many-crates-but-no-match/crateA1.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateA2.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateA3.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateB.rs delete mode 100644 src/test/run-make/many-crates-but-no-match/crateC.rs delete mode 100644 src/test/run-make/metadata-flag-frobs-symbols/Makefile delete mode 100644 src/test/run-make/metadata-flag-frobs-symbols/bar.rs delete mode 100644 src/test/run-make/metadata-flag-frobs-symbols/foo.rs delete mode 100644 src/test/run-make/min-global-align/Makefile delete mode 100644 src/test/run-make/min-global-align/min_global_align.rs delete mode 100644 src/test/run-make/mismatching-target-triples/Makefile delete mode 100644 src/test/run-make/mismatching-target-triples/bar.rs delete mode 100644 src/test/run-make/mismatching-target-triples/foo.rs delete mode 100644 src/test/run-make/missing-crate-dependency/Makefile delete mode 100644 src/test/run-make/missing-crate-dependency/crateA.rs delete mode 100644 src/test/run-make/missing-crate-dependency/crateB.rs delete mode 100644 src/test/run-make/missing-crate-dependency/crateC.rs delete mode 100644 src/test/run-make/mixing-deps/Makefile delete mode 100644 src/test/run-make/mixing-deps/both.rs delete mode 100644 src/test/run-make/mixing-deps/dylib.rs delete mode 100644 src/test/run-make/mixing-deps/prog.rs delete mode 100644 src/test/run-make/mixing-formats/Makefile delete mode 100644 src/test/run-make/mixing-formats/bar1.rs delete mode 100644 src/test/run-make/mixing-formats/bar2.rs delete mode 100644 src/test/run-make/mixing-formats/baz.rs delete mode 100644 src/test/run-make/mixing-formats/baz2.rs delete mode 100644 src/test/run-make/mixing-formats/foo.rs delete mode 100644 src/test/run-make/mixing-libs/Makefile delete mode 100644 src/test/run-make/mixing-libs/dylib.rs delete mode 100644 src/test/run-make/mixing-libs/prog.rs delete mode 100644 src/test/run-make/mixing-libs/rlib.rs delete mode 100644 src/test/run-make/msvc-opt-minsize/Makefile delete mode 100644 src/test/run-make/msvc-opt-minsize/foo.rs delete mode 100644 src/test/run-make/multiple-emits/Makefile delete mode 100644 src/test/run-make/multiple-emits/foo.rs delete mode 100644 src/test/run-make/no-builtins-lto/Makefile delete mode 100644 src/test/run-make/no-builtins-lto/main.rs delete mode 100644 src/test/run-make/no-builtins-lto/no_builtins.rs delete mode 100644 src/test/run-make/no-duplicate-libs/Makefile delete mode 100644 src/test/run-make/no-duplicate-libs/bar.c delete mode 100644 src/test/run-make/no-duplicate-libs/foo.c delete mode 100644 src/test/run-make/no-duplicate-libs/main.rs delete mode 100644 src/test/run-make/no-integrated-as/Makefile delete mode 100644 src/test/run-make/no-integrated-as/hello.rs delete mode 100644 src/test/run-make/no-intermediate-extras/Makefile delete mode 100644 src/test/run-make/no-intermediate-extras/foo.rs delete mode 100644 src/test/run-make/obey-crate-type-flag/Makefile delete mode 100644 src/test/run-make/obey-crate-type-flag/test.rs delete mode 100644 src/test/run-make/output-filename-conflicts-with-directory/Makefile delete mode 100644 src/test/run-make/output-filename-conflicts-with-directory/foo.rs delete mode 100644 src/test/run-make/output-filename-overwrites-input/Makefile delete mode 100644 src/test/run-make/output-filename-overwrites-input/bar.rs delete mode 100644 src/test/run-make/output-filename-overwrites-input/foo.rs delete mode 100644 src/test/run-make/output-type-permutations/Makefile delete mode 100644 src/test/run-make/output-type-permutations/foo.rs delete mode 100644 src/test/run-make/output-with-hyphens/Makefile delete mode 100644 src/test/run-make/output-with-hyphens/foo-bar.rs delete mode 100644 src/test/run-make/prefer-dylib/Makefile delete mode 100644 src/test/run-make/prefer-dylib/bar.rs delete mode 100644 src/test/run-make/prefer-dylib/foo.rs delete mode 100644 src/test/run-make/prefer-rlib/Makefile delete mode 100644 src/test/run-make/prefer-rlib/bar.rs delete mode 100644 src/test/run-make/prefer-rlib/foo.rs delete mode 100644 src/test/run-make/pretty-expanded-hygiene/Makefile delete mode 100644 src/test/run-make/pretty-expanded-hygiene/input.pp.rs delete mode 100644 src/test/run-make/pretty-expanded-hygiene/input.rs delete mode 100644 src/test/run-make/pretty-expanded/Makefile delete mode 100644 src/test/run-make/pretty-expanded/input.rs delete mode 100644 src/test/run-make/pretty-print-path-suffix/Makefile delete mode 100644 src/test/run-make/pretty-print-path-suffix/foo.pp delete mode 100644 src/test/run-make/pretty-print-path-suffix/foo_method.pp delete mode 100644 src/test/run-make/pretty-print-path-suffix/input.rs delete mode 100644 src/test/run-make/pretty-print-path-suffix/nest_foo.pp delete mode 100644 src/test/run-make/pretty-print-to-file/Makefile delete mode 100644 src/test/run-make/pretty-print-to-file/input.pp delete mode 100644 src/test/run-make/pretty-print-to-file/input.rs delete mode 100644 src/test/run-make/print-cfg/Makefile delete mode 100644 src/test/run-make/print-target-list/Makefile delete mode 100644 src/test/run-make/profile/Makefile delete mode 100644 src/test/run-make/profile/test.rs delete mode 100644 src/test/run-make/prune-link-args/Makefile delete mode 100644 src/test/run-make/prune-link-args/empty.rs delete mode 100644 src/test/run-make/relocation-model/Makefile delete mode 100644 src/test/run-make/relocation-model/foo.rs delete mode 100644 src/test/run-make/relro-levels/Makefile delete mode 100644 src/test/run-make/relro-levels/hello.rs delete mode 100644 src/test/run-make/reproducible-build/Makefile delete mode 100644 src/test/run-make/reproducible-build/linker.rs delete mode 100644 src/test/run-make/reproducible-build/reproducible-build-aux.rs delete mode 100644 src/test/run-make/reproducible-build/reproducible-build.rs delete mode 100644 src/test/run-make/rlib-chain/Makefile delete mode 100644 src/test/run-make/rlib-chain/m1.rs delete mode 100644 src/test/run-make/rlib-chain/m2.rs delete mode 100644 src/test/run-make/rlib-chain/m3.rs delete mode 100644 src/test/run-make/rlib-chain/m4.rs delete mode 100644 src/test/run-make/rustc-macro-dep-files/Makefile delete mode 100644 src/test/run-make/rustc-macro-dep-files/bar.rs delete mode 100644 src/test/run-make/rustc-macro-dep-files/foo.rs delete mode 100644 src/test/run-make/rustdoc-error-lines/Makefile delete mode 100644 src/test/run-make/rustdoc-error-lines/input.rs delete mode 100644 src/test/run-make/rustdoc-output-path/Makefile delete mode 100644 src/test/run-make/rustdoc-output-path/foo.rs delete mode 100644 src/test/run-make/sanitizer-address/Makefile delete mode 100644 src/test/run-make/sanitizer-address/overflow.rs delete mode 100644 src/test/run-make/sanitizer-cdylib-link/Makefile delete mode 100644 src/test/run-make/sanitizer-cdylib-link/library.rs delete mode 100644 src/test/run-make/sanitizer-cdylib-link/program.rs delete mode 100644 src/test/run-make/sanitizer-dylib-link/Makefile delete mode 100644 src/test/run-make/sanitizer-dylib-link/library.rs delete mode 100644 src/test/run-make/sanitizer-dylib-link/program.rs delete mode 100644 src/test/run-make/sanitizer-invalid-cratetype/Makefile delete mode 100644 src/test/run-make/sanitizer-invalid-cratetype/hello.rs delete mode 100644 src/test/run-make/sanitizer-invalid-target/Makefile delete mode 100644 src/test/run-make/sanitizer-invalid-target/hello.rs delete mode 100644 src/test/run-make/sanitizer-leak/Makefile delete mode 100644 src/test/run-make/sanitizer-leak/leak.rs delete mode 100644 src/test/run-make/sanitizer-memory/Makefile delete mode 100644 src/test/run-make/sanitizer-memory/uninit.rs delete mode 100644 src/test/run-make/sanitizer-staticlib-link/Makefile delete mode 100644 src/test/run-make/sanitizer-staticlib-link/library.rs delete mode 100644 src/test/run-make/sanitizer-staticlib-link/program.c delete mode 100644 src/test/run-make/save-analysis-fail/Makefile delete mode 100644 src/test/run-make/save-analysis-fail/SameDir.rs delete mode 100644 src/test/run-make/save-analysis-fail/SameDir3.rs delete mode 100644 src/test/run-make/save-analysis-fail/SubDir/mod.rs delete mode 100644 src/test/run-make/save-analysis-fail/foo.rs delete mode 100644 src/test/run-make/save-analysis-fail/krate2.rs delete mode 100644 src/test/run-make/save-analysis/Makefile delete mode 100644 src/test/run-make/save-analysis/SameDir.rs delete mode 100644 src/test/run-make/save-analysis/SameDir3.rs delete mode 100644 src/test/run-make/save-analysis/SubDir/mod.rs delete mode 100644 src/test/run-make/save-analysis/extra-docs.md delete mode 100644 src/test/run-make/save-analysis/foo.rs delete mode 100644 src/test/run-make/save-analysis/krate2.rs delete mode 100644 src/test/run-make/sepcomp-cci-copies/Makefile delete mode 100644 src/test/run-make/sepcomp-cci-copies/cci_lib.rs delete mode 100644 src/test/run-make/sepcomp-cci-copies/foo.rs delete mode 100644 src/test/run-make/sepcomp-inlining/Makefile delete mode 100644 src/test/run-make/sepcomp-inlining/foo.rs delete mode 100644 src/test/run-make/sepcomp-separate/Makefile delete mode 100644 src/test/run-make/sepcomp-separate/foo.rs delete mode 100644 src/test/run-make/simd-ffi/Makefile delete mode 100644 src/test/run-make/simd-ffi/simd.rs delete mode 100644 src/test/run-make/simple-dylib/Makefile delete mode 100644 src/test/run-make/simple-dylib/bar.rs delete mode 100644 src/test/run-make/simple-dylib/foo.rs delete mode 100644 src/test/run-make/simple-rlib/Makefile delete mode 100644 src/test/run-make/simple-rlib/bar.rs delete mode 100644 src/test/run-make/simple-rlib/foo.rs delete mode 100644 src/test/run-make/stable-symbol-names/Makefile delete mode 100644 src/test/run-make/stable-symbol-names/stable-symbol-names1.rs delete mode 100644 src/test/run-make/stable-symbol-names/stable-symbol-names2.rs delete mode 100644 src/test/run-make/static-dylib-by-default/Makefile delete mode 100644 src/test/run-make/static-dylib-by-default/bar.rs delete mode 100644 src/test/run-make/static-dylib-by-default/foo.rs delete mode 100644 src/test/run-make/static-dylib-by-default/main.c delete mode 100644 src/test/run-make/static-nobundle/Makefile delete mode 100644 src/test/run-make/static-nobundle/aaa.c delete mode 100644 src/test/run-make/static-nobundle/bbb.rs delete mode 100644 src/test/run-make/static-nobundle/ccc.rs delete mode 100644 src/test/run-make/static-nobundle/ddd.rs delete mode 100644 src/test/run-make/static-unwinding/Makefile delete mode 100644 src/test/run-make/static-unwinding/lib.rs delete mode 100644 src/test/run-make/static-unwinding/main.rs delete mode 100644 src/test/run-make/staticlib-blank-lib/Makefile delete mode 100644 src/test/run-make/staticlib-blank-lib/foo.rs delete mode 100644 src/test/run-make/stdin-non-utf8/Makefile delete mode 100644 src/test/run-make/stdin-non-utf8/non-utf8 delete mode 100644 src/test/run-make/suspicious-library/Makefile delete mode 100644 src/test/run-make/suspicious-library/bar.rs delete mode 100644 src/test/run-make/suspicious-library/foo.rs delete mode 100644 src/test/run-make/symbol-visibility/Makefile delete mode 100644 src/test/run-make/symbol-visibility/a_cdylib.rs delete mode 100644 src/test/run-make/symbol-visibility/a_rust_dylib.rs delete mode 100644 src/test/run-make/symbol-visibility/an_executable.rs delete mode 100644 src/test/run-make/symbol-visibility/an_rlib.rs delete mode 100644 src/test/run-make/symbols-are-reasonable/Makefile delete mode 100644 src/test/run-make/symbols-are-reasonable/lib.rs delete mode 100644 src/test/run-make/symbols-include-type-name/Makefile delete mode 100644 src/test/run-make/symbols-include-type-name/lib.rs delete mode 100644 src/test/run-make/symlinked-extern/Makefile delete mode 100644 src/test/run-make/symlinked-extern/bar.rs delete mode 100644 src/test/run-make/symlinked-extern/baz.rs delete mode 100644 src/test/run-make/symlinked-extern/foo.rs delete mode 100644 src/test/run-make/symlinked-libraries/Makefile delete mode 100644 src/test/run-make/symlinked-libraries/bar.rs delete mode 100644 src/test/run-make/symlinked-libraries/foo.rs delete mode 100644 src/test/run-make/symlinked-rlib/Makefile delete mode 100644 src/test/run-make/symlinked-rlib/bar.rs delete mode 100644 src/test/run-make/symlinked-rlib/foo.rs delete mode 100644 src/test/run-make/sysroot-crates-are-unstable/Makefile delete mode 100644 src/test/run-make/sysroot-crates-are-unstable/test.py delete mode 100644 src/test/run-make/target-cpu-native/Makefile delete mode 100644 src/test/run-make/target-cpu-native/foo.rs delete mode 100644 src/test/run-make/target-specs/Makefile delete mode 100644 src/test/run-make/target-specs/foo.rs delete mode 100644 src/test/run-make/target-specs/my-awesome-platform.json delete mode 100644 src/test/run-make/target-specs/my-incomplete-platform.json delete mode 100644 src/test/run-make/target-specs/my-invalid-platform.json delete mode 100644 src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json delete mode 100644 src/test/run-make/target-without-atomics/Makefile delete mode 100644 src/test/run-make/test-harness/Makefile delete mode 100644 src/test/run-make/test-harness/test-ignore-cfg.rs delete mode 100644 src/test/run-make/tools.mk delete mode 100644 src/test/run-make/treat-err-as-bug/Makefile delete mode 100644 src/test/run-make/treat-err-as-bug/err.rs delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/Makefile delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/crateA.rs delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/crateB.rs delete mode 100644 src/test/run-make/type-mismatch-same-crate-name/crateC.rs delete mode 100644 src/test/run-make/use-extern-for-plugins/Makefile delete mode 100644 src/test/run-make/use-extern-for-plugins/bar.rs delete mode 100644 src/test/run-make/use-extern-for-plugins/baz.rs delete mode 100644 src/test/run-make/use-extern-for-plugins/foo.rs delete mode 100644 src/test/run-make/used/Makefile delete mode 100644 src/test/run-make/used/used.rs delete mode 100644 src/test/run-make/version/Makefile delete mode 100644 src/test/run-make/volatile-intrinsics/Makefile delete mode 100644 src/test/run-make/volatile-intrinsics/main.rs create mode 100644 src/test/run-make/wasm-custom-section/Makefile create mode 100644 src/test/run-make/wasm-custom-section/bar.rs create mode 100644 src/test/run-make/wasm-custom-section/foo.js create mode 100644 src/test/run-make/wasm-custom-section/foo.rs delete mode 100644 src/test/run-make/weird-output-filenames/Makefile delete mode 100644 src/test/run-make/weird-output-filenames/foo.rs delete mode 100644 src/test/run-make/windows-spawn/Makefile delete mode 100644 src/test/run-make/windows-spawn/hello.rs delete mode 100644 src/test/run-make/windows-spawn/spawn.rs delete mode 100644 src/test/run-make/windows-subsystem/Makefile delete mode 100644 src/test/run-make/windows-subsystem/console.rs delete mode 100644 src/test/run-make/windows-subsystem/windows.rs create mode 100644 src/test/ui/feature-gate-wasm_custom_section.rs create mode 100644 src/test/ui/feature-gate-wasm_custom_section.stderr create mode 100644 src/test/ui/wasm-custom-section/malformed.rs create mode 100644 src/test/ui/wasm-custom-section/malformed.stderr create mode 100644 src/test/ui/wasm-custom-section/not-const.rs create mode 100644 src/test/ui/wasm-custom-section/not-const.stderr create mode 100644 src/test/ui/wasm-custom-section/not-slice.rs create mode 100644 src/test/ui/wasm-custom-section/not-slice.stderr diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a398bcc9737..2e094a88982 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -313,6 +313,7 @@ impl<'a> Builder<'a> { test::RunPassFullDepsPretty, test::RunFailFullDepsPretty, test::Crate, test::CrateLibrustc, test::CrateRustdoc, test::Linkcheck, test::Cargotest, test::Cargo, test::Rls, test::ErrorIndex, test::Distcheck, + test::RunMakeFullDeps, test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample, test::TheBook, test::UnstableBook, test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme, diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 86263c8fa07..2640248373c 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -915,7 +915,7 @@ impl Step for Assemble { } } - let lld_install = if build.config.lld_enabled && target_compiler.stage > 0 { + let lld_install = if build.config.lld_enabled { Some(builder.ensure(native::Lld { target: target_compiler.host, })) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index de938ec8e83..6c19da4648a 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -759,12 +759,18 @@ test!(RunFailFullDepsPretty { host: true }); -host_test!(RunMake { +default_test!(RunMake { path: "src/test/run-make", mode: "run-make", suite: "run-make" }); +host_test!(RunMakeFullDeps { + path: "src/test/run-make-fulldeps", + mode: "run-make", + suite: "run-make-fulldeps" +}); + #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] struct Compiletest { compiler: Compiler, @@ -827,8 +833,7 @@ impl Step for Compiletest { // FIXME: Does pretty need librustc compiled? Note that there are // fulldeps test suites with mode = pretty as well. mode == "pretty" || - mode == "rustdoc" || - mode == "run-make" { + mode == "rustdoc" { builder.ensure(compile::Rustc { compiler, target }); } @@ -849,7 +854,7 @@ impl Step for Compiletest { cmd.arg("--rustc-path").arg(builder.rustc(compiler)); // Avoid depending on rustdoc when we don't need it. - if mode == "rustdoc" || mode == "run-make" { + if mode == "rustdoc" || (mode == "run-make" && suite.ends_with("fulldeps")) { cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler.host)); } @@ -931,7 +936,7 @@ impl Step for Compiletest { // Only pass correct values for these flags for the `run-make` suite as it // requires that a C++ compiler was configured which isn't always the case. - if suite == "run-make" { + if suite == "run-make-fulldeps" { let llvm_components = output(Command::new(&llvm_config).arg("--components")); let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags")); cmd.arg("--cc").arg(build.cc(target)) @@ -944,12 +949,12 @@ impl Step for Compiletest { } } } - if suite == "run-make" && !build.config.llvm_enabled { + if suite == "run-make-fulldeps" && !build.config.llvm_enabled { println!("Ignoring run-make test suite as they generally don't work without LLVM"); return; } - if suite != "run-make" { + if suite != "run-make-fulldeps" { cmd.arg("--cc").arg("") .arg("--cxx").arg("") .arg("--cflags").arg("") diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 1e2e4e5a69f..09d7ce599ab 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -650,6 +650,8 @@ define_dep_nodes!( <'tcx> [] GetSymbolExportLevel(DefId), + [] WasmCustomSections(CrateNum), + [input] Features, [] ProgramClausesFor(DefId), diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index d7194e9c2ca..f141cac1614 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -25,6 +25,7 @@ enum Target { Struct, Union, Enum, + Const, Other, } @@ -35,6 +36,7 @@ impl Target { hir::ItemStruct(..) => Target::Struct, hir::ItemUnion(..) => Target::Union, hir::ItemEnum(..) => Target::Enum, + hir::ItemConst(..) => Target::Const, _ => Target::Other, } } @@ -60,6 +62,17 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { if name == "inline" { self.check_inline(attr, item, target) } + + if name == "wasm_custom_section" { + if target != Target::Const { + self.tcx.sess.span_err(attr.span, "only allowed on consts"); + } + + if attr.value_str().is_none() { + self.tcx.sess.span_err(attr.span, "must be of the form \ + #[wasm_custom_section = \"foo\"]"); + } + } } } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 1ff9c7a8629..abd52624c30 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -318,6 +318,11 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt, return true; } + // These constants are special for wasm + if attr::contains_name(attrs, "wasm_custom_section") { + return true; + } + tcx.lint_level_at_node(lint::builtin::DEAD_CODE, id).0 == lint::Allow } diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 117d9219312..0b41c3ab2fa 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -678,6 +678,12 @@ impl<'tcx> QueryDescription<'tcx> for queries::instance_def_size_estimate<'tcx> } } +impl<'tcx> QueryDescription<'tcx> for queries::wasm_custom_sections<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("custom wasm sections for a crate") + } +} + impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> { #[inline] fn cache_on_disk(def_id: Self::Key) -> bool { diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 6c3b4efb932..2b4c1992762 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -424,6 +424,8 @@ define_maps! { <'tcx> [] fn features_query: features_node(CrateNum) -> Lrc, [] fn program_clauses_for: ProgramClausesFor(DefId) -> Lrc>>, + + [] fn wasm_custom_sections: WasmCustomSections(CrateNum) -> Lrc>, } ////////////////////////////////////////////////////////////////////// diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 4170fa76797..910c00b832e 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -940,6 +940,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::Features => { force!(features_query, LOCAL_CRATE); } DepKind::ProgramClausesFor => { force!(program_clauses_for, def_id!()); } + DepKind::WasmCustomSections => { force!(wasm_custom_sections, krate!()); } } true diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 2de27f3a1c3..3c2f984ef8b 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -271,6 +271,8 @@ provide! { <'tcx> tcx, def_id, other, cdata, Arc::new(cdata.exported_symbols()) } + + wasm_custom_sections => { Lrc::new(cdata.wasm_custom_sections()) } } pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index b0c945fbf2a..0e5df3142af 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1067,6 +1067,16 @@ impl<'a, 'tcx> CrateMetadata { .collect() } + pub fn wasm_custom_sections(&self) -> Vec { + let sections = self.root + .wasm_custom_sections + .decode(self) + .map(|def_index| self.local_def_id(def_index)) + .collect::>(); + info!("loaded wasm sections {:?}", sections); + return sections + } + pub fn get_macro(&self, id: DefIndex) -> (InternedString, MacroDef) { let entry = self.entry(id); match entry.kind { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 6b3453f2c99..56981b8f4a1 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -435,6 +435,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { &exported_symbols); let exported_symbols_bytes = self.position() - i; + // encode wasm custom sections + let wasm_custom_sections = self.tcx.wasm_custom_sections(LOCAL_CRATE); + let wasm_custom_sections = self.tracked( + IsolatedEncoder::encode_wasm_custom_sections, + &wasm_custom_sections); + // Encode and index the items. i = self.position(); let items = self.encode_info_for_items(); @@ -478,6 +484,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { def_path_table, impls, exported_symbols, + wasm_custom_sections, index, }); @@ -1444,6 +1451,11 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { .cloned()) } + fn encode_wasm_custom_sections(&mut self, statics: &[DefId]) -> LazySeq { + info!("encoding custom wasm section constants {:?}", statics); + self.lazy_seq(statics.iter().map(|id| id.index)) + } + fn encode_dylib_dependency_formats(&mut self, _: ()) -> LazySeq> { match self.tcx.sess.dependency_formats.borrow().get(&config::CrateTypeDylib) { Some(arr) => { diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 593f08e90bb..001772623e7 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -204,6 +204,7 @@ pub struct CrateRoot { pub def_path_table: Lazy, pub impls: LazySeq, pub exported_symbols: LazySeq<(ExportedSymbol, SymbolExportLevel)>, + pub wasm_custom_sections: LazySeq, pub index: LazySeq, } diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs index 040d9455334..16253aa92ac 100644 --- a/src/librustc_trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -11,9 +11,11 @@ use std::ffi::{CStr, CString}; -use rustc::hir::TransFnAttrFlags; +use rustc::hir::{self, TransFnAttrFlags}; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; +use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::session::config::Sanitizer; +use rustc::ty::TyCtxt; use rustc::ty::maps::Providers; use rustc_data_structures::sync::Lrc; @@ -161,4 +163,32 @@ pub fn provide(providers: &mut Providers) { .collect()) } }; + + providers.wasm_custom_sections = |tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + let mut finder = WasmSectionFinder { tcx, list: Vec::new() }; + tcx.hir.krate().visit_all_item_likes(&mut finder); + Lrc::new(finder.list) + }; +} + +struct WasmSectionFinder<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + list: Vec, +} + +impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for WasmSectionFinder<'a, 'tcx> { + fn visit_item(&mut self, i: &'tcx hir::Item) { + match i.node { + hir::ItemConst(..) => {} + _ => return, + } + if i.attrs.iter().any(|i| i.check_name("wasm_custom_section")) { + self.list.push(self.tcx.hir.local_def_id(i.id)); + } + } + + fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) {} + + fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) {} } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index bdda7741221..8e8ba823b6f 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use back::wasm; use cc::windows_registry; use super::archive::{ArchiveBuilder, ArchiveConfig}; use super::bytecode::RLIB_BYTECODE_EXTENSION; @@ -810,6 +811,11 @@ fn link_natively(sess: &Session, Err(e) => sess.fatal(&format!("failed to run dsymutil: {}", e)), } } + + if sess.opts.target_triple == "wasm32-unknown-unknown" { + wasm::add_custom_sections(&out_filename, + &trans.crate_info.wasm_custom_sections); + } } fn exec_linker(sess: &Session, cmd: &mut Command, tmpdir: &Path) diff --git a/src/librustc_trans/back/wasm.rs b/src/librustc_trans/back/wasm.rs new file mode 100644 index 00000000000..99f1e4b7e78 --- /dev/null +++ b/src/librustc_trans/back/wasm.rs @@ -0,0 +1,44 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fs; +use std::path::Path; +use std::collections::BTreeMap; + +use serialize::leb128; + +pub fn add_custom_sections(path: &Path, sections: &BTreeMap>) { + let mut wasm = fs::read(path).expect("failed to read wasm output"); + + // see https://webassembly.github.io/spec/core/binary/modules.html#custom-section + for (section, bytes) in sections { + // write the `id` identifier, 0 for a custom section + let len = wasm.len(); + leb128::write_u32_leb128(&mut wasm, len, 0); + + // figure out how long our name descriptor will be + let mut name = Vec::new(); + leb128::write_u32_leb128(&mut name, 0, section.len() as u32); + name.extend_from_slice(section.as_bytes()); + + // write the length of the payload + let len = wasm.len(); + let total_len = bytes.len() + name.len(); + leb128::write_u32_leb128(&mut wasm, len, total_len as u32); + + // write out the name section + wasm.extend(name); + + // and now the payload itself + wasm.extend_from_slice(bytes); + } + + fs::write(path, &wasm).expect("failed to write wasm output"); +} diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 4da082e9d50..11f952bc5bc 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -74,6 +74,7 @@ use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; use CrateInfo; use std::any::Any; +use std::collections::BTreeMap; use std::ffi::CString; use std::str; use std::sync::Arc; @@ -1070,8 +1071,24 @@ impl CrateInfo { used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic), used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), used_crate_source: FxHashMap(), + wasm_custom_sections: BTreeMap::new(), }; + let load_wasm_sections = tcx.sess.crate_types.borrow() + .iter() + .any(|c| *c != config::CrateTypeRlib) && + tcx.sess.opts.target_triple == "wasm32-unknown-unknown"; + + if load_wasm_sections { + info!("attempting to load all wasm sections"); + for &id in tcx.wasm_custom_sections(LOCAL_CRATE).iter() { + let (name, contents) = fetch_wasm_section(tcx, id); + info.wasm_custom_sections.entry(name) + .or_insert(Vec::new()) + .extend(contents); + } + } + for &cnum in tcx.crates().iter() { info.native_libraries.insert(cnum, tcx.native_libraries(cnum)); info.crate_name.insert(cnum, tcx.crate_name(cnum).to_string()); @@ -1091,6 +1108,14 @@ impl CrateInfo { if tcx.is_no_builtins(cnum) { info.is_no_builtins.insert(cnum); } + if load_wasm_sections { + for &id in tcx.wasm_custom_sections(cnum).iter() { + let (name, contents) = fetch_wasm_section(tcx, id); + info.wasm_custom_sections.entry(name) + .or_insert(Vec::new()) + .extend(contents); + } + } } @@ -1270,3 +1295,44 @@ mod temp_stable_hash_impls { } } } + +fn fetch_wasm_section(tcx: TyCtxt, id: DefId) -> (String, Vec) { + use rustc::mir::interpret::{GlobalId, Value, PrimVal}; + use rustc::middle::const_val::ConstVal; + + info!("loading wasm section {:?}", id); + + let section = tcx.get_attrs(id) + .iter() + .find(|a| a.check_name("wasm_custom_section")) + .expect("missing #[wasm_custom_section] attribute") + .value_str() + .expect("malformed #[wasm_custom_section] attribute"); + + let instance = ty::Instance::mono(tcx, id); + let cid = GlobalId { + instance, + promoted: None + }; + let param_env = ty::ParamEnv::reveal_all(); + let val = tcx.const_eval(param_env.and(cid)).unwrap(); + + let val = match val.val { + ConstVal::Value(val) => val, + ConstVal::Unevaluated(..) => bug!("should be evaluated"), + }; + let val = match val { + Value::ByRef(ptr, _align) => ptr.into_inner_primval(), + ref v => bug!("should be ByRef, was {:?}", v), + }; + let mem = match val { + PrimVal::Ptr(mem) => mem, + ref v => bug!("should be Ptr, was {:?}", v), + }; + assert_eq!(mem.offset, 0); + let alloc = tcx + .interpret_interner + .get_alloc(mem.alloc_id) + .expect("miri allocation never successfully created"); + (section.to_string(), alloc.bytes.clone()) +} diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 337f85a3813..bb2aeca3748 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -72,6 +72,7 @@ pub use llvm_util::target_features; use std::any::Any; use std::path::PathBuf; use std::sync::mpsc; +use std::collections::BTreeMap; use rustc_data_structures::sync::Lrc; use rustc::dep_graph::DepGraph; @@ -98,6 +99,7 @@ mod back { pub mod symbol_export; pub mod write; mod rpath; + mod wasm; } mod abi; @@ -400,6 +402,7 @@ struct CrateInfo { used_crate_source: FxHashMap>, used_crates_static: Vec<(CrateNum, LibSource)>, used_crates_dynamic: Vec<(CrateNum, LibSource)>, + wasm_custom_sections: BTreeMap>, } __build_diagnostic_array! { librustc_trans, DIAGNOSTICS } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 69879bbe85d..f86fe1fb756 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1182,9 +1182,15 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item let _indenter = indenter(); match it.node { // Consts can play a role in type-checking, so they are included here. - hir::ItemStatic(..) | + hir::ItemStatic(..) => { + tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); + } hir::ItemConst(..) => { tcx.typeck_tables_of(tcx.hir.local_def_id(it.id)); + if it.attrs.iter().any(|a| a.check_name("wasm_custom_section")) { + let def_id = tcx.hir.local_def_id(it.id); + check_const_is_u8_array(tcx, def_id, it.span); + } } hir::ItemEnum(ref enum_definition, _) => { check_enum(tcx, @@ -1256,6 +1262,21 @@ pub fn check_item_type<'a,'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Item } } +fn check_const_is_u8_array<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, + span: Span) { + match tcx.type_of(def_id).sty { + ty::TyArray(t, _) => { + match t.sty { + ty::TyUint(ast::UintTy::U8) => return, + _ => {} + } + } + _ => {} + } + tcx.sess.span_err(span, "must be an array of bytes like `[u8; N]`"); +} + fn check_on_unimplemented<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_def_id: DefId, item: &hir::Item) { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 915396d29fe..dbcfee208ca 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -451,6 +451,9 @@ declare_features! ( // `use path as _;` and `extern crate c as _;` (active, underscore_imports, "1.26.0", Some(48216), None), + + // The #[wasm_custom_section] attribute + (active, wasm_custom_section, "1.26.0", None, None), ); declare_features! ( @@ -1004,6 +1007,11 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "never will be stable", cfg_fn!(rustc_attrs))), + ("wasm_custom_section", Whitelisted, Gated(Stability::Unstable, + "wasm_custom_section", + "attribute is currently unstable", + cfg_fn!(wasm_custom_section))), + // Crate level attributes ("crate_name", CrateLevel, Ungated), ("crate_type", CrateLevel, Ungated), diff --git a/src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile b/src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile new file mode 100644 index 00000000000..0962ebfbff5 --- /dev/null +++ b/src/test/run-make-fulldeps/a-b-a-linker-guard/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +# Test that if we build `b` against a version of `a` that has one set +# of types, it will not run with a dylib that has a different set of +# types. + +all: + $(RUSTC) a.rs --cfg x -C prefer-dynamic + $(RUSTC) b.rs -C prefer-dynamic + $(call RUN,b) + $(RUSTC) a.rs --cfg y -C prefer-dynamic + $(call FAIL,b) diff --git a/src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs b/src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs new file mode 100644 index 00000000000..c6680a78819 --- /dev/null +++ b/src/test/run-make-fulldeps/a-b-a-linker-guard/a.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "a"] +#![crate_type = "dylib"] + +#[cfg(x)] +pub fn foo(x: u32) { } + +#[cfg(y)] +pub fn foo(x: i32) { } diff --git a/src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs b/src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs new file mode 100644 index 00000000000..89fd48de5bb --- /dev/null +++ b/src/test/run-make-fulldeps/a-b-a-linker-guard/b.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "b"] + +extern crate a; + +fn main() { + a::foo(22_u32); +} diff --git a/src/test/run-make-fulldeps/alloc-extern-crates/Makefile b/src/test/run-make-fulldeps/alloc-extern-crates/Makefile new file mode 100644 index 00000000000..7197f4e17e3 --- /dev/null +++ b/src/test/run-make-fulldeps/alloc-extern-crates/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) fakealloc.rs + $(RUSTC) --crate-type=rlib ../../../liballoc/lib.rs --cfg feature=\"external_crate\" --extern external=$(TMPDIR)/$(shell $(RUSTC) --print file-names fakealloc.rs) diff --git a/src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs b/src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs new file mode 100644 index 00000000000..43f97489314 --- /dev/null +++ b/src/test/run-make-fulldeps/alloc-extern-crates/fakealloc.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![no_std] + +#[inline] +pub unsafe fn allocate(_size: usize, _align: usize) -> *mut u8 { 0 as *mut u8 } + +#[inline] +pub unsafe fn deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) { } + +#[inline] +pub unsafe fn reallocate(_ptr: *mut u8, _old_size: usize, _size: usize, _align: usize) -> *mut u8 { + 0 as *mut u8 +} + +#[inline] +pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize, + _align: usize) -> usize { old_size } + +#[inline] +pub fn usable_size(size: usize, _align: usize) -> usize { size } + +#[inline] +pub fn stats_print() { } diff --git a/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile new file mode 100644 index 00000000000..c14006cc2e0 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Test that -A warnings makes the 'empty trait list for derive' warning go away +OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) + +all: foo + test -z '$(OUT)' + +# This is just to make sure the above command actually succeeds +foo: + $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs new file mode 100644 index 00000000000..a9e18f5a8f1 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-non-lint-warnings-cmdline/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive()] +#[derive(Copy, Clone)] +pub struct Foo; + +pub fn main() { } diff --git a/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile new file mode 100644 index 00000000000..3eecaf93142 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# Test that -A warnings makes the 'empty trait list for derive' warning go away +DEP=$(shell $(RUSTC) bar.rs) +OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) + +all: foo bar + test -z '$(OUT)' + +# These are just to ensure that the above commands actually work +bar: + $(RUSTC) bar.rs + +foo: bar + $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs new file mode 100644 index 00000000000..fed1405b7f4 --- /dev/null +++ b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![feature(staged_api)] +#![unstable(feature = "test_feature", issue = "0")] + +pub fn baz() { } diff --git a/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs new file mode 100644 index 00000000000..a36cc474c2b --- /dev/null +++ b/src/test/run-make-fulldeps/allow-warnings-cmdline-stability/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test_feature)] + +extern crate bar; + +pub fn main() { bar::baz() } diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/Makefile b/src/test/run-make-fulldeps/archive-duplicate-names/Makefile new file mode 100644 index 00000000000..93711c41d79 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +all: + mkdir $(TMPDIR)/a + mkdir $(TMPDIR)/b + $(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c) + $(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c) + $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/bar.c b/src/test/run-make-fulldeps/archive-duplicate-names/bar.c new file mode 100644 index 00000000000..a25fa10f4d3 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/bar.c @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void bar() {} diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/bar.rs b/src/test/run-make-fulldeps/archive-duplicate-names/bar.rs new file mode 100644 index 00000000000..1200a6de8e2 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::baz(); +} diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/foo.c b/src/test/run-make-fulldeps/archive-duplicate-names/foo.c new file mode 100644 index 00000000000..61d5d154078 --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/foo.c @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo() {} diff --git a/src/test/run-make-fulldeps/archive-duplicate-names/foo.rs b/src/test/run-make-fulldeps/archive-duplicate-names/foo.rs new file mode 100644 index 00000000000..24b4734f2cd --- /dev/null +++ b/src/test/run-make-fulldeps/archive-duplicate-names/foo.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "foo", kind = "static")] +extern { + fn foo(); + fn bar(); +} + +pub fn baz() { + unsafe { + foo(); + bar(); + } +} diff --git a/src/test/run-make-fulldeps/atomic-lock-free/Makefile b/src/test/run-make-fulldeps/atomic-lock-free/Makefile new file mode 100644 index 00000000000..a7df821f92d --- /dev/null +++ b/src/test/run-make-fulldeps/atomic-lock-free/Makefile @@ -0,0 +1,46 @@ +-include ../tools.mk + +# This tests ensure that atomic types are never lowered into runtime library calls that are not +# guaranteed to be lock-free. + +all: +ifeq ($(UNAME),Linux) +ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) + $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) + $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64) + $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) + $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc) + $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add + $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) + $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs + nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add +endif +endif diff --git a/src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs b/src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs new file mode 100644 index 00000000000..b41e8e9226b --- /dev/null +++ b/src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs @@ -0,0 +1,66 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(cfg_target_has_atomic, no_core, intrinsics, lang_items)] +#![crate_type="rlib"] +#![no_core] + +extern "rust-intrinsic" { + fn atomic_xadd(dst: *mut T, src: T) -> T; +} + +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} +#[lang = "freeze"] +trait Freeze {} + +#[cfg(target_has_atomic = "8")] +pub unsafe fn atomic_u8(x: *mut u8) { + atomic_xadd(x, 1); + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "8")] +pub unsafe fn atomic_i8(x: *mut i8) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "16")] +pub unsafe fn atomic_u16(x: *mut u16) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "16")] +pub unsafe fn atomic_i16(x: *mut i16) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "32")] +pub unsafe fn atomic_u32(x: *mut u32) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "32")] +pub unsafe fn atomic_i32(x: *mut i32) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "64")] +pub unsafe fn atomic_u64(x: *mut u64) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "64")] +pub unsafe fn atomic_i64(x: *mut i64) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "ptr")] +pub unsafe fn atomic_usize(x: *mut usize) { + atomic_xadd(x, 1); +} +#[cfg(target_has_atomic = "ptr")] +pub unsafe fn atomic_isize(x: *mut isize) { + atomic_xadd(x, 1); +} diff --git a/src/test/run-make-fulldeps/bare-outfile/Makefile b/src/test/run-make-fulldeps/bare-outfile/Makefile new file mode 100644 index 00000000000..baa4c1c0237 --- /dev/null +++ b/src/test/run-make-fulldeps/bare-outfile/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR) + cd $(TMPDIR) && $(RUSTC) -o foo foo.rs + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/bare-outfile/foo.rs b/src/test/run-make-fulldeps/bare-outfile/foo.rs new file mode 100644 index 00000000000..63e747901ae --- /dev/null +++ b/src/test/run-make-fulldeps/bare-outfile/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { +} diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/Makefile b/src/test/run-make-fulldeps/c-dynamic-dylib/Makefile new file mode 100644 index 00000000000..83bddd4c73c --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# This hits an assertion in the linker on older versions of osx apparently +ifeq ($(shell uname),Darwin) +all: + echo ignored +else +all: $(call DYLIB,cfoo) + $(RUSTC) foo.rs -C prefer-dynamic + $(RUSTC) bar.rs + $(call RUN,bar) + $(call REMOVE_DYLIBS,cfoo) + $(call FAIL,bar) +endif diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs b/src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c b/src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c new file mode 100644 index 00000000000..a9755493541 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/cfoo.c @@ -0,0 +1,5 @@ +// ignore-license +#ifdef _WIN32 +__declspec(dllexport) +#endif +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs b/src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs new file mode 100644 index 00000000000..04253be71d4 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-dylib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[link(name = "cfoo")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/Makefile b/src/test/run-make-fulldeps/c-dynamic-rlib/Makefile new file mode 100644 index 00000000000..e15cfd34d6c --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +# This overrides the LD_LIBRARY_PATH for RUN +TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) + +# This hits an assertion in the linker on older versions of osx apparently +ifeq ($(shell uname),Darwin) +all: + echo ignored +else +all: $(call DYLIB,cfoo) + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(call RUN,bar) + $(call REMOVE_DYLIBS,cfoo) + $(call FAIL,bar) +endif diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs b/src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c b/src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c new file mode 100644 index 00000000000..b2849326a75 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/cfoo.c @@ -0,0 +1,6 @@ +// ignore-license + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs b/src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs new file mode 100644 index 00000000000..a1f01bd2b62 --- /dev/null +++ b/src/test/run-make-fulldeps/c-dynamic-rlib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "cfoo")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile new file mode 100644 index 00000000000..98e112a3744 --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-dylib/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +all: $(TMPDIR)/$(call BIN,bar) + $(call RUN,bar) + $(call REMOVE_DYLIBS,foo) + $(call FAIL,bar) + +ifdef IS_MSVC +$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) + $(CC) bar.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,bar) +else +$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) + $(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR) +endif + +$(call DYLIB,foo): foo.rs + $(RUSTC) foo.rs diff --git a/src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c b/src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c new file mode 100644 index 00000000000..5729d411c5b --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-dylib/bar.c @@ -0,0 +1,7 @@ +// ignore-license +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs b/src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs new file mode 100644 index 00000000000..32675bcba1e --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-dylib/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[no_mangle] +pub extern "C" fn foo() {} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile new file mode 100644 index 00000000000..47264e82165 --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +# FIXME: ignore freebsd +ifneq ($(shell uname),FreeBSD) +all: + $(RUSTC) foo.rs + $(CC) bar.c $(call STATICLIB,foo) $(call OUT_EXE,bar) \ + $(EXTRACFLAGS) $(EXTRACXXFLAGS) + $(call RUN,bar) + rm $(call STATICLIB,foo) + $(call RUN,bar) + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c new file mode 100644 index 00000000000..5729d411c5b --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/bar.c @@ -0,0 +1,7 @@ +// ignore-license +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs new file mode 100644 index 00000000000..1bb19016700 --- /dev/null +++ b/src/test/run-make-fulldeps/c-link-to-rust-staticlib/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +#[no_mangle] +pub extern "C" fn foo() {} diff --git a/src/test/run-make-fulldeps/c-static-dylib/Makefile b/src/test/run-make-fulldeps/c-static-dylib/Makefile new file mode 100644 index 00000000000..f88786857cc --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,cfoo) + $(RUSTC) foo.rs -C prefer-dynamic + $(RUSTC) bar.rs + rm $(call NATIVE_STATICLIB,cfoo) + $(call RUN,bar) + $(call REMOVE_DYLIBS,foo) + $(call FAIL,bar) diff --git a/src/test/run-make-fulldeps/c-static-dylib/bar.rs b/src/test/run-make-fulldeps/c-static-dylib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-static-dylib/cfoo.c b/src/test/run-make-fulldeps/c-static-dylib/cfoo.c new file mode 100644 index 00000000000..113717a776a --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/cfoo.c @@ -0,0 +1,2 @@ +// ignore-license +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-static-dylib/foo.rs b/src/test/run-make-fulldeps/c-static-dylib/foo.rs new file mode 100644 index 00000000000..44be5ac890d --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-dylib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[link(name = "cfoo", kind = "static")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/c-static-rlib/Makefile b/src/test/run-make-fulldeps/c-static-rlib/Makefile new file mode 100644 index 00000000000..be22b2728f0 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,cfoo) + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(call REMOVE_RLIBS,foo) + rm $(call NATIVE_STATICLIB,cfoo) + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/c-static-rlib/bar.rs b/src/test/run-make-fulldeps/c-static-rlib/bar.rs new file mode 100644 index 00000000000..37b120decd1 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::rsfoo(); +} diff --git a/src/test/run-make-fulldeps/c-static-rlib/cfoo.c b/src/test/run-make-fulldeps/c-static-rlib/cfoo.c new file mode 100644 index 00000000000..113717a776a --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/cfoo.c @@ -0,0 +1,2 @@ +// ignore-license +int foo() { return 0; } diff --git a/src/test/run-make-fulldeps/c-static-rlib/foo.rs b/src/test/run-make-fulldeps/c-static-rlib/foo.rs new file mode 100644 index 00000000000..cbd7b020bd8 --- /dev/null +++ b/src/test/run-make-fulldeps/c-static-rlib/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "cfoo", kind = "static")] +extern { + fn foo(); +} + +pub fn rsfoo() { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile b/src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile new file mode 100644 index 00000000000..fead197ce39 --- /dev/null +++ b/src/test/run-make-fulldeps/cat-and-grep-sanity-check/Makefile @@ -0,0 +1,46 @@ +-include ../tools.mk + +all: + echo a | $(CGREP) a + ! echo b | $(CGREP) a + echo xyz | $(CGREP) x y z + ! echo abc | $(CGREP) b c d + printf "x\ny\nz" | $(CGREP) x y z + + echo AbCd | $(CGREP) -i a b C D + ! echo AbCd | $(CGREP) a b C D + + true | $(CGREP) -v nothing + ! echo nothing | $(CGREP) -v nothing + ! echo xyz | $(CGREP) -v w x y + ! echo xyz | $(CGREP) -v x y z + echo xyz | $(CGREP) -v a b c + + ! echo 'foo bar baz' | $(CGREP) 'foo baz' + echo 'foo bar baz' | $(CGREP) foo baz + echo 'x a `b` c y z' | $(CGREP) 'a `b` c' + + echo baaac | $(CGREP) -e 'ba*c' + echo bc | $(CGREP) -e 'ba*c' + ! echo aaac | $(CGREP) -e 'ba*c' + + echo aaa | $(CGREP) -e 'a+' + ! echo bbb | $(CGREP) -e 'a+' + + echo abc | $(CGREP) -e 'a|e|i|o|u' + ! echo fgh | $(CGREP) -e 'a|e|i|o|u' + echo abc | $(CGREP) -e '[aeiou]' + ! echo fgh | $(CGREP) -e '[aeiou]' + ! echo abc | $(CGREP) -e '[^aeiou]{3}' + echo fgh | $(CGREP) -e '[^aeiou]{3}' + echo ab cd ef gh | $(CGREP) -e '\bcd\b' + ! echo abcdefgh | $(CGREP) -e '\bcd\b' + echo xyz | $(CGREP) -e '...' + ! echo xy | $(CGREP) -e '...' + ! echo xyz | $(CGREP) -e '\.\.\.' + echo ... | $(CGREP) -e '\.\.\.' + + echo foo bar baz | $(CGREP) -e 'foo.*baz' + ! echo foo bar baz | $(CGREP) -ve 'foo.*baz' + ! echo foo bar baz | $(CGREP) -e 'baz.*foo' + echo foo bar baz | $(CGREP) -ve 'baz.*foo' diff --git a/src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile b/src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile new file mode 100644 index 00000000000..1a0664dfafd --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib-fewer-symbols/Makefile @@ -0,0 +1,15 @@ +# Test that allocator-related symbols don't show up as exported from a cdylib as +# they're internal to Rust and not part of the public ABI. + +-include ../tools.mk + +# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU +# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753 +ifdef IS_WINDOWS +all: + true +else +all: + $(RUSTC) foo.rs + nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_ +endif diff --git a/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs b/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs new file mode 100644 index 00000000000..4ec8d4ee860 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib-fewer-symbols/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] + +#[no_mangle] +pub extern fn foo() -> u32 { + 3 +} diff --git a/src/test/run-make-fulldeps/cdylib/Makefile b/src/test/run-make-fulldeps/cdylib/Makefile new file mode 100644 index 00000000000..47ec762b3e9 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/Makefile @@ -0,0 +1,19 @@ +include ../tools.mk + +all: $(call RUN_BINFILE,foo) + $(call RUN,foo) + rm $(call DYLIB,foo) + $(RUSTC) foo.rs -C lto + $(call RUN,foo) + +ifdef IS_MSVC +$(call RUN_BINFILE,foo): $(call DYLIB,foo) + $(CC) $(CFLAGS) foo.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,foo) +else +$(call RUN_BINFILE,foo): $(call DYLIB,foo) + $(CC) $(CFLAGS) foo.c -lfoo -o $(call RUN_BINFILE,foo) -L $(TMPDIR) +endif + +$(call DYLIB,foo): + $(RUSTC) bar.rs + $(RUSTC) foo.rs diff --git a/src/test/run-make-fulldeps/cdylib/bar.rs b/src/test/run-make-fulldeps/cdylib/bar.rs new file mode 100644 index 00000000000..2c97298604c --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub fn bar() { + println!("hello!"); +} diff --git a/src/test/run-make-fulldeps/cdylib/foo.c b/src/test/run-make-fulldeps/cdylib/foo.c new file mode 100644 index 00000000000..1c950427c65 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/foo.c @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include + +extern void foo(); +extern unsigned bar(unsigned a, unsigned b); + +int main() { + foo(); + assert(bar(1, 2) == 3); + return 0; +} diff --git a/src/test/run-make-fulldeps/cdylib/foo.rs b/src/test/run-make-fulldeps/cdylib/foo.rs new file mode 100644 index 00000000000..cdac6d19035 --- /dev/null +++ b/src/test/run-make-fulldeps/cdylib/foo.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] + +extern crate bar; + +#[no_mangle] +pub extern fn foo() { + bar::bar(); +} + +#[no_mangle] +pub extern fn bar(a: u32, b: u32) -> u32 { + a + b +} diff --git a/src/test/run-make-fulldeps/codegen-options-parsing/Makefile b/src/test/run-make-fulldeps/codegen-options-parsing/Makefile new file mode 100644 index 00000000000..fda96a8b1fb --- /dev/null +++ b/src/test/run-make-fulldeps/codegen-options-parsing/Makefile @@ -0,0 +1,31 @@ +-include ../tools.mk + +all: + #Option taking a number + $(RUSTC) -C codegen-units dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `codegen-units` requires a number' + $(RUSTC) -C codegen-units= dummy.rs 2>&1 | \ + $(CGREP) 'incorrect value `` for codegen option `codegen-units` - a number was expected' + $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | \ + $(CGREP) 'incorrect value `foo` for codegen option `codegen-units` - a number was expected' + $(RUSTC) -C codegen-units=1 dummy.rs + #Option taking a string + $(RUSTC) -C extra-filename dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `extra-filename` requires a string' + $(RUSTC) -C extra-filename= dummy.rs 2>&1 + $(RUSTC) -C extra-filename=foo dummy.rs 2>&1 + #Option taking no argument + $(RUSTC) -C lto= dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' + $(RUSTC) -C lto=1 dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' + $(RUSTC) -C lto=foo dummy.rs 2>&1 | \ + $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' + $(RUSTC) -C lto dummy.rs + + # Should not link dead code... + $(RUSTC) -Z print-link-args dummy.rs 2>&1 | \ + $(CGREP) -e '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' + # ... unless you specifically ask to keep it + $(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \ + $(CGREP) -ve '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' diff --git a/src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs b/src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/codegen-options-parsing/dummy.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/compile-stdin/Makefile b/src/test/run-make-fulldeps/compile-stdin/Makefile new file mode 100644 index 00000000000..1442224cf9a --- /dev/null +++ b/src/test/run-make-fulldeps/compile-stdin/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + echo 'fn main(){}' | $(RUSTC) - + $(call RUN,rust_out) diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile b/src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile new file mode 100644 index 00000000000..bd7f62d5c2d --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + mkdir -p $(TMPDIR)/a $(TMPDIR)/b + $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a + $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b + $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \ + && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs b/src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs new file mode 100644 index 00000000000..e7572a5f615 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/a.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs b/src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs new file mode 100644 index 00000000000..fee0da9b4c1 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/b.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate a; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs b/src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs new file mode 100644 index 00000000000..66fe51d1099 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths-2/c.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate b; +extern crate a; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/Makefile b/src/test/run-make-fulldeps/compiler-lookup-paths/Makefile new file mode 100644 index 00000000000..e22b937a087 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/Makefile @@ -0,0 +1,38 @@ +-include ../tools.mk + +all: $(TMPDIR)/libnative.a + mkdir -p $(TMPDIR)/crate + mkdir -p $(TMPDIR)/native + mv $(TMPDIR)/libnative.a $(TMPDIR)/native + $(RUSTC) a.rs + mv $(TMPDIR)/liba.rlib $(TMPDIR)/crate + $(RUSTC) b.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) b.rs -L dependency=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) b.rs -L crate=$(TMPDIR)/crate + $(RUSTC) b.rs -L all=$(TMPDIR)/crate + $(RUSTC) c.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) c.rs -L crate=$(TMPDIR)/crate && exit 1 || exit 0 + $(RUSTC) c.rs -L dependency=$(TMPDIR)/crate + $(RUSTC) c.rs -L all=$(TMPDIR)/crate + $(RUSTC) d.rs -L dependency=$(TMPDIR)/native && exit 1 || exit 0 + $(RUSTC) d.rs -L crate=$(TMPDIR)/native && exit 1 || exit 0 + $(RUSTC) d.rs -L native=$(TMPDIR)/native + $(RUSTC) d.rs -L all=$(TMPDIR)/native + # Deduplication tests: + # Same hash, no errors. + mkdir -p $(TMPDIR)/e1 + mkdir -p $(TMPDIR)/e2 + $(RUSTC) e.rs -o $(TMPDIR)/e1/libe.rlib + $(RUSTC) e.rs -o $(TMPDIR)/e2/libe.rlib + $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 + # Different hash, errors. + $(RUSTC) e2.rs -o $(TMPDIR)/e2/libe.rlib + $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 + $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 && exit 1 || exit 0 + # Native/dependency paths don't cause errors. + $(RUSTC) f.rs -L native=$(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L $(TMPDIR)/e2 + $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/a.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/a.rs new file mode 100644 index 00000000000..4ddf231fba2 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/a.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/b.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/b.rs new file mode 100644 index 00000000000..c38300f976e --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/b.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate a; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/c.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/c.rs new file mode 100644 index 00000000000..b5c54558a4f --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/c.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate b; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/d.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/d.rs new file mode 100644 index 00000000000..295b6e00e41 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/d.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "native", kind = "static")] +extern {} diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/e.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/e.rs new file mode 100644 index 00000000000..c0407aba7c9 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/e.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "e"] +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs new file mode 100644 index 00000000000..f8c8c029c0b --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/e2.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "e"] +#![crate_type = "rlib"] + +pub fn f() {} diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/f.rs b/src/test/run-make-fulldeps/compiler-lookup-paths/f.rs new file mode 100644 index 00000000000..e6160422576 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/f.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +extern crate e; diff --git a/src/test/run-make-fulldeps/compiler-lookup-paths/native.c b/src/test/run-make-fulldeps/compiler-lookup-paths/native.c new file mode 100644 index 00000000000..30669470522 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-lookup-paths/native.c @@ -0,0 +1,9 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile new file mode 100644 index 00000000000..06d1bb6698e --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +ifneq (,$(findstring MINGW,$(UNAME))) +ifndef IS_MSVC +all: + $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o + $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o + $(RUSTC) foo.rs -lfoo -lstdc++ + $(call RUN,foo) +else +all: + +endif +else +all: + +endif diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp new file mode 100644 index 00000000000..aac3ba42201 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.cpp @@ -0,0 +1,5 @@ +// ignore-license +extern "C" void foo() { + int *a = new int(3); + delete a; +} diff --git a/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs new file mode 100644 index 00000000000..293f9d58294 --- /dev/null +++ b/src/test/run-make-fulldeps/compiler-rt-works-on-mingw/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { fn foo(); } + +pub fn main() { + unsafe { foo(); } + assert_eq!(7f32.powi(3), 343f32); +} diff --git a/src/test/run-make-fulldeps/crate-data-smoke/Makefile b/src/test/run-make-fulldeps/crate-data-smoke/Makefile new file mode 100644 index 00000000000..1afda457411 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + [ `$(RUSTC) --print crate-name crate.rs` = "foo" ] + [ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ] + [ `$(RUSTC) --print file-names --crate-type=lib \ + --test crate.rs` = "$(call BIN,foo)" ] + [ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ] + $(RUSTC) --print file-names lib.rs + $(RUSTC) --print file-names rlib.rs diff --git a/src/test/run-make-fulldeps/crate-data-smoke/crate.rs b/src/test/run-make-fulldeps/crate-data-smoke/crate.rs new file mode 100644 index 00000000000..305b3dc70a6 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/crate.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +// Querying about the crate metadata should *not* parse the entire crate, it +// only needs the crate attributes (which are guaranteed to be at the top) be +// sure that if we have an error like a missing module that we can still query +// about the crate id. +mod error; diff --git a/src/test/run-make-fulldeps/crate-data-smoke/lib.rs b/src/test/run-make-fulldeps/crate-data-smoke/lib.rs new file mode 100644 index 00000000000..639a5d0387b --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/lib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "mylib"] +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/crate-data-smoke/rlib.rs b/src/test/run-make-fulldeps/crate-data-smoke/rlib.rs new file mode 100644 index 00000000000..4e093748600 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-data-smoke/rlib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "mylib"] +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/crate-name-priority/Makefile b/src/test/run-make-fulldeps/crate-name-priority/Makefile new file mode 100644 index 00000000000..17ecb33ab28 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-name-priority/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-name bar + rm $(TMPDIR)/$(call BIN,bar) + $(RUSTC) foo1.rs + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1) + rm $(TMPDIR)/$(call BIN,bar1) diff --git a/src/test/run-make-fulldeps/crate-name-priority/foo.rs b/src/test/run-make-fulldeps/crate-name-priority/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-name-priority/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/crate-name-priority/foo1.rs b/src/test/run-make-fulldeps/crate-name-priority/foo1.rs new file mode 100644 index 00000000000..a397d6bc749 --- /dev/null +++ b/src/test/run-make-fulldeps/crate-name-priority/foo1.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/debug-assertions/Makefile b/src/test/run-make-fulldeps/debug-assertions/Makefile new file mode 100644 index 00000000000..76ada90f1e2 --- /dev/null +++ b/src/test/run-make-fulldeps/debug-assertions/Makefile @@ -0,0 +1,25 @@ +-include ../tools.mk + +all: + $(RUSTC) debug.rs -C debug-assertions=no + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=0 + $(call RUN,debug) bad + $(RUSTC) debug.rs -C opt-level=1 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=2 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=3 + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=s + $(call RUN,debug) good + $(RUSTC) debug.rs -C opt-level=z + $(call RUN,debug) good + $(RUSTC) debug.rs -O + $(call RUN,debug) good + $(RUSTC) debug.rs + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -O + $(call RUN,debug) bad + $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1 + $(call RUN,debug) bad diff --git a/src/test/run-make-fulldeps/debug-assertions/debug.rs b/src/test/run-make-fulldeps/debug-assertions/debug.rs new file mode 100644 index 00000000000..65682cb86c3 --- /dev/null +++ b/src/test/run-make-fulldeps/debug-assertions/debug.rs @@ -0,0 +1,43 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![deny(warnings)] + +use std::env; +use std::thread; + +fn main() { + let should_fail = env::args().nth(1) == Some("bad".to_string()); + + assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail); + assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail); + assert_eq!(thread::spawn(overflow).join().is_err(), should_fail); +} + +fn debug_assert_eq() { + let mut hit1 = false; + let mut hit2 = false; + debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 }); + assert!(!hit1); + assert!(!hit2); +} + +fn debug_assert() { + let mut hit = false; + debug_assert!({ hit = true; false }); + assert!(!hit); +} + +fn overflow() { + fn add(a: u8, b: u8) -> u8 { a + b } + + add(200u8, 200u8); +} diff --git a/src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile new file mode 100644 index 00000000000..2fd84639f21 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --emit dep-info diff --git a/src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs new file mode 100644 index 00000000000..35911821044 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-doesnt-run-much/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// We're only emitting dep info, so we shouldn't be running static analysis to +// figure out that this program is erroneous. +fn main() { + let a: u8 = "a"; +} diff --git a/src/test/run-make-fulldeps/dep-info-spaces/Makefile b/src/test/run-make-fulldeps/dep-info-spaces/Makefile new file mode 100644 index 00000000000..82686ffdd9d --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/Makefile @@ -0,0 +1,28 @@ +-include ../tools.mk + +# FIXME: ignore freebsd/windows +# (windows: see `../dep-info/Makefile`) +ifneq ($(shell uname),FreeBSD) +ifndef IS_WINDOWS +all: + cp lib.rs $(TMPDIR)/ + cp 'foo foo.rs' $(TMPDIR)/ + cp bar.rs $(TMPDIR)/ + $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs + sleep 1 + touch $(TMPDIR)/'foo foo.rs' + -rm -f $(TMPDIR)/done + $(MAKE) -drf Makefile.foo + rm $(TMPDIR)/done + pwd + $(MAKE) -drf Makefile.foo + rm $(TMPDIR)/done && exit 1 || exit 0 +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo b/src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo new file mode 100644 index 00000000000..80a5d4333cd --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/Makefile.foo @@ -0,0 +1,7 @@ +LIB := $(shell $(RUSTC) --print file-names --crate-type=lib $(TMPDIR)/lib.rs) + +$(TMPDIR)/$(LIB): + $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs + touch $(TMPDIR)/done + +-include $(TMPDIR)/lib.d diff --git a/src/test/run-make-fulldeps/dep-info-spaces/bar.rs b/src/test/run-make-fulldeps/dep-info-spaces/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs b/src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs new file mode 100644 index 00000000000..2661b1f4eb4 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/foo foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/dep-info-spaces/lib.rs b/src/test/run-make-fulldeps/dep-info-spaces/lib.rs new file mode 100644 index 00000000000..bfbe41baeac --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info-spaces/lib.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[path="foo foo.rs"] +pub mod foo; + +pub mod bar; diff --git a/src/test/run-make-fulldeps/dep-info/Makefile b/src/test/run-make-fulldeps/dep-info/Makefile new file mode 100644 index 00000000000..9b79d1af521 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/Makefile @@ -0,0 +1,34 @@ +-include ../tools.mk + +# FIXME: ignore freebsd/windows +# on windows `rustc --dep-info` produces Makefile dependency with +# windows native paths (e.g. `c:\path\to\libfoo.a`) +# but msys make seems to fail to recognize such paths, so test fails. +ifneq ($(shell uname),FreeBSD) +ifndef IS_WINDOWS +all: + cp *.rs $(TMPDIR) + $(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs + sleep 2 + touch $(TMPDIR)/foo.rs + -rm -f $(TMPDIR)/done + $(MAKE) -drf Makefile.foo + sleep 2 + rm $(TMPDIR)/done + pwd + $(MAKE) -drf Makefile.foo + rm $(TMPDIR)/done && exit 1 || exit 0 + + # When a source file is deleted `make` should still work + rm $(TMPDIR)/bar.rs + cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs + $(MAKE) -drf Makefile.foo +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/dep-info/Makefile.foo b/src/test/run-make-fulldeps/dep-info/Makefile.foo new file mode 100644 index 00000000000..e5df31f88c1 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/Makefile.foo @@ -0,0 +1,7 @@ +LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs) + +$(TMPDIR)/$(LIB): + $(RUSTC) --emit dep-info,link --crate-type=lib lib.rs + touch $(TMPDIR)/done + +-include $(TMPDIR)/foo.d diff --git a/src/test/run-make-fulldeps/dep-info/bar.rs b/src/test/run-make-fulldeps/dep-info/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/dep-info/foo.rs b/src/test/run-make-fulldeps/dep-info/foo.rs new file mode 100644 index 00000000000..2661b1f4eb4 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/dep-info/lib.rs b/src/test/run-make-fulldeps/dep-info/lib.rs new file mode 100644 index 00000000000..7c15785bbb2 --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/lib.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +pub mod foo; +pub mod bar; diff --git a/src/test/run-make-fulldeps/dep-info/lib2.rs b/src/test/run-make-fulldeps/dep-info/lib2.rs new file mode 100644 index 00000000000..1b70fb4eb4b --- /dev/null +++ b/src/test/run-make-fulldeps/dep-info/lib2.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] + +pub mod foo; diff --git a/src/test/run-make-fulldeps/duplicate-output-flavors/Makefile b/src/test/run-make-fulldeps/duplicate-output-flavors/Makefile new file mode 100644 index 00000000000..e33279966c9 --- /dev/null +++ b/src/test/run-make-fulldeps/duplicate-output-flavors/Makefile @@ -0,0 +1,5 @@ +include ../tools.mk + +all: + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=rlib,rlib foo.rs diff --git a/src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs b/src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/duplicate-output-flavors/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/dylib-chain/Makefile b/src/test/run-make-fulldeps/dylib-chain/Makefile new file mode 100644 index 00000000000..a33177197b1 --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +all: + $(RUSTC) m1.rs -C prefer-dynamic + $(RUSTC) m2.rs -C prefer-dynamic + $(RUSTC) m3.rs -C prefer-dynamic + $(RUSTC) m4.rs + $(call RUN,m4) + $(call REMOVE_DYLIBS,m1) + $(call REMOVE_DYLIBS,m2) + $(call REMOVE_DYLIBS,m3) + $(call FAIL,m4) diff --git a/src/test/run-make-fulldeps/dylib-chain/m1.rs b/src/test/run-make-fulldeps/dylib-chain/m1.rs new file mode 100644 index 00000000000..5437c935c4e --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m1.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +pub fn m1() {} diff --git a/src/test/run-make-fulldeps/dylib-chain/m2.rs b/src/test/run-make-fulldeps/dylib-chain/m2.rs new file mode 100644 index 00000000000..b464f32eae2 --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate m1; + +pub fn m2() { m1::m1() } diff --git a/src/test/run-make-fulldeps/dylib-chain/m3.rs b/src/test/run-make-fulldeps/dylib-chain/m3.rs new file mode 100644 index 00000000000..bf431cc827b --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m3.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate m2; + +pub fn m3() { m2::m2() } diff --git a/src/test/run-make-fulldeps/dylib-chain/m4.rs b/src/test/run-make-fulldeps/dylib-chain/m4.rs new file mode 100644 index 00000000000..6c2a6685802 --- /dev/null +++ b/src/test/run-make-fulldeps/dylib-chain/m4.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate m3; + +fn main() { m3::m3() } diff --git a/src/test/run-make-fulldeps/emit/Makefile b/src/test/run-make-fulldeps/emit/Makefile new file mode 100644 index 00000000000..e0b57107e5b --- /dev/null +++ b/src/test/run-make-fulldeps/emit/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +all: + $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs + $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 + $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs + $(call RUN,test-26235) || exit 1 diff --git a/src/test/run-make-fulldeps/emit/test-24876.rs b/src/test/run-make-fulldeps/emit/test-24876.rs new file mode 100644 index 00000000000..ab69decbf00 --- /dev/null +++ b/src/test/run-make-fulldeps/emit/test-24876.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks for issue #24876 + +fn main() { + let mut v = 0; + for i in 0..0 { + v += i; + } + println!("{}", v) +} diff --git a/src/test/run-make-fulldeps/emit/test-26235.rs b/src/test/run-make-fulldeps/emit/test-26235.rs new file mode 100644 index 00000000000..97b58a3671b --- /dev/null +++ b/src/test/run-make-fulldeps/emit/test-26235.rs @@ -0,0 +1,56 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Checks for issue #26235 + +fn main() { + use std::thread; + + type Key = u32; + const NUM_THREADS: usize = 2; + + #[derive(Clone,Copy)] + struct Stats { + upsert: S, + delete: S, + insert: S, + update: S + }; + + impl Stats where S: Copy { + fn dot(self, s: Stats, f: F) -> Stats where F: Fn(S, T) -> B { + let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self; + 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) } + } + + fn new(init: S) -> Self { + Stats { upsert: init, delete: init, insert: init, update: init } + } + } + + fn make_threads() -> Vec> { + let mut t = Vec::with_capacity(NUM_THREADS); + for _ in 0..NUM_THREADS { + t.push(thread::spawn(move || {})); + } + t + } + + let stats = [Stats::new(0); NUM_THREADS]; + make_threads(); + + { + let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold( + Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y))); + println!("upserts: {}, deletes: {}, inserts: {}, updates: {}", + upsert, delete, insert, update); + } +} diff --git a/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile new file mode 100644 index 00000000000..fef12c4da67 --- /dev/null +++ b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --crate-type staticlib + $(RUSTC) bar.rs 2>&1 | $(CGREP) "found staticlib" diff --git a/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs new file mode 100644 index 00000000000..5ab3e5ee99d --- /dev/null +++ b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::foo(); +} diff --git a/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs new file mode 100644 index 00000000000..222d98a12de --- /dev/null +++ b/src/test/run-make-fulldeps/error-found-staticlib-instead-crate/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/error-writing-dependencies/Makefile b/src/test/run-make-fulldeps/error-writing-dependencies/Makefile new file mode 100644 index 00000000000..cbc96901a38 --- /dev/null +++ b/src/test/run-make-fulldeps/error-writing-dependencies/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + # Let's get a nice error message + $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \ + $(CGREP) "error writing dependencies" + # Make sure the filename shows up + $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | $(CGREP) "baz" diff --git a/src/test/run-make-fulldeps/error-writing-dependencies/foo.rs b/src/test/run-make-fulldeps/error-writing-dependencies/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/error-writing-dependencies/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/extern-diff-internal-name/Makefile b/src/test/run-make-fulldeps/extern-diff-internal-name/Makefile new file mode 100644 index 00000000000..b84e930757b --- /dev/null +++ b/src/test/run-make-fulldeps/extern-diff-internal-name/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + $(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs b/src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs new file mode 100644 index 00000000000..e8779bba13c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-diff-internal-name/lib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "bar"] +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/extern-diff-internal-name/test.rs b/src/test/run-make-fulldeps/extern-diff-internal-name/test.rs new file mode 100644 index 00000000000..11e042c8c4a --- /dev/null +++ b/src/test/run-make-fulldeps/extern-diff-internal-name/test.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate foo; + +fn main() { +} diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile b/src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile new file mode 100644 index 00000000000..81930e969a9 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/Makefile @@ -0,0 +1,25 @@ +-include ../tools.mk + +# Attempt to build this dependency tree: +# +# A.1 A.2 +# |\ | +# | \ | +# B \ C +# \ | / +# \|/ +# D +# +# Note that A.1 and A.2 are crates with the same name. + +all: + $(RUSTC) -C metadata=1 -C extra-filename=-1 a.rs + $(RUSTC) -C metadata=2 -C extra-filename=-2 a.rs + $(RUSTC) b.rs --extern a=$(TMPDIR)/liba-1.rlib + $(RUSTC) c.rs --extern a=$(TMPDIR)/liba-2.rlib + @echo before + $(RUSTC) --cfg before d.rs --extern a=$(TMPDIR)/liba-1.rlib + $(call RUN,d) + @echo after + $(RUSTC) --cfg after d.rs --extern a=$(TMPDIR)/liba-1.rlib + $(call RUN,d) diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs new file mode 100644 index 00000000000..ac92aede789 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/a.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "a"] +#![crate_type = "rlib"] + +static FOO: usize = 3; + +pub fn token() -> &'static usize { &FOO } diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs new file mode 100644 index 00000000000..8ae238f5a48 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/b.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "b"] +#![crate_type = "rlib"] + +extern crate a; + +static FOO: usize = 3; + +pub fn token() -> &'static usize { &FOO } +pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs new file mode 100644 index 00000000000..6eccdf7e5c8 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/c.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "c"] +#![crate_type = "rlib"] + +extern crate a; + +static FOO: usize = 3; + +pub fn token() -> &'static usize { &FOO } +pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs b/src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs new file mode 100644 index 00000000000..9923ff83a91 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-disambiguates/d.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(before)] extern crate a; +extern crate b; +extern crate c; +#[cfg(after)] extern crate a; + +fn t(a: &'static usize) -> usize { a as *const _ as usize } + +fn main() { + assert_eq!(t(a::token()), t(b::a_token())); + assert!(t(a::token()) != t(c::a_token())); +} diff --git a/src/test/run-make-fulldeps/extern-flag-fun/Makefile b/src/test/run-make-fulldeps/extern-flag-fun/Makefile new file mode 100644 index 00000000000..a9f25853350 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +all: + $(RUSTC) bar.rs --crate-type=rlib + $(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a + $(RUSTC) bar-alt.rs --crate-type=rlib + $(RUSTC) foo.rs --extern hello && exit 1 || exit 0 + $(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0 + $(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0 + $(RUSTC) foo.rs \ + --extern bar=$(TMPDIR)/libbar.rlib \ + --extern bar=$(TMPDIR)/libbar-alt.rlib \ + && exit 1 || exit 0 + $(RUSTC) foo.rs \ + --extern bar=$(TMPDIR)/libbar.rlib \ + --extern bar=$(TMPDIR)/libbar-a.rlib + $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs b/src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs new file mode 100644 index 00000000000..d6ebd9d896f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/bar-alt.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn f() {} diff --git a/src/test/run-make-fulldeps/extern-flag-fun/bar.rs b/src/test/run-make-fulldeps/extern-flag-fun/bar.rs new file mode 100644 index 00000000000..e6c76025738 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/bar.rs @@ -0,0 +1,9 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/extern-flag-fun/foo.rs b/src/test/run-make-fulldeps/extern-flag-fun/foo.rs new file mode 100644 index 00000000000..52741668640 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-flag-fun/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() {} diff --git a/src/test/run-make-fulldeps/extern-fn-generic/Makefile b/src/test/run-make-fulldeps/extern-fn-generic/Makefile new file mode 100644 index 00000000000..cf897dba1f2 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) testcrate.rs + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-generic/test.c b/src/test/run-make-fulldeps/extern-fn-generic/test.c new file mode 100644 index 00000000000..f9faef64afc --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/test.c @@ -0,0 +1,17 @@ +// ignore-license +#include + +typedef struct TestStruct { + uint8_t x; + int32_t y; +} TestStruct; + +typedef int callback(TestStruct s); + +uint32_t call(callback *c) { + TestStruct s; + s.x = 'a'; + s.y = 3; + + return c(s); +} diff --git a/src/test/run-make-fulldeps/extern-fn-generic/test.rs b/src/test/run-make-fulldeps/extern-fn-generic/test.rs new file mode 100644 index 00000000000..8f5ff091b3b --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/test.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate testcrate; + +extern "C" fn bar(ts: testcrate::TestStruct) -> T { ts.y } + +#[link(name = "test", kind = "static")] +extern { + fn call(c: extern "C" fn(testcrate::TestStruct) -> i32) -> i32; +} + +fn main() { + // Let's test calling it cross crate + let back = unsafe { + testcrate::call(testcrate::foo::) + }; + assert_eq!(3, back); + + // And just within this crate + let back = unsafe { + call(bar::) + }; + assert_eq!(3, back); +} diff --git a/src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs b/src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs new file mode 100644 index 00000000000..d02c05047c0 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-generic/testcrate.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[repr(C)] +pub struct TestStruct { + pub x: u8, + pub y: T +} + +pub extern "C" fn foo(ts: TestStruct) -> T { ts.y } + +#[link(name = "test", kind = "static")] +extern { + pub fn call(c: extern "C" fn(TestStruct) -> i32) -> i32; +} diff --git a/src/test/run-make-fulldeps/extern-fn-mangle/Makefile b/src/test/run-make-fulldeps/extern-fn-mangle/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-mangle/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-mangle/test.c b/src/test/run-make-fulldeps/extern-fn-mangle/test.c new file mode 100644 index 00000000000..1a9855dedec --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-mangle/test.c @@ -0,0 +1,9 @@ +// ignore-license +#include + +uint32_t foo(); +uint32_t bar(); + +uint32_t add() { + return foo() + bar(); +} diff --git a/src/test/run-make-fulldeps/extern-fn-mangle/test.rs b/src/test/run-make-fulldeps/extern-fn-mangle/test.rs new file mode 100644 index 00000000000..35b5a9278a4 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-mangle/test.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern "C" fn foo() -> i32 { 3 } + +#[no_mangle] +pub extern "C" fn bar() -> i32 { 5 } + +#[link(name = "test", kind = "static")] +extern { + fn add() -> i32; +} + +fn main() { + let back = unsafe { add() }; + assert_eq!(8, back); +} diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/Makefile b/src/test/run-make-fulldeps/extern-fn-reachable/Makefile new file mode 100644 index 00000000000..79a9a3c640f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-reachable/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# This overrides the LD_LIBRARY_PATH for RUN +TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) + +all: + $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so -C prefer-dynamic + $(RUSTC) main.rs -C prefer-dynamic + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs b/src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs new file mode 100644 index 00000000000..f24265e7a52 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-reachable/dylib.rs @@ -0,0 +1,24 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +#![allow(dead_code)] + +#[no_mangle] pub extern "C" fn fun1() {} +#[no_mangle] extern "C" fn fun2() {} + +mod foo { + #[no_mangle] pub extern "C" fn fun3() {} +} +pub mod bar { + #[no_mangle] pub extern "C" fn fun4() {} +} + +#[no_mangle] pub fn fun5() {} diff --git a/src/test/run-make-fulldeps/extern-fn-reachable/main.rs b/src/test/run-make-fulldeps/extern-fn-reachable/main.rs new file mode 100644 index 00000000000..27387332c1c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-reachable/main.rs @@ -0,0 +1,28 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_private)] + +extern crate rustc_metadata; + +use rustc_metadata::dynamic_lib::DynamicLibrary; +use std::path::Path; + +pub fn main() { + unsafe { + let path = Path::new("libdylib.so"); + let a = DynamicLibrary::open(Some(&path)).unwrap(); + assert!(a.symbol::("fun1").is_ok()); + assert!(a.symbol::("fun2").is_err()); + assert!(a.symbol::("fun3").is_err()); + assert!(a.symbol::("fun4").is_ok()); + assert!(a.symbol::("fun5").is_ok()); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c new file mode 100644 index 00000000000..25cd6da10b8 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.c @@ -0,0 +1,324 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include + +struct Rect { + int32_t a; + int32_t b; + int32_t c; + int32_t d; +}; + +struct BiggerRect { + struct Rect s; + int32_t a; + int32_t b; +}; + +struct FloatRect { + int32_t a; + int32_t b; + double c; +}; + +struct Huge { + int32_t a; + int32_t b; + int32_t c; + int32_t d; + int32_t e; +}; + +struct FloatPoint { + double x; + double y; +}; + +struct FloatOne { + double x; +}; + +struct IntOdd { + int8_t a; + int8_t b; + int8_t c; +}; + +// System V x86_64 ABI: +// a, b, c, d, e should be in registers +// s should be byval pointer +// +// Win64 ABI: +// a, b, c, d should be in registers +// e should be on the stack +// s should be byval pointer +void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(d == 4); + assert(e == 5); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 ABI: +// a, b, c, d, e, f should be in registers +// s should be byval pointer on the stack +// +// Win64 ABI: +// a, b, c, d should be in registers +// e, f should be on the stack +// s should be byval pointer on the stack +void byval_many_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, + int32_t f, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(d == 4); + assert(e == 5); + assert(f == 6); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 ABI: +// a, b, c, d, e, f, g should be in sse registers +// s should be split across 2 registers +// t should be byval pointer +// +// Win64 ABI: +// a, b, c, d should be in sse registers +// e, f, g should be on the stack +// s should be on the stack (treated as 2 i64's) +// t should be on the stack (treated as an i64 and a double) +void byval_rect_floats(float a, float b, double c, float d, float e, + float f, double g, struct Rect s, struct FloatRect t) { + assert(a == 1.); + assert(b == 2.); + assert(c == 3.); + assert(d == 4.); + assert(e == 5.); + assert(f == 6.); + assert(g == 7.); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + assert(t.a == 3489); + assert(t.b == 3490); + assert(t.c == 8.); +} + +// System V x86_64 ABI: +// a, b, d, e, f should be in registers +// c passed via sse registers +// s should be byval pointer +// +// Win64 ABI: +// a, b, d should be in registers +// c passed via sse registers +// e, f should be on the stack +// s should be byval pointer +void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d, + int32_t e, int32_t f, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3.); + assert(d == 4); + assert(e == 5); + assert(f == 6); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 ABI: +// a, b, d, e, f should be byval pointer (on the stack) +// g passed via register (fixes #41375) +// +// Win64 ABI: +// a, b, d, e, f, g should be byval pointer +void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c, + struct Huge d, struct Huge e, struct Huge f, + struct Rect g) { + assert(g.a == 123); + assert(g.b == 456); + assert(g.c == 789); + assert(g.d == 420); +} + +// System V x86_64 & Win64 ABI: +// a, b should be in registers +// s should be split across 2 integer registers +void split_rect(int32_t a, int32_t b, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 & Win64 ABI: +// a, b should be in sse registers +// s should be split across integer & sse registers +void split_rect_floats(float a, float b, struct FloatRect s) { + assert(a == 1.); + assert(b == 2.); + assert(s.a == 3489); + assert(s.b == 3490); + assert(s.c == 8.); +} + +// System V x86_64 ABI: +// a, b, d, f should be in registers +// c, e passed via sse registers +// s should be split across 2 registers +// +// Win64 ABI: +// a, b, d should be in registers +// c passed via sse registers +// e, f should be on the stack +// s should be on the stack (treated as 2 i64's) +void split_rect_with_floats(int32_t a, int32_t b, float c, + int32_t d, float e, int32_t f, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3.); + assert(d == 4); + assert(e == 5.); + assert(f == 6); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); +} + +// System V x86_64 & Win64 ABI: +// a, b, c should be in registers +// s should be split across 2 registers +// t should be a byval pointer +void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct Rect t) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + assert(t.a == 553); + assert(t.b == 554); + assert(t.c == 555); + assert(t.d == 556); +} + +// System V x86_64 & Win64 ABI: +// a, b should in registers +// s and return should be split across 2 registers +struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + return s; +} + +// System V x86_64 & Win64 ABI: +// a, b, c, d should be in registers +// return should be in a hidden sret pointer +// s should be a byval pointer +struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(c == 3); + assert(d == 4); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + + struct BiggerRect t; + t.s = s; t.a = 27834; t.b = 7657; + return t; +} + +// System V x86_64 & Win64 ABI: +// a, b should be in registers +// return should be in a hidden sret pointer +// s should be split across 2 registers +struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) { + assert(a == 1); + assert(b == 2); + assert(s.a == 553); + assert(s.b == 554); + assert(s.c == 555); + assert(s.d == 556); + + struct BiggerRect t; + t.s = s; t.a = 27834; t.b = 7657; + return t; +} + +// System V x86_64 & Win64 ABI: +// s should be byval pointer (since sizeof(s) > 16) +// return should in a hidden sret pointer +struct Huge huge_struct(struct Huge s) { + assert(s.a == 5647); + assert(s.b == 5648); + assert(s.c == 5649); + assert(s.d == 5650); + assert(s.e == 5651); + + return s; +} + +// System V x86_64 ABI: +// p should be in registers +// return should be in registers +// +// Win64 ABI and 64-bit PowerPC ELFv1 ABI: +// p should be a byval pointer +// return should be in a hidden sret pointer +struct FloatPoint float_point(struct FloatPoint p) { + assert(p.x == 5.); + assert(p.y == -3.); + + return p; +} + +// 64-bit PowerPC ELFv1 ABI: +// f1 should be in a register +// return should be in a hidden sret pointer +struct FloatOne float_one(struct FloatOne f1) { + assert(f1.x == 7.); + + return f1; +} + +// 64-bit PowerPC ELFv1 ABI: +// i should be in the least-significant bits of a register +// return should be in a hidden sret pointer +struct IntOdd int_odd(struct IntOdd i) { + assert(i.a == 1); + assert(i.b == 2); + assert(i.c == 3); + + return i; +} diff --git a/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs new file mode 100644 index 00000000000..54a4f868eb4 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-struct-passing-abi/test.rs @@ -0,0 +1,144 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Passing structs via FFI should work regardless of whether +// they get passed in multiple registers, byval pointers or the stack + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct Rect { + a: i32, + b: i32, + c: i32, + d: i32 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct BiggerRect { + s: Rect, + a: i32, + b: i32 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct FloatRect { + a: i32, + b: i32, + c: f64 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct Huge { + a: i32, + b: i32, + c: i32, + d: i32, + e: i32 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct FloatPoint { + x: f64, + y: f64 +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct FloatOne { + x: f64, +} + +#[derive(Clone, Copy, Debug, PartialEq)] +#[repr(C)] +struct IntOdd { + a: i8, + b: i8, + c: i8, +} + +#[link(name = "test", kind = "static")] +extern { + fn byval_rect(a: i32, b: i32, c: i32, d: i32, e: i32, s: Rect); + + fn byval_many_rect(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, s: Rect); + + fn byval_rect_floats(a: f32, b: f32, c: f64, d: f32, e: f32, + f: f32, g: f64, s: Rect, t: FloatRect); + + fn byval_rect_with_float(a: i32, b: i32, c: f32, d: i32, e: i32, f: i32, s: Rect); + + fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect); + + fn split_rect(a: i32, b: i32, s: Rect); + + fn split_rect_floats(a: f32, b: f32, s: FloatRect); + + fn split_rect_with_floats(a: i32, b: i32, c: f32, d: i32, e: f32, f: i32, s: Rect); + + fn split_and_byval_rect(a: i32, b: i32, c: i32, s: Rect, t: Rect); + + fn split_ret_byval_struct(a: i32, b: i32, s: Rect) -> Rect; + + fn sret_byval_struct(a: i32, b: i32, c: i32, d: i32, s: Rect) -> BiggerRect; + + fn sret_split_struct(a: i32, b: i32, s: Rect) -> BiggerRect; + + fn huge_struct(s: Huge) -> Huge; + + fn float_point(p: FloatPoint) -> FloatPoint; + + fn float_one(f: FloatOne) -> FloatOne; + + fn int_odd(i: IntOdd) -> IntOdd; +} + +fn main() { + let s = Rect { a: 553, b: 554, c: 555, d: 556 }; + let t = BiggerRect { s: s, a: 27834, b: 7657 }; + let u = FloatRect { a: 3489, b: 3490, c: 8. }; + let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 }; + let p = FloatPoint { x: 5., y: -3. }; + let f1 = FloatOne { x: 7. }; + let i = IntOdd { a: 1, b: 2, c: 3 }; + + unsafe { + byval_rect(1, 2, 3, 4, 5, s); + byval_many_rect(1, 2, 3, 4, 5, 6, s); + byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u); + byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s); + byval_rect_with_many_huge(v, v, v, v, v, v, Rect { + a: 123, + b: 456, + c: 789, + d: 420 + }); + split_rect(1, 2, s); + split_rect_floats(1., 2., u); + split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s); + split_and_byval_rect(1, 2, 3, s, s); + split_rect(1, 2, s); + assert_eq!(huge_struct(v), v); + assert_eq!(split_ret_byval_struct(1, 2, s), s); + assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t); + assert_eq!(sret_split_struct(1, 2, s), t); + assert_eq!(float_point(p), p); + assert_eq!(int_odd(i), i); + + // MSVC/GCC/Clang are not consistent in the ABI of single-float aggregates. + // x86_64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82028 + // i686: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82041 + #[cfg(not(all(windows, target_env = "gnu")))] + assert_eq!(float_one(f1), f1); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile b/src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile new file mode 100644 index 00000000000..8977e14c3ad --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-extern-types/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,ctest) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c b/src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c new file mode 100644 index 00000000000..c3d6166fb12 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-extern-types/ctest.c @@ -0,0 +1,17 @@ +// ignore-license +#include +#include + +typedef struct data { + uint32_t magic; +} data; + +data* data_create(uint32_t magic) { + static data d; + d.magic = magic; + return &d; +} + +uint32_t data_get(data* p) { + return p->magic; +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs b/src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs new file mode 100644 index 00000000000..9d6c87885b1 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-extern-types/test.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(extern_types)] + +#[link(name = "ctest", kind = "static")] +extern { + type data; + + fn data_create(magic: u32) -> *mut data; + fn data_get(data: *mut data) -> u32; +} + +const MAGIC: u32 = 0xdeadbeef; +fn main() { + unsafe { + let data = data_create(MAGIC); + assert_eq!(data_get(data), MAGIC); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c new file mode 100644 index 00000000000..4124e202c1d --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.c @@ -0,0 +1,27 @@ +// ignore-license +// Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 + +#include + +#ifdef _MSC_VER +#pragma pack(push,1) +struct Foo { + char a; + short b; + char c; +}; +#else +#pragma pack(1) +struct __attribute__((packed)) Foo { + char a; + short b; + char c; +}; +#endif + +struct Foo foo(struct Foo foo) { + assert(foo.a == 1); + assert(foo.b == 2); + assert(foo.c == 3); + return foo; +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs new file mode 100644 index 00000000000..d2540ad6154 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-packed-struct/test.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[repr(C, packed)] +#[derive(Copy, Clone, Debug, PartialEq)] +struct Foo { + a: i8, + b: i16, + c: i8 +} + +#[link(name = "test", kind = "static")] +extern { + fn foo(f: Foo) -> Foo; +} + +fn main() { + unsafe { + let a = Foo { a: 1, b: 2, c: 3 }; + let b = foo(a); + assert_eq!(a, b); + } +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/Makefile b/src/test/run-make-fulldeps/extern-fn-with-union/Makefile new file mode 100644 index 00000000000..71a5407e882 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,ctest) + $(RUSTC) testcrate.rs + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/ctest.c b/src/test/run-make-fulldeps/extern-fn-with-union/ctest.c new file mode 100644 index 00000000000..8c87c230693 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/ctest.c @@ -0,0 +1,11 @@ +// ignore-license +#include +#include + +typedef union TestUnion { + uint64_t bits; +} TestUnion; + +uint64_t give_back(TestUnion tu) { + return tu.bits; +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/test.rs b/src/test/run-make-fulldeps/extern-fn-with-union/test.rs new file mode 100644 index 00000000000..f9277ba11f4 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/test.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate testcrate; + +use std::mem; + +extern { + fn give_back(tu: testcrate::TestUnion) -> u64; +} + +fn main() { + let magic: u64 = 0xDEADBEEF; + + // Let's test calling it cross crate + let back = unsafe { + testcrate::give_back(mem::transmute(magic)) + }; + assert_eq!(magic, back); + + // And just within this crate + let back = unsafe { + give_back(mem::transmute(magic)) + }; + assert_eq!(magic, back); +} diff --git a/src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs b/src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs new file mode 100644 index 00000000000..66978c38511 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-fn-with-union/testcrate.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[repr(C)] +pub struct TestUnion { + _val: u64 +} + +#[link(name = "ctest", kind = "static")] +extern { + pub fn give_back(tu: TestUnion) -> u64; +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/Makefile b/src/test/run-make-fulldeps/extern-multiple-copies/Makefile new file mode 100644 index 00000000000..1631aa806af --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) foo1.rs + $(RUSTC) foo2.rs + mkdir $(TMPDIR)/foo + cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib + $(RUSTC) bar.rs --extern foo1=$(TMPDIR)/libfoo1.rlib -L $(TMPDIR)/foo diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/bar.rs b/src/test/run-make-fulldeps/extern-multiple-copies/bar.rs new file mode 100644 index 00000000000..a50f5de384c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/bar.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo2; // foo2 first to exhibit the bug +extern crate foo1; + +fn main() { + /* ... */ +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs b/src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs new file mode 100644 index 00000000000..0be200ddcd2 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/foo1.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs b/src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs new file mode 100644 index 00000000000..0be200ddcd2 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies/foo2.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/Makefile b/src/test/run-make-fulldeps/extern-multiple-copies2/Makefile new file mode 100644 index 00000000000..567d7e78a57 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + $(RUSTC) foo1.rs + $(RUSTC) foo2.rs + mkdir $(TMPDIR)/foo + cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib + $(RUSTC) bar.rs \ + --extern foo1=$(TMPDIR)/foo/libfoo1.rlib \ + --extern foo2=$(TMPDIR)/libfoo2.rlib diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs b/src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs new file mode 100644 index 00000000000..b8ac34aa53e --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/bar.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate foo2; // foo2 first to exhibit the bug +#[macro_use] +extern crate foo1; + +fn main() { + foo2::foo2(foo1::A); +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs b/src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs new file mode 100644 index 00000000000..1787772053b --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/foo1.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub struct A; + +pub fn foo1(a: A) { + drop(a); +} diff --git a/src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs b/src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs new file mode 100644 index 00000000000..bad10304387 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-multiple-copies2/foo2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[macro_use] +extern crate foo1; + +pub fn foo2(a: foo1::A) { + foo1::foo1(a); +} diff --git a/src/test/run-make-fulldeps/extern-overrides-distribution/Makefile b/src/test/run-make-fulldeps/extern-overrides-distribution/Makefile new file mode 100644 index 00000000000..7d063a4c83c --- /dev/null +++ b/src/test/run-make-fulldeps/extern-overrides-distribution/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) libc.rs -Cmetadata=foo + $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib diff --git a/src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs b/src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs new file mode 100644 index 00000000000..a489d834a92 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-overrides-distribution/libc.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/extern-overrides-distribution/main.rs b/src/test/run-make-fulldeps/extern-overrides-distribution/main.rs new file mode 100644 index 00000000000..451841e7368 --- /dev/null +++ b/src/test/run-make-fulldeps/extern-overrides-distribution/main.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate libc; + +fn main() { + libc::foo(); +} diff --git a/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile new file mode 100644 index 00000000000..6de4f97df0c --- /dev/null +++ b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) -C extra-filename=bar foo.rs -C save-temps + rm $(TMPDIR)/foobar.foo0.rcgu.o + rm $(TMPDIR)/$(call BIN,foobar) diff --git a/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/extra-filename-with-temp-outputs/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/fpic/Makefile b/src/test/run-make-fulldeps/fpic/Makefile new file mode 100644 index 00000000000..6de58c2db18 --- /dev/null +++ b/src/test/run-make-fulldeps/fpic/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# Test for #39529. +# `-z text` causes ld to error if there are any non-PIC sections + +ifeq ($(UNAME),Darwin) +all: +else ifdef IS_WINDOWS +all: +else +all: + $(RUSTC) hello.rs -C link-args=-Wl,-z,text +endif diff --git a/src/test/run-make-fulldeps/fpic/hello.rs b/src/test/run-make-fulldeps/fpic/hello.rs new file mode 100644 index 00000000000..a9e231b0ea8 --- /dev/null +++ b/src/test/run-make-fulldeps/fpic/hello.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/hir-tree/Makefile b/src/test/run-make-fulldeps/hir-tree/Makefile new file mode 100644 index 00000000000..2e100b269e1 --- /dev/null +++ b/src/test/run-make-fulldeps/hir-tree/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +# Test that hir-tree output doens't crash and includes +# the string constant we would expect to see. + +all: + $(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs + $(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir diff --git a/src/test/run-make-fulldeps/hir-tree/input.rs b/src/test/run-make-fulldeps/hir-tree/input.rs new file mode 100644 index 00000000000..12adc083bcd --- /dev/null +++ b/src/test/run-make-fulldeps/hir-tree/input.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, Rustaceans!"); +} diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile b/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile new file mode 100644 index 00000000000..2ddf3aa5439 --- /dev/null +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile @@ -0,0 +1,9 @@ +include ../tools.mk + +all: + /bin/echo || exit 0 # This test requires /bin/echo to exist + $(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \ + -o $(TMPDIR)/the_backend.dylib + $(RUSTC) some_crate.rs --crate-name some_crate --crate-type bin -o $(TMPDIR)/some_crate \ + -Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options + grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs new file mode 100644 index 00000000000..26ffce01b2e --- /dev/null +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/some_crate.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + ::std::process::exit(1); +} diff --git a/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs new file mode 100644 index 00000000000..e266b0f5e83 --- /dev/null +++ b/src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -0,0 +1,82 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_private)] + +extern crate syntax; +extern crate rustc; +extern crate rustc_trans_utils; + +use std::any::Any; +use std::sync::mpsc; +use syntax::symbol::Symbol; +use rustc::session::{Session, CompileIncomplete}; +use rustc::session::config::OutputFilenames; +use rustc::ty::TyCtxt; +use rustc::ty::maps::Providers; +use rustc::middle::cstore::MetadataLoader; +use rustc::dep_graph::DepGraph; +use rustc_trans_utils::trans_crate::{TransCrate, MetadataOnlyTransCrate}; + +struct TheBackend(Box); + +impl TransCrate for TheBackend { + fn metadata_loader(&self) -> Box { + self.0.metadata_loader() + } + + fn provide(&self, providers: &mut Providers) { + self.0.provide(providers); + } + + fn provide_extern(&self, providers: &mut Providers) { + self.0.provide_extern(providers); + } + + fn trans_crate<'a, 'tcx>( + &self, + tcx: TyCtxt<'a, 'tcx, 'tcx>, + _rx: mpsc::Receiver> + ) -> Box { + use rustc::hir::def_id::LOCAL_CRATE; + + Box::new(tcx.crate_name(LOCAL_CRATE) as Symbol) + } + + fn join_trans_and_link( + &self, + trans: Box, + sess: &Session, + _dep_graph: &DepGraph, + outputs: &OutputFilenames, + ) -> Result<(), CompileIncomplete> { + use std::io::Write; + use rustc::session::config::CrateType; + use rustc_trans_utils::link::out_filename; + let crate_name = trans.downcast::() + .expect("in join_trans_and_link: trans is not a Symbol"); + for &crate_type in sess.opts.crate_types.iter() { + if crate_type != CrateType::CrateTypeExecutable { + sess.fatal(&format!("Crate type is {:?}", crate_type)); + } + let output_name = + out_filename(sess, crate_type, &outputs, &*crate_name.as_str()); + let mut out_file = ::std::fs::File::create(output_name).unwrap(); + write!(out_file, "This has been \"compiled\" successfully.").unwrap(); + } + Ok(()) + } +} + +/// This is the entrypoint for a hot plugged rustc_trans +#[no_mangle] +pub fn __rustc_codegen_backend() -> Box { + Box::new(TheBackend(MetadataOnlyTransCrate::new())) +} diff --git a/src/test/run-make-fulldeps/include_bytes_deps/Makefile b/src/test/run-make-fulldeps/include_bytes_deps/Makefile new file mode 100644 index 00000000000..1293695b799 --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/Makefile @@ -0,0 +1,20 @@ +-include ../tools.mk + +# FIXME: ignore freebsd/windows +# on windows `rustc --dep-info` produces Makefile dependency with +# windows native paths (e.g. `c:\path\to\libfoo.a`) +# but msys make seems to fail to recognize such paths, so test fails. +ifneq ($(shell uname),FreeBSD) +ifndef IS_WINDOWS +all: + $(RUSTC) --emit dep-info main.rs + $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/include_bytes_deps/input.bin b/src/test/run-make-fulldeps/include_bytes_deps/input.bin new file mode 100644 index 00000000000..cd0875583aa --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/input.bin @@ -0,0 +1 @@ +Hello world! diff --git a/src/test/run-make-fulldeps/include_bytes_deps/input.md b/src/test/run-make-fulldeps/include_bytes_deps/input.md new file mode 100644 index 00000000000..2a19b7405f7 --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/input.md @@ -0,0 +1 @@ +# Hello, world! diff --git a/src/test/run-make-fulldeps/include_bytes_deps/input.txt b/src/test/run-make-fulldeps/include_bytes_deps/input.txt new file mode 100644 index 00000000000..cd0875583aa --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/input.txt @@ -0,0 +1 @@ +Hello world! diff --git a/src/test/run-make-fulldeps/include_bytes_deps/main.rs b/src/test/run-make-fulldeps/include_bytes_deps/main.rs new file mode 100644 index 00000000000..27ca1a46a50 --- /dev/null +++ b/src/test/run-make-fulldeps/include_bytes_deps/main.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(external_doc)] + +#[doc(include="input.md")] +pub struct SomeStruct; + +pub fn main() { + const INPUT_TXT: &'static str = include_str!("input.txt"); + const INPUT_BIN: &'static [u8] = include_bytes!("input.bin"); + + println!("{}", INPUT_TXT); + println!("{:?}", INPUT_BIN); +} diff --git a/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile b/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile new file mode 100644 index 00000000000..0cab955f644 --- /dev/null +++ b/src/test/run-make-fulldeps/inline-always-many-cgu/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2 + if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \ + echo "found call instruction when one wasn't expected"; \ + exit 1; \ + fi diff --git a/src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs b/src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs new file mode 100644 index 00000000000..539dcdfa9b3 --- /dev/null +++ b/src/test/run-make-fulldeps/inline-always-many-cgu/foo.rs @@ -0,0 +1,25 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +pub mod a { + #[inline(always)] + pub fn foo() { + } + + pub fn bar() { + } +} + +#[no_mangle] +pub fn bar() { + a::foo(); +} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile b/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile new file mode 100644 index 00000000000..1268022e37b --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# The rust crate foo will link to the native library foo, while the rust crate +# bar will link to the native library bar. There is also a dependency between +# the native library bar to the natibe library foo. +# +# This test ensures that the ordering of -lfoo and -lbar on the command line is +# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo' +# library will be stripped out, and the linkage will fail. + +all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(RUSTC) main.rs -Z print-link-args diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/bar.c b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.c new file mode 100644 index 00000000000..c761f029eff --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.c @@ -0,0 +1,4 @@ +// ignore-license +void foo(); + +void bar() { foo(); } diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs new file mode 100644 index 00000000000..1963976b4b0 --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/bar.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern crate foo; + +#[link(name = "bar", kind = "static")] +extern { + fn bar(); +} + +pub fn doit() { + unsafe { bar(); } +} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/foo.c b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.c new file mode 100644 index 00000000000..2895ad473bf --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.c @@ -0,0 +1,2 @@ +// ignore-license +void foo() {} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs new file mode 100644 index 00000000000..7a0fe6bb18f --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/foo.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "foo", kind = "static")] +extern { + fn foo(); +} + +pub fn doit() { + unsafe { foo(); } +} diff --git a/src/test/run-make-fulldeps/interdependent-c-libraries/main.rs b/src/test/run-make-fulldeps/interdependent-c-libraries/main.rs new file mode 100644 index 00000000000..f42e3dd44a9 --- /dev/null +++ b/src/test/run-make-fulldeps/interdependent-c-libraries/main.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; +extern crate bar; + +fn main() { + bar::doit(); +} diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile new file mode 100644 index 00000000000..305e8a7ddc9 --- /dev/null +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +ifndef IS_WINDOWS +# The assembly for exit-unreachable.rs should be shorter because it's missing +# (at minimum) a return instruction. + +all: + $(RUSTC) -O --emit asm exit-ret.rs + $(RUSTC) -O --emit asm exit-unreachable.rs + test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s` +else +# Because of Windows exception handling, the code is not necessarily any shorter. +# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466 +all: +endif diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs new file mode 100644 index 00000000000..1b8b644dd78 --- /dev/null +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-ret.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(asm)] +#![crate_type="lib"] + +#[deny(unreachable_code)] +pub fn exit(n: usize) -> i32 { + unsafe { + // Pretend this asm is an exit() syscall. + asm!("" :: "r"(n) :: "volatile"); + // Can't actually reach this point, but rustc doesn't know that. + } + // This return value is just here to generate some extra code for a return + // value, making it easier for the test script to detect whether the + // compiler deleted it. + 42 +} diff --git a/src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs new file mode 100644 index 00000000000..de63809ab66 --- /dev/null +++ b/src/test/run-make-fulldeps/intrinsic-unreachable/exit-unreachable.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(asm, core_intrinsics)] +#![crate_type="lib"] + +use std::intrinsics; + +#[allow(unreachable_code)] +pub fn exit(n: usize) -> i32 { + unsafe { + // Pretend this asm is an exit() syscall. + asm!("" :: "r"(n) :: "volatile"); + intrinsics::unreachable() + } + // This return value is just here to generate some extra code for a return + // value, making it easier for the test script to detect whether the + // compiler deleted it. + 42 +} diff --git a/src/test/run-make-fulldeps/invalid-library/Makefile b/src/test/run-make-fulldeps/invalid-library/Makefile new file mode 100644 index 00000000000..b6fb122d98b --- /dev/null +++ b/src/test/run-make-fulldeps/invalid-library/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + touch $(TMPDIR)/rust.metadata.bin + $(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/rust.metadata.bin + $(RUSTC) foo.rs 2>&1 | $(CGREP) "can't find crate for" diff --git a/src/test/run-make-fulldeps/invalid-library/foo.rs b/src/test/run-make-fulldeps/invalid-library/foo.rs new file mode 100644 index 00000000000..6316cfa3bba --- /dev/null +++ b/src/test/run-make-fulldeps/invalid-library/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() {} diff --git a/src/test/run-make-fulldeps/invalid-staticlib/Makefile b/src/test/run-make-fulldeps/invalid-staticlib/Makefile new file mode 100644 index 00000000000..3a91902ccce --- /dev/null +++ b/src/test/run-make-fulldeps/invalid-staticlib/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + touch $(TMPDIR)/libfoo.a + echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | $(CGREP) "failed to add native library" diff --git a/src/test/run-make-fulldeps/issue-11908/Makefile b/src/test/run-make-fulldeps/issue-11908/Makefile new file mode 100644 index 00000000000..cf6572c27ad --- /dev/null +++ b/src/test/run-make-fulldeps/issue-11908/Makefile @@ -0,0 +1,21 @@ +# This test ensures that if you have the same rlib or dylib at two locations +# in the same path that you don't hit an assertion in the compiler. +# +# Note that this relies on `liburl` to be in the path somewhere else, +# and then our aux-built libraries will collide with liburl (they have +# the same version listed) + +-include ../tools.mk + +all: + mkdir $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic + mv $(call DYLIB,foo) $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic + $(RUSTC) bar.rs -L $(TMPDIR)/other + rm -rf $(TMPDIR) + mkdir -p $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=rlib + mv $(TMPDIR)/libfoo.rlib $(TMPDIR)/other + $(RUSTC) foo.rs --crate-type=rlib + $(RUSTC) bar.rs -L $(TMPDIR)/other diff --git a/src/test/run-make-fulldeps/issue-11908/bar.rs b/src/test/run-make-fulldeps/issue-11908/bar.rs new file mode 100644 index 00000000000..6316cfa3bba --- /dev/null +++ b/src/test/run-make-fulldeps/issue-11908/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-11908/foo.rs b/src/test/run-make-fulldeps/issue-11908/foo.rs new file mode 100644 index 00000000000..0858d3c4e47 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-11908/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] diff --git a/src/test/run-make-fulldeps/issue-14500/Makefile b/src/test/run-make-fulldeps/issue-14500/Makefile new file mode 100644 index 00000000000..bd94db09520 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/Makefile @@ -0,0 +1,17 @@ +-include ../tools.mk + +# Test to make sure that reachable extern fns are always available in final +# productcs, including when LTO is used. In this test, the `foo` crate has a +# reahable symbol, and is a dependency of the `bar` crate. When the `bar` crate +# is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the +# only way that `foo.c` will successfully compile. + +ifeq ($(UNAME),Bitrig) + EXTRACFLAGS := -lc $(EXTRACFLAGS) $(EXTRACXXFLAGS) +endif + +all: + $(RUSTC) foo.rs --crate-type=rlib + $(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a + $(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo) + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/issue-14500/bar.rs b/src/test/run-make-fulldeps/issue-14500/bar.rs new file mode 100644 index 00000000000..4b4916fe96d --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; diff --git a/src/test/run-make-fulldeps/issue-14500/foo.c b/src/test/run-make-fulldeps/issue-14500/foo.c new file mode 100644 index 00000000000..e84b5509c50 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/foo.c @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void foo(); +extern char FOO_STATIC; + +int main() { + foo(); + return (int)FOO_STATIC; +} diff --git a/src/test/run-make-fulldeps/issue-14500/foo.rs b/src/test/run-make-fulldeps/issue-14500/foo.rs new file mode 100644 index 00000000000..a91d8d6a21d --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14500/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn foo() {} + +#[no_mangle] +pub static FOO_STATIC: u8 = 0; diff --git a/src/test/run-make-fulldeps/issue-14698/Makefile b/src/test/run-make-fulldeps/issue-14698/Makefile new file mode 100644 index 00000000000..dbe8317dbc4 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14698/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | $(CGREP) "couldn't create a temp dir:" diff --git a/src/test/run-make-fulldeps/issue-14698/foo.rs b/src/test/run-make-fulldeps/issue-14698/foo.rs new file mode 100644 index 00000000000..7dc79f2043b --- /dev/null +++ b/src/test/run-make-fulldeps/issue-14698/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-15460/Makefile b/src/test/run-make-fulldeps/issue-15460/Makefile new file mode 100644 index 00000000000..846805686a1 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) + $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic + $(RUSTC) bar.rs + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/issue-15460/bar.rs b/src/test/run-make-fulldeps/issue-15460/bar.rs new file mode 100644 index 00000000000..46777f7fbd2 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/bar.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; +fn main() { + unsafe { foo::foo() } +} diff --git a/src/test/run-make-fulldeps/issue-15460/foo.c b/src/test/run-make-fulldeps/issue-15460/foo.c new file mode 100644 index 00000000000..fdf595b574e --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/foo.c @@ -0,0 +1,6 @@ +// ignore-license + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void foo() {} diff --git a/src/test/run-make-fulldeps/issue-15460/foo.rs b/src/test/run-make-fulldeps/issue-15460/foo.rs new file mode 100644 index 00000000000..6917fa55579 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-15460/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +#[link(name = "foo", kind = "static")] +extern { + pub fn foo(); +} diff --git a/src/test/run-make-fulldeps/issue-18943/Makefile b/src/test/run-make-fulldeps/issue-18943/Makefile new file mode 100644 index 00000000000..bef70a0edaa --- /dev/null +++ b/src/test/run-make-fulldeps/issue-18943/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +# Regression test for ICE #18943 when compiling as lib + +all: + $(RUSTC) foo.rs --crate-type lib + $(call REMOVE_RLIBS,foo) && exit 0 || exit 1 diff --git a/src/test/run-make-fulldeps/issue-18943/foo.rs b/src/test/run-make-fulldeps/issue-18943/foo.rs new file mode 100644 index 00000000000..aadf0f593e7 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-18943/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Foo { } + +trait Bar { } + +impl<'a> Foo for Bar + 'a { } + diff --git a/src/test/run-make-fulldeps/issue-19371/Makefile b/src/test/run-make-fulldeps/issue-19371/Makefile new file mode 100644 index 00000000000..9f3ec78465b --- /dev/null +++ b/src/test/run-make-fulldeps/issue-19371/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# This test ensures that rustc compile_input can be called twice in one task +# without causing a panic. +# The program needs the path to rustc to get sysroot. + +all: + $(RUSTC) foo.rs + $(call RUN,foo $(TMPDIR) $(RUSTC)) diff --git a/src/test/run-make-fulldeps/issue-19371/foo.rs b/src/test/run-make-fulldeps/issue-19371/foo.rs new file mode 100644 index 00000000000..e0db2627d85 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-19371/foo.rs @@ -0,0 +1,88 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_private)] + +extern crate rustc; +extern crate rustc_driver; +extern crate rustc_lint; +extern crate rustc_metadata; +extern crate rustc_errors; +extern crate rustc_trans_utils; +extern crate syntax; + +use rustc::session::{build_session, Session}; +use rustc::session::config::{basic_options, Input, + OutputType, OutputTypes}; +use rustc_driver::driver::{compile_input, CompileController}; +use rustc_metadata::cstore::CStore; +use rustc_errors::registry::Registry; +use syntax::codemap::FileName; +use rustc_trans_utils::trans_crate::TransCrate; + +use std::path::PathBuf; +use std::rc::Rc; + +fn main() { + let src = r#" + fn main() {} + "#; + + let args: Vec = std::env::args().collect(); + + if args.len() < 4 { + panic!("expected rustc path"); + } + + let tmpdir = PathBuf::from(&args[1]); + + let mut sysroot = PathBuf::from(&args[3]); + sysroot.pop(); + sysroot.pop(); + + compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); + + compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); +} + +fn basic_sess(sysroot: PathBuf) -> (Session, Rc, Box) { + let mut opts = basic_options(); + opts.output_types = OutputTypes::new(&[(OutputType::Exe, None)]); + opts.maybe_sysroot = Some(sysroot); + if let Ok(linker) = std::env::var("RUSTC_LINKER") { + opts.cg.linker = Some(linker.into()); + } + + let descriptions = Registry::new(&rustc::DIAGNOSTICS); + let sess = build_session(opts, None, descriptions); + let trans = rustc_driver::get_trans(&sess); + let cstore = Rc::new(CStore::new(trans.metadata_loader())); + rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); + (sess, cstore, trans) +} + +fn compile(code: String, output: PathBuf, sysroot: PathBuf) { + syntax::with_globals(|| { + let (sess, cstore, trans) = basic_sess(sysroot); + let control = CompileController::basic(); + let input = Input::Str { name: FileName::Anon, input: code }; + let _ = compile_input( + trans, + &sess, + &cstore, + &None, + &input, + &None, + &Some(output), + None, + &control + ); + }); +} diff --git a/src/test/run-make-fulldeps/issue-20626/Makefile b/src/test/run-make-fulldeps/issue-20626/Makefile new file mode 100644 index 00000000000..0487b240400 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-20626/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +# Test output to be four +# The original error only occurred when printing, not when comparing using assert! + +all: + $(RUSTC) foo.rs -O + [ `$(call RUN,foo)` = "4" ] diff --git a/src/test/run-make-fulldeps/issue-20626/foo.rs b/src/test/run-make-fulldeps/issue-20626/foo.rs new file mode 100644 index 00000000000..9f727607e4e --- /dev/null +++ b/src/test/run-make-fulldeps/issue-20626/foo.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn identity(a: &u32) -> &u32 { a } + +fn print_foo(f: &fn(&u32) -> &u32, x: &u32) { + print!("{}", (*f)(x)); +} + +fn main() { + let x = &4; + let f: fn(&u32) -> &u32 = identity; + + // Didn't print 4 on optimized builds + print_foo(&f, x); +} diff --git a/src/test/run-make-fulldeps/issue-22131/Makefile b/src/test/run-make-fulldeps/issue-22131/Makefile new file mode 100644 index 00000000000..6db737a9e72 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-22131/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: foo.rs + $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs + $(RUSTDOC) --test --cfg 'feature="bar"' \ + -L $(TMPDIR) foo.rs |\ + $(CGREP) 'foo.rs - foo (line 11) ... ok' diff --git a/src/test/run-make-fulldeps/issue-22131/foo.rs b/src/test/run-make-fulldeps/issue-22131/foo.rs new file mode 100644 index 00000000000..50c63abc0d4 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-22131/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/// ```rust +/// assert_eq!(foo::foo(), 1); +/// ``` +#[cfg(feature = "bar")] +pub fn foo() -> i32 { 1 } diff --git a/src/test/run-make-fulldeps/issue-24445/Makefile b/src/test/run-make-fulldeps/issue-24445/Makefile new file mode 100644 index 00000000000..2ed971bf7d9 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-24445/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +ifeq ($(UNAME),Linux) +all: + $(RUSTC) foo.rs + $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo + $(call RUN,foo) + $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo + $(call RUN,foo) +else +all: +endif diff --git a/src/test/run-make-fulldeps/issue-24445/foo.c b/src/test/run-make-fulldeps/issue-24445/foo.c new file mode 100644 index 00000000000..775e151f236 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-24445/foo.c @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/issue-24445/foo.rs b/src/test/run-make-fulldeps/issue-24445/foo.rs new file mode 100644 index 00000000000..65e505df5ef --- /dev/null +++ b/src/test/run-make-fulldeps/issue-24445/foo.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +struct Destroy; +impl Drop for Destroy { + fn drop(&mut self) { println!("drop"); } +} + +thread_local! { + static X: Destroy = Destroy +} + +#[no_mangle] +pub extern "C" fn foo() { + X.with(|_| ()); +} diff --git a/src/test/run-make-fulldeps/issue-25581/Makefile b/src/test/run-make-fulldeps/issue-25581/Makefile new file mode 100644 index 00000000000..042048ec25f --- /dev/null +++ b/src/test/run-make-fulldeps/issue-25581/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,test) + $(RUSTC) test.rs + $(call RUN,test) || exit 1 diff --git a/src/test/run-make-fulldeps/issue-25581/test.c b/src/test/run-make-fulldeps/issue-25581/test.c new file mode 100644 index 00000000000..5736b173021 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-25581/test.c @@ -0,0 +1,16 @@ +// ignore-license +#include +#include + +struct ByteSlice { + uint8_t *data; + size_t len; +}; + +size_t slice_len(struct ByteSlice bs) { + return bs.len; +} + +uint8_t slice_elem(struct ByteSlice bs, size_t idx) { + return bs.data[idx]; +} diff --git a/src/test/run-make-fulldeps/issue-25581/test.rs b/src/test/run-make-fulldeps/issue-25581/test.rs new file mode 100644 index 00000000000..6717d16cb7c --- /dev/null +++ b/src/test/run-make-fulldeps/issue-25581/test.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(libc)] + +extern crate libc; + +#[link(name = "test", kind = "static")] +extern { + fn slice_len(s: &[u8]) -> libc::size_t; + fn slice_elem(s: &[u8], idx: libc::size_t) -> u8; +} + +fn main() { + let data = [1,2,3,4,5]; + + unsafe { + assert_eq!(data.len(), slice_len(&data) as usize); + assert_eq!(data[0], slice_elem(&data, 0)); + assert_eq!(data[1], slice_elem(&data, 1)); + assert_eq!(data[2], slice_elem(&data, 2)); + assert_eq!(data[3], slice_elem(&data, 3)); + assert_eq!(data[4], slice_elem(&data, 4)); + } +} diff --git a/src/test/run-make-fulldeps/issue-26006/Makefile b/src/test/run-make-fulldeps/issue-26006/Makefile new file mode 100644 index 00000000000..66aa78d5386 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26006/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +OUT := $(TMPDIR)/out + +ifndef IS_WINDOWS +all: time + +time: libc + mkdir -p $(OUT)/time $(OUT)/time/deps + ln -sf $(OUT)/libc/liblibc.rlib $(OUT)/time/deps/ + $(RUSTC) in/time/lib.rs -Ldependency=$(OUT)/time/deps/ + +libc: + mkdir -p $(OUT)/libc + $(RUSTC) in/libc/lib.rs --crate-name=libc -Cmetadata=foo -o $(OUT)/libc/liblibc.rlib +else +all: +endif diff --git a/src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs b/src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs new file mode 100644 index 00000000000..177ffdce062 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26006/in/libc/lib.rs @@ -0,0 +1,12 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![crate_type="rlib"] + +pub fn something(){} diff --git a/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs b/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs new file mode 100644 index 00000000000..b1d07d57337 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26006/in/time/lib.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![feature(libc)] +extern crate libc; + +fn main(){} diff --git a/src/test/run-make-fulldeps/issue-26092/Makefile b/src/test/run-make-fulldeps/issue-26092/Makefile new file mode 100644 index 00000000000..27631c31c4a --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26092/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTC) -o "" blank.rs 2>&1 | $(CGREP) -i 'No such file or directory' diff --git a/src/test/run-make-fulldeps/issue-26092/blank.rs b/src/test/run-make-fulldeps/issue-26092/blank.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-26092/blank.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-28595/Makefile b/src/test/run-make-fulldeps/issue-28595/Makefile new file mode 100644 index 00000000000..61e9d0c6547 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b) + $(RUSTC) a.rs + $(RUSTC) b.rs + $(call RUN,b) diff --git a/src/test/run-make-fulldeps/issue-28595/a.c b/src/test/run-make-fulldeps/issue-28595/a.c new file mode 100644 index 00000000000..feacd7bc313 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/a.c @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void a(void) {} diff --git a/src/test/run-make-fulldeps/issue-28595/a.rs b/src/test/run-make-fulldeps/issue-28595/a.rs new file mode 100644 index 00000000000..7377a9f3416 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/a.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "a", kind = "static")] +extern { + pub fn a(); +} diff --git a/src/test/run-make-fulldeps/issue-28595/b.c b/src/test/run-make-fulldeps/issue-28595/b.c new file mode 100644 index 00000000000..de81fbcaa60 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/b.c @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void a(void); + +void b(void) { + a(); +} + diff --git a/src/test/run-make-fulldeps/issue-28595/b.rs b/src/test/run-make-fulldeps/issue-28595/b.rs new file mode 100644 index 00000000000..37ff346c3f3 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28595/b.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate a; + +#[link(name = "b", kind = "static")] +extern { + pub fn b(); +} + + +fn main() { + unsafe { b(); } +} diff --git a/src/test/run-make-fulldeps/issue-28766/Makefile b/src/test/run-make-fulldeps/issue-28766/Makefile new file mode 100644 index 00000000000..1f47ef15b27 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28766/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -O foo.rs + $(RUSTC) -O -L $(TMPDIR) main.rs diff --git a/src/test/run-make-fulldeps/issue-28766/foo.rs b/src/test/run-make-fulldeps/issue-28766/foo.rs new file mode 100644 index 00000000000..3ed0a6bfc74 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28766/foo.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +pub struct Foo(()); + +impl Foo { + pub fn new() -> Foo { + Foo(()) + } +} diff --git a/src/test/run-make-fulldeps/issue-28766/main.rs b/src/test/run-make-fulldeps/issue-28766/main.rs new file mode 100644 index 00000000000..d1dadbdc7ad --- /dev/null +++ b/src/test/run-make-fulldeps/issue-28766/main.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] +extern crate foo; +use foo::Foo; + +pub fn crash() -> Box { + Box::new(Foo::new()) +} diff --git a/src/test/run-make-fulldeps/issue-30063/Makefile b/src/test/run-make-fulldeps/issue-30063/Makefile new file mode 100644 index 00000000000..a76051dc81e --- /dev/null +++ b/src/test/run-make-fulldeps/issue-30063/Makefile @@ -0,0 +1,35 @@ +-include ../tools.mk + +all: + rm -f $(TMPDIR)/foo-output + $(RUSTC) -C codegen-units=4 -o $(TMPDIR)/foo-output foo.rs + rm $(TMPDIR)/foo-output + + rm -f $(TMPDIR)/asm-output + $(RUSTC) -C codegen-units=4 --emit=asm -o $(TMPDIR)/asm-output foo.rs + rm $(TMPDIR)/asm-output + + rm -f $(TMPDIR)/bc-output + $(RUSTC) -C codegen-units=4 --emit=llvm-bc -o $(TMPDIR)/bc-output foo.rs + rm $(TMPDIR)/bc-output + + rm -f $(TMPDIR)/ir-output + $(RUSTC) -C codegen-units=4 --emit=llvm-ir -o $(TMPDIR)/ir-output foo.rs + rm $(TMPDIR)/ir-output + + rm -f $(TMPDIR)/link-output + $(RUSTC) -C codegen-units=4 --emit=link -o $(TMPDIR)/link-output foo.rs + rm $(TMPDIR)/link-output + + rm -f $(TMPDIR)/obj-output + $(RUSTC) -C codegen-units=4 --emit=obj -o $(TMPDIR)/obj-output foo.rs + rm $(TMPDIR)/obj-output + + rm -f $(TMPDIR)/dep-output + $(RUSTC) -C codegen-units=4 --emit=dep-info -o $(TMPDIR)/dep-output foo.rs + rm $(TMPDIR)/dep-output + +# # (This case doesn't work yet, and may be fundamentally wrong-headed anyway.) +# rm -f $(TMPDIR)/multi-output +# $(RUSTC) -C codegen-units=4 --emit=asm,obj -o $(TMPDIR)/multi-output foo.rs +# rm $(TMPDIR)/multi-output diff --git a/src/test/run-make-fulldeps/issue-30063/foo.rs b/src/test/run-make-fulldeps/issue-30063/foo.rs new file mode 100644 index 00000000000..45f7a2c2aa6 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-30063/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/issue-33329/Makefile b/src/test/run-make-fulldeps/issue-33329/Makefile new file mode 100644 index 00000000000..591e4e3dda3 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-33329/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) --target x86_64_unknown-linux-musl main.rs 2>&1 | $(CGREP) \ + "error: Error loading target specification: Could not find specification for target" diff --git a/src/test/run-make-fulldeps/issue-33329/main.rs b/src/test/run-make-fulldeps/issue-33329/main.rs new file mode 100644 index 00000000000..e06c0a5ec2a --- /dev/null +++ b/src/test/run-make-fulldeps/issue-33329/main.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/issue-35164/Makefile b/src/test/run-make-fulldeps/issue-35164/Makefile new file mode 100644 index 00000000000..6a451656dcb --- /dev/null +++ b/src/test/run-make-fulldeps/issue-35164/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTC) main.rs --error-format json 2>&1 | $(CGREP) -e '"byte_start":490\b' '"byte_end":496\b' diff --git a/src/test/run-make-fulldeps/issue-35164/main.rs b/src/test/run-make-fulldeps/issue-35164/main.rs new file mode 100644 index 00000000000..24322a2484f --- /dev/null +++ b/src/test/run-make-fulldeps/issue-35164/main.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod submodule; + +fn main() { + submodule::foo(); +} diff --git a/src/test/run-make-fulldeps/issue-35164/submodule/mod.rs b/src/test/run-make-fulldeps/issue-35164/submodule/mod.rs new file mode 100644 index 00000000000..7847c13af78 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-35164/submodule/mod.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() { + let _MyFoo = 2; +} diff --git a/src/test/run-make-fulldeps/issue-37839/Makefile b/src/test/run-make-fulldeps/issue-37839/Makefile new file mode 100644 index 00000000000..8b3355b9622 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) a.rs && $(RUSTC) b.rs + $(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \ + --out-dir=$(TMPDIR) +endif diff --git a/src/test/run-make-fulldeps/issue-37839/a.rs b/src/test/run-make-fulldeps/issue-37839/a.rs new file mode 100644 index 00000000000..052317438c2 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/a.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +#![crate_type = "proc-macro"] diff --git a/src/test/run-make-fulldeps/issue-37839/b.rs b/src/test/run-make-fulldeps/issue-37839/b.rs new file mode 100644 index 00000000000..82f48f6d8d6 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/b.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#[macro_use] extern crate a; diff --git a/src/test/run-make-fulldeps/issue-37839/c.rs b/src/test/run-make-fulldeps/issue-37839/c.rs new file mode 100644 index 00000000000..85bece51427 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37839/c.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +extern crate b; diff --git a/src/test/run-make-fulldeps/issue-37893/Makefile b/src/test/run-make-fulldeps/issue-37893/Makefile new file mode 100644 index 00000000000..c7732cc2682 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs +endif diff --git a/src/test/run-make-fulldeps/issue-37893/a.rs b/src/test/run-make-fulldeps/issue-37893/a.rs new file mode 100644 index 00000000000..052317438c2 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/a.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused)] +#![crate_type = "proc-macro"] diff --git a/src/test/run-make-fulldeps/issue-37893/b.rs b/src/test/run-make-fulldeps/issue-37893/b.rs new file mode 100644 index 00000000000..82f48f6d8d6 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/b.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#[macro_use] extern crate a; diff --git a/src/test/run-make-fulldeps/issue-37893/c.rs b/src/test/run-make-fulldeps/issue-37893/c.rs new file mode 100644 index 00000000000..eee55cc2369 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-37893/c.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] +extern crate b; +extern crate a; diff --git a/src/test/run-make-fulldeps/issue-38237/Makefile b/src/test/run-make-fulldeps/issue-38237/Makefile new file mode 100644 index 00000000000..855d958b344 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) foo.rs; $(RUSTC) bar.rs + $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR) +endif diff --git a/src/test/run-make-fulldeps/issue-38237/bar.rs b/src/test/run-make-fulldeps/issue-38237/bar.rs new file mode 100644 index 00000000000..794e08c2fe3 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/bar.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +#[derive(Debug)] +pub struct S; diff --git a/src/test/run-make-fulldeps/issue-38237/baz.rs b/src/test/run-make-fulldeps/issue-38237/baz.rs new file mode 100644 index 00000000000..c2a2c89db01 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/baz.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; +extern crate bar; + +pub struct Bar; +impl ::std::ops::Deref for Bar { + type Target = bar::S; + fn deref(&self) -> &Self::Target { unimplemented!() } +} diff --git a/src/test/run-make-fulldeps/issue-38237/foo.rs b/src/test/run-make-fulldeps/issue-38237/foo.rs new file mode 100644 index 00000000000..6fb315731de --- /dev/null +++ b/src/test/run-make-fulldeps/issue-38237/foo.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +#[proc_macro_derive(A)] +pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts } + +#[derive(Debug)] +struct S; diff --git a/src/test/run-make-fulldeps/issue-40535/Makefile b/src/test/run-make-fulldeps/issue-40535/Makefile new file mode 100644 index 00000000000..49db1d43e47 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# The ICE occurred in the following situation: +# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`) +# * `bar` declares and depends on `extern crate baz` +# * All crates built in metadata-only mode (`cargo check`) +all: + # cc https://github.com/rust-lang/rust/issues/40623 + $(RUSTC) baz.rs --emit=metadata + $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta + $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \ + $(CGREP) -v "unexpectedly panicked" + # ^ Succeeds if it doesn't find the ICE message diff --git a/src/test/run-make-fulldeps/issue-40535/bar.rs b/src/test/run-make-fulldeps/issue-40535/bar.rs new file mode 100644 index 00000000000..4c22f181975 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +extern crate baz; diff --git a/src/test/run-make-fulldeps/issue-40535/baz.rs b/src/test/run-make-fulldeps/issue-40535/baz.rs new file mode 100644 index 00000000000..737a918a039 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/baz.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/issue-40535/foo.rs b/src/test/run-make-fulldeps/issue-40535/foo.rs new file mode 100644 index 00000000000..53a8c8636b1 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-40535/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] + +extern crate bar; +extern crate baz; diff --git a/src/test/run-make-fulldeps/issue-46239/Makefile b/src/test/run-make-fulldeps/issue-46239/Makefile new file mode 100644 index 00000000000..698a605f7e9 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-46239/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) main.rs -C opt-level=1 + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/issue-46239/main.rs b/src/test/run-make-fulldeps/issue-46239/main.rs new file mode 100644 index 00000000000..3b3289168ab --- /dev/null +++ b/src/test/run-make-fulldeps/issue-46239/main.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn project(x: &(T,)) -> &T { &x.0 } + +fn dummy() {} + +fn main() { + let f = (dummy as fn(),); + (*project(&f))(); +} diff --git a/src/test/run-make-fulldeps/issue-7349/Makefile b/src/test/run-make-fulldeps/issue-7349/Makefile new file mode 100644 index 00000000000..50dc63b1deb --- /dev/null +++ b/src/test/run-make-fulldeps/issue-7349/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Test to make sure that inner functions within a polymorphic outer function +# don't get re-translated when the outer function is monomorphized. The test +# code monomorphizes the outer functions several times, but the magic constants +# used in the inner functions should each appear only once in the generated IR. + +all: + $(RUSTC) foo.rs --emit=llvm-ir + [ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ] + [ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ] diff --git a/src/test/run-make-fulldeps/issue-7349/foo.rs b/src/test/run-make-fulldeps/issue-7349/foo.rs new file mode 100644 index 00000000000..b75c82afb53 --- /dev/null +++ b/src/test/run-make-fulldeps/issue-7349/foo.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn outer() { + #[allow(dead_code)] + fn inner() -> u32 { + 8675309 + } + inner(); +} + +extern "C" fn outer_foreign() { + #[allow(dead_code)] + fn inner() -> u32 { + 11235813 + } + inner(); +} + +fn main() { + outer::(); + outer::(); + outer_foreign::(); + outer_foreign::(); +} diff --git a/src/test/run-make-fulldeps/issues-41478-43796/Makefile b/src/test/run-make-fulldeps/issues-41478-43796/Makefile new file mode 100644 index 00000000000..f9735253ab6 --- /dev/null +++ b/src/test/run-make-fulldeps/issues-41478-43796/Makefile @@ -0,0 +1,8 @@ +-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/src/test/run-make-fulldeps/issues-41478-43796/a.rs b/src/test/run-make-fulldeps/issues-41478-43796/a.rs new file mode 100644 index 00000000000..9d95f8b2585 --- /dev/null +++ b/src/test/run-make-fulldeps/issues-41478-43796/a.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +pub struct V(S); +pub trait An { + type U; +} +pub trait F { +} +impl F for V<::U> { +} diff --git a/src/test/run-make-fulldeps/libs-and-bins/Makefile b/src/test/run-make-fulldeps/libs-and-bins/Makefile new file mode 100644 index 00000000000..cc3b257a5c5 --- /dev/null +++ b/src/test/run-make-fulldeps/libs-and-bins/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs + $(call RUN,foo) + rm $(TMPDIR)/$(call DYLIB_GLOB,foo) diff --git a/src/test/run-make-fulldeps/libs-and-bins/foo.rs b/src/test/run-make-fulldeps/libs-and-bins/foo.rs new file mode 100644 index 00000000000..2ebe63928ca --- /dev/null +++ b/src/test/run-make-fulldeps/libs-and-bins/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +#![crate_type = "bin"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/libs-through-symlinks/Makefile b/src/test/run-make-fulldeps/libs-through-symlinks/Makefile new file mode 100644 index 00000000000..2f425121f66 --- /dev/null +++ b/src/test/run-make-fulldeps/libs-through-symlinks/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +ifdef IS_WINDOWS +all: +else + +NAME := $(shell $(RUSTC) --print file-names foo.rs) + +all: + mkdir -p $(TMPDIR)/outdir + $(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME) + ln -nsf outdir/$(NAME) $(TMPDIR) + RUST_LOG=rustc_metadata::loader $(RUSTC) bar.rs +endif diff --git a/src/test/run-make-fulldeps/libs-through-symlinks/bar.rs b/src/test/run-make-fulldeps/libs-through-symlinks/bar.rs new file mode 100644 index 00000000000..6316cfa3bba --- /dev/null +++ b/src/test/run-make-fulldeps/libs-through-symlinks/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() {} diff --git a/src/test/run-make-fulldeps/libs-through-symlinks/foo.rs b/src/test/run-make-fulldeps/libs-through-symlinks/foo.rs new file mode 100644 index 00000000000..dd818cf8798 --- /dev/null +++ b/src/test/run-make-fulldeps/libs-through-symlinks/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_name = "foo"] diff --git a/src/test/run-make-fulldeps/libtest-json/Makefile b/src/test/run-make-fulldeps/libtest-json/Makefile new file mode 100644 index 00000000000..ec91ddfb9f9 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# Test expected libtest's JSON output + +OUTPUT_FILE := $(TMPDIR)/libtest-json-output.json + +all: + $(RUSTC) --test f.rs + $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE) || true + + cat $(OUTPUT_FILE) | "$(PYTHON)" validate_json.py + + # Compare to output file + diff output.json $(OUTPUT_FILE) diff --git a/src/test/run-make-fulldeps/libtest-json/f.rs b/src/test/run-make-fulldeps/libtest-json/f.rs new file mode 100644 index 00000000000..5cff1f1a5b1 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/f.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[test] +fn a() { + // Should pass +} + +#[test] +fn b() { + assert!(false) +} + +#[test] +#[should_panic] +fn c() { + assert!(false); +} + +#[test] +#[ignore] +fn d() { + assert!(false); +} + diff --git a/src/test/run-make-fulldeps/libtest-json/output.json b/src/test/run-make-fulldeps/libtest-json/output.json new file mode 100644 index 00000000000..235f8cd7c72 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/output.json @@ -0,0 +1,10 @@ +{ "type": "suite", "event": "started", "test_count": "4" } +{ "type": "test", "event": "started", "name": "a" } +{ "type": "test", "name": "a", "event": "ok" } +{ "type": "test", "event": "started", "name": "b" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:18:5\nnote: Run with `RUST_BACKTRACE=1` for a backtrace.\n" } +{ "type": "test", "event": "started", "name": "c" } +{ "type": "test", "name": "c", "event": "ok" } +{ "type": "test", "event": "started", "name": "d" } +{ "type": "test", "name": "d", "event": "ignored" } +{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "allowed_fail": 0, "ignored": 1, "measured": 0, "filtered_out": "0" } diff --git a/src/test/run-make-fulldeps/libtest-json/validate_json.py b/src/test/run-make-fulldeps/libtest-json/validate_json.py new file mode 100755 index 00000000000..1e97639b524 --- /dev/null +++ b/src/test/run-make-fulldeps/libtest-json/validate_json.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +import sys +import json + +# Try to decode line in order to ensure it is a valid JSON document +for line in sys.stdin: + json.loads(line) diff --git a/src/test/run-make-fulldeps/link-arg/Makefile b/src/test/run-make-fulldeps/link-arg/Makefile new file mode 100644 index 00000000000..d7c9fd27112 --- /dev/null +++ b/src/test/run-make-fulldeps/link-arg/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk +RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" -Z print-link-args + +all: + $(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar diff --git a/src/test/run-make-fulldeps/link-arg/empty.rs b/src/test/run-make-fulldeps/link-arg/empty.rs new file mode 100644 index 00000000000..2b76fb24e5f --- /dev/null +++ b/src/test/run-make-fulldeps/link-arg/empty.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/link-cfg/Makefile b/src/test/run-make-fulldeps/link-cfg/Makefile new file mode 100644 index 00000000000..188cba5fe41 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3) + ls $(TMPDIR) + $(RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static + + $(RUSTC) no-deps.rs --cfg foo + $(call RUN,no-deps) + $(RUSTC) no-deps.rs --cfg bar + $(call RUN,no-deps) + + $(RUSTC) dep.rs + $(RUSTC) with-deps.rs --cfg foo + $(call RUN,with-deps) + $(RUSTC) with-deps.rs --cfg bar + $(call RUN,with-deps) + + $(RUSTC) dep-with-staticlib.rs + $(RUSTC) with-staticlib-deps.rs --cfg foo + $(call RUN,with-staticlib-deps) + $(RUSTC) with-staticlib-deps.rs --cfg bar + $(call RUN,with-staticlib-deps) diff --git a/src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs b/src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs new file mode 100644 index 00000000000..ecc2365ddb0 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/dep-with-staticlib.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return3", kind = "static", cfg(bar))] +extern { + pub fn my_function() -> i32; +} diff --git a/src/test/run-make-fulldeps/link-cfg/dep.rs b/src/test/run-make-fulldeps/link-cfg/dep.rs new file mode 100644 index 00000000000..7da879c2bfa --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/dep.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(link_cfg)] +#![crate_type = "rlib"] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern { + pub fn my_function() -> i32; +} diff --git a/src/test/run-make-fulldeps/link-cfg/no-deps.rs b/src/test/run-make-fulldeps/link-cfg/no-deps.rs new file mode 100644 index 00000000000..6b114106744 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/no-deps.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(link_cfg)] + +#[link(name = "return1", cfg(foo))] +#[link(name = "return2", cfg(bar))] +extern { + fn my_function() -> i32; +} + +fn main() { + unsafe { + let v = my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/src/test/run-make-fulldeps/link-cfg/return1.c b/src/test/run-make-fulldeps/link-cfg/return1.c new file mode 100644 index 00000000000..a2a3d051dd1 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/return1.c @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 1; +} diff --git a/src/test/run-make-fulldeps/link-cfg/return2.c b/src/test/run-make-fulldeps/link-cfg/return2.c new file mode 100644 index 00000000000..d6ddcccf2fb --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/return2.c @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 2; +} diff --git a/src/test/run-make-fulldeps/link-cfg/return3.c b/src/test/run-make-fulldeps/link-cfg/return3.c new file mode 100644 index 00000000000..6a3b695f208 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/return3.c @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int my_function() { + return 3; +} diff --git a/src/test/run-make-fulldeps/link-cfg/with-deps.rs b/src/test/run-make-fulldeps/link-cfg/with-deps.rs new file mode 100644 index 00000000000..799555c500a --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/with-deps.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dep; + +fn main() { + unsafe { + let v = dep::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 2); + } else { + panic!("unknown"); + } + } +} diff --git a/src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs b/src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs new file mode 100644 index 00000000000..33a9c7720e2 --- /dev/null +++ b/src/test/run-make-fulldeps/link-cfg/with-staticlib-deps.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dep_with_staticlib; + +fn main() { + unsafe { + let v = dep_with_staticlib::my_function(); + if cfg!(foo) { + assert_eq!(v, 1); + } else if cfg!(bar) { + assert_eq!(v, 3); + } else { + panic!("unknown"); + } + } +} diff --git a/src/test/run-make-fulldeps/link-path-order/Makefile b/src/test/run-make-fulldeps/link-path-order/Makefile new file mode 100644 index 00000000000..eeea0e3714e --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# Verifies that the -L arguments given to the linker is in the same order +# as the -L arguments on the rustc command line. + +CORRECT_DIR=$(TMPDIR)/correct +WRONG_DIR=$(TMPDIR)/wrong + +F := $(call NATIVE_STATICLIB_FILE,foo) + +all: $(call NATIVE_STATICLIB,correct) $(call NATIVE_STATICLIB,wrong) + mkdir -p $(CORRECT_DIR) $(WRONG_DIR) + mv $(call NATIVE_STATICLIB,correct) $(CORRECT_DIR)/$(F) + mv $(call NATIVE_STATICLIB,wrong) $(WRONG_DIR)/$(F) + $(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR) + $(call RUN,should_succeed) + $(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR) + $(call FAIL,should_fail) diff --git a/src/test/run-make-fulldeps/link-path-order/correct.c b/src/test/run-make-fulldeps/link-path-order/correct.c new file mode 100644 index 00000000000..a595939f92e --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/correct.c @@ -0,0 +1,2 @@ +// ignore-license +int should_return_one() { return 1; } diff --git a/src/test/run-make-fulldeps/link-path-order/main.rs b/src/test/run-make-fulldeps/link-path-order/main.rs new file mode 100644 index 00000000000..aaac3927f1c --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/main.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(libc, exit_status)] + +extern crate libc; + +#[link(name="foo", kind = "static")] +extern { + fn should_return_one() -> libc::c_int; +} + +fn main() { + let result = unsafe { + should_return_one() + }; + + if result != 1 { + std::process::exit(255); + } +} diff --git a/src/test/run-make-fulldeps/link-path-order/wrong.c b/src/test/run-make-fulldeps/link-path-order/wrong.c new file mode 100644 index 00000000000..c53e7e3c48c --- /dev/null +++ b/src/test/run-make-fulldeps/link-path-order/wrong.c @@ -0,0 +1,2 @@ +// ignore-license +int should_return_one() { return 0; } diff --git a/src/test/run-make-fulldeps/linkage-attr-on-static/Makefile b/src/test/run-make-fulldeps/linkage-attr-on-static/Makefile new file mode 100644 index 00000000000..4befbe14465 --- /dev/null +++ b/src/test/run-make-fulldeps/linkage-attr-on-static/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) + $(RUSTC) bar.rs + $(call RUN,bar) || exit 1 diff --git a/src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs b/src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs new file mode 100644 index 00000000000..274401c448b --- /dev/null +++ b/src/test/run-make-fulldeps/linkage-attr-on-static/bar.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(linkage)] + +#[no_mangle] +#[linkage = "external"] +static BAZ: i32 = 21; + +#[link(name = "foo", kind = "static")] +extern { + fn what() -> i32; +} + +fn main() { + unsafe { + assert_eq!(what(), BAZ); + } +} diff --git a/src/test/run-make-fulldeps/linkage-attr-on-static/foo.c b/src/test/run-make-fulldeps/linkage-attr-on-static/foo.c new file mode 100644 index 00000000000..d7d33ea12e8 --- /dev/null +++ b/src/test/run-make-fulldeps/linkage-attr-on-static/foo.c @@ -0,0 +1,8 @@ +// ignore-license +#include + +extern int32_t BAZ; + +int32_t what() { + return BAZ; +} diff --git a/src/test/run-make-fulldeps/linker-output-non-utf8/Makefile b/src/test/run-make-fulldeps/linker-output-non-utf8/Makefile new file mode 100644 index 00000000000..5f1577ab44d --- /dev/null +++ b/src/test/run-make-fulldeps/linker-output-non-utf8/Makefile @@ -0,0 +1,32 @@ +-include ../tools.mk + +# Make sure we don't ICE if the linker prints a non-UTF-8 error message. + +# Ignore Windows and Apple + +# This does not work in its current form on windows, possibly due to +# gcc bugs or something about valid Windows paths. See issue #29151 +# for more information. +ifndef IS_WINDOWS + +# This also does not work on Apple APFS due to the filesystem requiring +# valid UTF-8 paths. +ifneq ($(shell uname),Darwin) + +# The zzz it to allow humans to tab complete or glob this thing. +bad_dir := $(TMPDIR)/zzz$$'\xff' + +all: + $(RUSTC) library.rs + mkdir $(bad_dir) + mv $(TMPDIR)/liblibrary.a $(bad_dir) + LIBRARY_PATH=$(bad_dir) $(RUSTC) exec.rs 2>&1 | $(CGREP) this_symbol_not_defined +else +all: + +endif + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs b/src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs new file mode 100644 index 00000000000..1c03eb479fd --- /dev/null +++ b/src/test/run-make-fulldeps/linker-output-non-utf8/exec.rs @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name="library")] +extern "C" { + fn foo(); +} + +fn main() { unsafe { foo(); } } diff --git a/src/test/run-make-fulldeps/linker-output-non-utf8/library.rs b/src/test/run-make-fulldeps/linker-output-non-utf8/library.rs new file mode 100644 index 00000000000..194be26424a --- /dev/null +++ b/src/test/run-make-fulldeps/linker-output-non-utf8/library.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +extern "C" { + fn this_symbol_not_defined(); +} + +#[no_mangle] +pub extern "C" fn foo() { + unsafe { this_symbol_not_defined(); } +} diff --git a/src/test/run-make-fulldeps/llvm-pass/Makefile b/src/test/run-make-fulldeps/llvm-pass/Makefile new file mode 100644 index 00000000000..8a18aadf36a --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/Makefile @@ -0,0 +1,28 @@ +-include ../tools.mk + +ifeq ($(UNAME),Darwin) +PLUGIN_FLAGS := -C link-args=-Wl,-undefined,dynamic_lookup +endif + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +# Windows doesn't correctly handle include statements with escaping paths, +# so this test will not get run on Windows. +ifdef IS_WINDOWS +all: +else +all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass) + $(RUSTC) plugin.rs -C prefer-dynamic $(PLUGIN_FLAGS) + $(RUSTC) main.rs + +$(TMPDIR)/libllvm-function-pass.o: + $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o + +$(TMPDIR)/libllvm-module-pass.o: + $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o +endif + +endif diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc new file mode 100644 index 00000000000..880c9bce562 --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc @@ -0,0 +1,61 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include +#include + +#include "llvm/Pass.h" +#include "llvm/IR/Function.h" + +using namespace llvm; + +namespace { + + class TestLLVMPass : public FunctionPass { + + public: + + static char ID; + TestLLVMPass() : FunctionPass(ID) { } + + bool runOnFunction(Function &F) override; + +#if LLVM_VERSION_MAJOR >= 4 + StringRef +#else + const char * +#endif + getPassName() const override { + return "Some LLVM pass"; + } + + }; + +} + +bool TestLLVMPass::runOnFunction(Function &F) { + // A couple examples of operations that previously caused segmentation faults + // https://github.com/rust-lang/rust/issues/31067 + + for (auto N = F.begin(); N != F.end(); ++N) { + /* code */ + } + + LLVMContext &C = F.getContext(); + IntegerType *Int8Ty = IntegerType::getInt8Ty(C); + PointerType::get(Int8Ty, 0); + return true; +} + +char TestLLVMPass::ID = 0; + +static RegisterPass RegisterAFLPass( + "some-llvm-function-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc new file mode 100644 index 00000000000..280eca7e8f0 --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc @@ -0,0 +1,60 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include +#include + +#include "llvm/IR/Module.h" + +using namespace llvm; + +namespace { + + class TestLLVMPass : public ModulePass { + + public: + + static char ID; + TestLLVMPass() : ModulePass(ID) { } + + bool runOnModule(Module &M) override; + +#if LLVM_VERSION_MAJOR >= 4 + StringRef +#else + const char * +#endif + getPassName() const override { + return "Some LLVM pass"; + } + + }; + +} + +bool TestLLVMPass::runOnModule(Module &M) { + // A couple examples of operations that previously caused segmentation faults + // https://github.com/rust-lang/rust/issues/31067 + + for (auto F = M.begin(); F != M.end(); ++F) { + /* code */ + } + + LLVMContext &C = M.getContext(); + IntegerType *Int8Ty = IntegerType::getInt8Ty(C); + PointerType::get(Int8Ty, 0); + return true; +} + +char TestLLVMPass::ID = 0; + +static RegisterPass RegisterAFLPass( + "some-llvm-module-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/main.rs b/src/test/run-make-fulldeps/llvm-pass/main.rs new file mode 100644 index 00000000000..5b5ab94bcef --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/main.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin)] +#![plugin(some_plugin)] + +fn main() {} diff --git a/src/test/run-make-fulldeps/llvm-pass/plugin.rs b/src/test/run-make-fulldeps/llvm-pass/plugin.rs new file mode 100644 index 00000000000..f77b2fca857 --- /dev/null +++ b/src/test/run-make-fulldeps/llvm-pass/plugin.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(plugin_registrar, rustc_private)] +#![crate_type = "dylib"] +#![crate_name = "some_plugin"] + +extern crate rustc; +extern crate rustc_plugin; + +#[link(name = "llvm-function-pass", kind = "static")] +#[link(name = "llvm-module-pass", kind = "static")] +extern {} + +use rustc_plugin::registry::Registry; + +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_llvm_pass("some-llvm-function-pass"); + reg.register_llvm_pass("some-llvm-module-pass"); +} diff --git a/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile new file mode 100644 index 00000000000..debe9e93824 --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -g + cp foo.bat $(TMPDIR)/ + OUT_DIR="$(TMPDIR)" RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat new file mode 100644 index 00000000000..a9350f12bbb --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.bat @@ -0,0 +1 @@ +%MY_LINKER% %* diff --git a/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs new file mode 100644 index 00000000000..67d8ad0b672 --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines-cmd-exe/foo.rs @@ -0,0 +1,111 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Like the `long-linker-command-lines` test this test attempts to blow +// a command line limit for running the linker. Unlike that test, however, +// this test is testing `cmd.exe` specifically rather than the OS. +// +// Unfortunately `cmd.exe` has a 8192 limit which is relatively small +// in the grand scheme of things and anyone sripting rustc's linker +// is probably using a `*.bat` script and is likely to hit this limit. +// +// This test uses a `foo.bat` script as the linker which just simply +// delegates back to this program. The compiler should use a lower +// limit for arguments before passing everything via `@`, which +// means that everything should still succeed here. + +use std::env; +use std::fs::{self, File}; +use std::io::{BufWriter, Write, Read}; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + if !cfg!(windows) { + return + } + + let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); + let ok = tmpdir.join("ok"); + let not_ok = tmpdir.join("not_ok"); + if env::var("YOU_ARE_A_LINKER").is_ok() { + match env::args_os().find(|a| a.to_string_lossy().contains("@")) { + Some(file) => { + let file = file.to_str().unwrap(); + fs::copy(&file[1..], &ok).unwrap(); + } + None => { File::create(¬_ok).unwrap(); } + } + return + } + + let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); + let me = env::current_exe().unwrap(); + let bat = me.parent() + .unwrap() + .join("foo.bat"); + let bat_linker = format!("linker={}", bat.display()); + for i in (1..).map(|i| i * 10) { + println!("attempt: {}", i); + + let file = tmpdir.join("bar.rs"); + let mut f = BufWriter::new(File::create(&file).unwrap()); + let mut lib_name = String::new(); + for _ in 0..i { + lib_name.push_str("foo"); + } + for j in 0..i { + writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); + } + writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); + f.into_inner().unwrap(); + + drop(fs::remove_file(&ok)); + drop(fs::remove_file(¬_ok)); + let status = Command::new(&rustc) + .arg(&file) + .arg("-C").arg(&bat_linker) + .arg("--out-dir").arg(&tmpdir) + .env("YOU_ARE_A_LINKER", "1") + .env("MY_LINKER", &me) + .status() + .unwrap(); + + if !status.success() { + panic!("rustc didn't succeed: {}", status); + } + + if !ok.exists() { + assert!(not_ok.exists()); + continue + } + + let mut contents = Vec::new(); + File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); + + for j in 0..i { + let exp = format!("{}{}", lib_name, j); + let exp = if cfg!(target_env = "msvc") { + let mut out = Vec::with_capacity(exp.len() * 2); + for c in exp.encode_utf16() { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + exp.into_bytes() + }; + assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); + } + + break + } +} diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/Makefile b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile new file mode 100644 index 00000000000..5876fbc94bc --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -g -O + RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/long-linker-command-lines/foo.rs b/src/test/run-make-fulldeps/long-linker-command-lines/foo.rs new file mode 100644 index 00000000000..2ac240982af --- /dev/null +++ b/src/test/run-make-fulldeps/long-linker-command-lines/foo.rs @@ -0,0 +1,101 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This is a test which attempts to blow out the system limit with how many +// arguments can be passed to a process. This'll successively call rustc with +// larger and larger argument lists in an attempt to find one that's way too +// big for the system at hand. This file itself is then used as a "linker" to +// detect when the process creation succeeds. +// +// Eventually we should see an argument that looks like `@` as we switch from +// passing literal arguments to passing everything in the file. + +use std::env; +use std::fs::{self, File}; +use std::io::{BufWriter, Write, Read}; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap()); + let ok = tmpdir.join("ok"); + if env::var("YOU_ARE_A_LINKER").is_ok() { + if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) { + let file = file.to_str().expect("non-utf8 file argument"); + fs::copy(&file[1..], &ok).unwrap(); + } + return + } + + let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); + let me_as_linker = format!("linker={}", env::current_exe().unwrap().display()); + for i in (1..).map(|i| i * 100) { + println!("attempt: {}", i); + let file = tmpdir.join("bar.rs"); + let mut f = BufWriter::new(File::create(&file).unwrap()); + let mut lib_name = String::new(); + for _ in 0..i { + lib_name.push_str("foo"); + } + for j in 0..i { + writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); + } + writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); + f.into_inner().unwrap(); + + drop(fs::remove_file(&ok)); + let output = Command::new(&rustc) + .arg(&file) + .arg("-C").arg(&me_as_linker) + .arg("--out-dir").arg(&tmpdir) + .env("YOU_ARE_A_LINKER", "1") + .output() + .unwrap(); + + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + panic!("status: {}\nstdout:\n{}\nstderr:\n{}", + output.status, + String::from_utf8_lossy(&output.stdout), + stderr.lines().map(|l| { + if l.len() > 200 { + format!("{}...\n", &l[..200]) + } else { + format!("{}\n", l) + } + }).collect::()); + } + + if !ok.exists() { + continue + } + + let mut contents = Vec::new(); + File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); + + for j in 0..i { + let exp = format!("{}{}", lib_name, j); + let exp = if cfg!(target_env = "msvc") { + let mut out = Vec::with_capacity(exp.len() * 2); + for c in exp.encode_utf16() { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + exp.into_bytes() + }; + assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); + } + + break + } +} diff --git a/src/test/run-make-fulldeps/longjmp-across-rust/Makefile b/src/test/run-make-fulldeps/longjmp-across-rust/Makefile new file mode 100644 index 00000000000..9d71ed8fcf3 --- /dev/null +++ b/src/test/run-make-fulldeps/longjmp-across-rust/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) + $(RUSTC) main.rs + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/longjmp-across-rust/foo.c b/src/test/run-make-fulldeps/longjmp-across-rust/foo.c new file mode 100644 index 00000000000..eb993957674 --- /dev/null +++ b/src/test/run-make-fulldeps/longjmp-across-rust/foo.c @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#include +#include + +static jmp_buf ENV; + +extern void test_middle(); + +void test_start(void(*f)()) { + if (setjmp(ENV) != 0) + return; + f(); + assert(0); +} + +void test_end() { + longjmp(ENV, 1); + assert(0); +} diff --git a/src/test/run-make-fulldeps/longjmp-across-rust/main.rs b/src/test/run-make-fulldeps/longjmp-across-rust/main.rs new file mode 100644 index 00000000000..c420473a560 --- /dev/null +++ b/src/test/run-make-fulldeps/longjmp-across-rust/main.rs @@ -0,0 +1,40 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name = "foo", kind = "static")] +extern { + fn test_start(f: extern fn()); + fn test_end(); +} + +fn main() { + unsafe { + test_start(test_middle); + } +} + +struct A; + +impl Drop for A { + fn drop(&mut self) { + } +} + +extern fn test_middle() { + let _a = A; + foo(); +} + +fn foo() { + let _a = A; + unsafe { + test_end(); + } +} diff --git a/src/test/run-make-fulldeps/ls-metadata/Makefile b/src/test/run-make-fulldeps/ls-metadata/Makefile new file mode 100644 index 00000000000..fc3f5bce0cd --- /dev/null +++ b/src/test/run-make-fulldeps/ls-metadata/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs + $(RUSTC) -Z ls $(TMPDIR)/foo + touch $(TMPDIR)/bar + $(RUSTC) -Z ls $(TMPDIR)/bar diff --git a/src/test/run-make-fulldeps/ls-metadata/foo.rs b/src/test/run-make-fulldeps/ls-metadata/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/ls-metadata/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile new file mode 100644 index 00000000000..1d45cb413c5 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/Makefile @@ -0,0 +1,18 @@ +# Copyright 2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +-include ../tools.mk + +all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) + $(RUSTC) lib1.rs + $(RUSTC) lib2.rs + $(RUSTC) main.rs -Clto + $(call RUN,main) + diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c new file mode 100644 index 00000000000..716d1abcf34 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/bar.c @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +int foo() { + return 2; +} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c new file mode 100644 index 00000000000..1b36874581a --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/foo.c @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +int foo() { + return 1; +} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs new file mode 100644 index 00000000000..0a87c8e4725 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib1.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[link(name = "foo", kind = "static")] +extern { + fn foo() -> i32; +} + +pub fn foo1() -> i32 { + unsafe { foo() } +} diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs new file mode 100644 index 00000000000..6e3f382b3fd --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/lib2.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern crate lib1; + +#[link(name = "bar", kind = "static")] +extern { + fn foo() -> i32; +} + +pub fn foo2() -> i32 { + unsafe { foo() } +} + diff --git a/src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs new file mode 100644 index 00000000000..8417af63be9 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-no-link-whole-rlib/main.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib1; +extern crate lib2; + +fn main() { + assert_eq!(lib1::foo1(), 2); + assert_eq!(lib2::foo2(), 2); +} diff --git a/src/test/run-make-fulldeps/lto-readonly-lib/Makefile b/src/test/run-make-fulldeps/lto-readonly-lib/Makefile new file mode 100644 index 00000000000..0afbbc3450a --- /dev/null +++ b/src/test/run-make-fulldeps/lto-readonly-lib/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + + # the compiler needs to copy and modify the rlib file when performing + # LTO, so we should ensure that it can cope with the original rlib + # being read-only. + chmod 444 $(TMPDIR)/*.rlib + + $(RUSTC) main.rs -C lto + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/lto-readonly-lib/lib.rs b/src/test/run-make-fulldeps/lto-readonly-lib/lib.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-readonly-lib/lib.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/lto-readonly-lib/main.rs b/src/test/run-make-fulldeps/lto-readonly-lib/main.rs new file mode 100644 index 00000000000..e12ac9e01dc --- /dev/null +++ b/src/test/run-make-fulldeps/lto-readonly-lib/main.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib; + +fn main() {} diff --git a/src/test/run-make-fulldeps/lto-smoke-c/Makefile b/src/test/run-make-fulldeps/lto-smoke-c/Makefile new file mode 100644 index 00000000000..0f61f5de938 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke-c/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Apparently older versions of GCC segfault if -g is passed... +CC := $(CC:-g=) + +all: + $(RUSTC) foo.rs -C lto + $(CC) bar.c $(call STATICLIB,foo) \ + $(call OUT_EXE,bar) \ + $(EXTRACFLAGS) $(EXTRACXXFLAGS) + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/lto-smoke-c/bar.c b/src/test/run-make-fulldeps/lto-smoke-c/bar.c new file mode 100644 index 00000000000..5729d411c5b --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke-c/bar.c @@ -0,0 +1,7 @@ +// ignore-license +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make-fulldeps/lto-smoke-c/foo.rs b/src/test/run-make-fulldeps/lto-smoke-c/foo.rs new file mode 100644 index 00000000000..1bb19016700 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke-c/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +#[no_mangle] +pub extern "C" fn foo() {} diff --git a/src/test/run-make-fulldeps/lto-smoke/Makefile b/src/test/run-make-fulldeps/lto-smoke/Makefile new file mode 100644 index 00000000000..020252e1f8c --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + $(RUSTC) main.rs -C lto + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/lto-smoke/lib.rs b/src/test/run-make-fulldeps/lto-smoke/lib.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke/lib.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/lto-smoke/main.rs b/src/test/run-make-fulldeps/lto-smoke/main.rs new file mode 100644 index 00000000000..e12ac9e01dc --- /dev/null +++ b/src/test/run-make-fulldeps/lto-smoke/main.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib; + +fn main() {} diff --git a/src/test/run-make-fulldeps/manual-crate-name/Makefile b/src/test/run-make-fulldeps/manual-crate-name/Makefile new file mode 100644 index 00000000000..1d1419997a2 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-crate-name/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) --crate-name foo bar.rs + rm $(TMPDIR)/libfoo.rlib diff --git a/src/test/run-make-fulldeps/manual-crate-name/bar.rs b/src/test/run-make-fulldeps/manual-crate-name/bar.rs new file mode 100644 index 00000000000..04d3ae67207 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-crate-name/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] diff --git a/src/test/run-make-fulldeps/manual-link/Makefile b/src/test/run-make-fulldeps/manual-link/Makefile new file mode 100644 index 00000000000..dccf0d99b0f --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: $(TMPDIR)/libbar.a + $(RUSTC) foo.rs -lstatic=bar + $(RUSTC) main.rs + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/manual-link/bar.c b/src/test/run-make-fulldeps/manual-link/bar.c new file mode 100644 index 00000000000..3c167b45af9 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/bar.c @@ -0,0 +1,2 @@ +// ignore-license +void bar() {} diff --git a/src/test/run-make-fulldeps/manual-link/foo.c b/src/test/run-make-fulldeps/manual-link/foo.c new file mode 100644 index 00000000000..3c167b45af9 --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/foo.c @@ -0,0 +1,2 @@ +// ignore-license +void bar() {} diff --git a/src/test/run-make-fulldeps/manual-link/foo.rs b/src/test/run-make-fulldeps/manual-link/foo.rs new file mode 100644 index 00000000000..d67a4057afb --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/foo.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern { + fn bar(); +} + +pub fn foo() { + unsafe { bar(); } +} diff --git a/src/test/run-make-fulldeps/manual-link/main.rs b/src/test/run-make-fulldeps/manual-link/main.rs new file mode 100644 index 00000000000..756a47f386a --- /dev/null +++ b/src/test/run-make-fulldeps/manual-link/main.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::foo(); +} diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile new file mode 100644 index 00000000000..03a797d95f9 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/Makefile @@ -0,0 +1,36 @@ +-include ../tools.mk + +# Modelled after compile-fail/changing-crates test, but this one puts +# more than one (mismatching) candidate crate into the search path, +# which did not appear directly expressible in compile-fail/aux-build +# infrastructure. +# +# Note that we move the built libraries into target direcrtories rather than +# use the `--out-dir` option because the `../tools.mk` file already bakes a +# use of `--out-dir` into the definition of $(RUSTC). + +A1=$(TMPDIR)/a1 +A2=$(TMPDIR)/a2 +A3=$(TMPDIR)/a3 + +# A hack to match distinct lines of output from a single run. +LOG=$(TMPDIR)/log.txt + +all: + mkdir -p $(A1) $(A2) $(A3) + $(RUSTC) --crate-type=rlib crateA1.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1) + $(RUSTC) --crate-type=rlib -L $(A1) crateB.rs + $(RUSTC) --crate-type=rlib crateA2.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2) + $(RUSTC) --crate-type=rlib crateA3.rs + mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3) + # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match + $(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true + $(CGREP) \ + 'found possibly newer version of crate `crateA` which `crateB` depends on' \ + 'note: perhaps that crate needs to be recompiled?' \ + 'crate `crateA`:' \ + 'crate `crateB`:' \ + < $(LOG) + # the 'crate `crateA`' will match two entries. \ No newline at end of file diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs new file mode 100644 index 00000000000..dbfe920c85b --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA1.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="crateA"] + +// Base crate +pub fn func() {} diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs new file mode 100644 index 00000000000..857c36aee60 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="crateA"] + +// Base crate +pub fn func() { println!("hello"); } diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs new file mode 100644 index 00000000000..8b8dac5e862 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateA3.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="crateA"] + +// Base crate +pub fn foo() { println!("world!"); } diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs new file mode 100644 index 00000000000..bf55017c646 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateB.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateA; diff --git a/src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs b/src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs new file mode 100644 index 00000000000..174d9382b76 --- /dev/null +++ b/src/test/run-make-fulldeps/many-crates-but-no-match/crateC.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateB; + +fn main() {} diff --git a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile new file mode 100644 index 00000000000..09e6ae0bbf7 --- /dev/null +++ b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a + $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b + $(RUSTC) bar.rs \ + --extern foo1=$(TMPDIR)/libfoo-a.rlib \ + --extern foo2=$(TMPDIR)/libfoo-b.rlib \ + -Z print-link-args + $(call RUN,bar) diff --git a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs new file mode 100644 index 00000000000..44b9e2f874a --- /dev/null +++ b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/bar.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo1; +extern crate foo2; + +fn main() { + let a = foo1::foo(); + let b = foo2::foo(); + assert!(a as *const _ != b as *const _); +} diff --git a/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs new file mode 100644 index 00000000000..baabdc9ad7b --- /dev/null +++ b/src/test/run-make-fulldeps/metadata-flag-frobs-symbols/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "foo"] +#![crate_type = "rlib"] + +static FOO: usize = 3; + +pub fn foo() -> &'static usize { &FOO } diff --git a/src/test/run-make-fulldeps/min-global-align/Makefile b/src/test/run-make-fulldeps/min-global-align/Makefile new file mode 100644 index 00000000000..2eacc36f380 --- /dev/null +++ b/src/test/run-make-fulldeps/min-global-align/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +# This tests ensure that global variables respect the target minimum alignment. +# The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have +# type-alignment of 1, but some targets require greater global alignment. + +SRC = min_global_align.rs +LL = $(TMPDIR)/min_global_align.ll + +all: +ifeq ($(UNAME),Linux) +# Most targets are happy with default alignment -- take i686 for example. +ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) + $(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC) + [ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ] +endif +# SystemZ requires even alignment for PC-relative addressing. +ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) + $(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC) + [ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ] +endif +endif diff --git a/src/test/run-make-fulldeps/min-global-align/min_global_align.rs b/src/test/run-make-fulldeps/min-global-align/min_global_align.rs new file mode 100644 index 00000000000..3d4f9001a74 --- /dev/null +++ b/src/test/run-make-fulldeps/min-global-align/min_global_align.rs @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core, lang_items)] +#![crate_type="rlib"] +#![no_core] + +pub static STATIC_BOOL: bool = true; + +pub static mut STATIC_MUT_BOOL: bool = true; + +const CONST_BOOL: bool = true; +pub static CONST_BOOL_REF: &'static bool = &CONST_BOOL; + + +#[lang = "sized"] +trait Sized {} + +#[lang = "copy"] +trait Copy {} + +#[lang = "freeze"] +trait Freeze {} + +#[lang = "sync"] +trait Sync {} +impl Sync for bool {} +impl Sync for &'static bool {} + +#[lang="drop_in_place"] +pub unsafe fn drop_in_place(_: *mut T) { } diff --git a/src/test/run-make-fulldeps/mismatching-target-triples/Makefile b/src/test/run-make-fulldeps/mismatching-target-triples/Makefile new file mode 100644 index 00000000000..1636e41b056 --- /dev/null +++ b/src/test/run-make-fulldeps/mismatching-target-triples/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +# Issue #10814 +# +# these are no_std to avoid having to have the standard library or any +# linkers/assemblers for the relevant platform + +all: + $(RUSTC) foo.rs --target=i686-unknown-linux-gnu + $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \ + | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu' diff --git a/src/test/run-make-fulldeps/mismatching-target-triples/bar.rs b/src/test/run-make-fulldeps/mismatching-target-triples/bar.rs new file mode 100644 index 00000000000..0dc5c0a3a8e --- /dev/null +++ b/src/test/run-make-fulldeps/mismatching-target-triples/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +extern crate foo; diff --git a/src/test/run-make-fulldeps/mismatching-target-triples/foo.rs b/src/test/run-make-fulldeps/mismatching-target-triples/foo.rs new file mode 100644 index 00000000000..a2169d0c631 --- /dev/null +++ b/src/test/run-make-fulldeps/mismatching-target-triples/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/Makefile b/src/test/run-make-fulldeps/missing-crate-dependency/Makefile new file mode 100644 index 00000000000..b5a5bf492ab --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + $(RUSTC) --crate-type=rlib crateA.rs + $(RUSTC) --crate-type=rlib crateB.rs + $(call REMOVE_RLIBS,crateA) + # Ensure crateC fails to compile since dependency crateA is missing + $(RUSTC) crateC.rs 2>&1 | \ + $(CGREP) 'can'"'"'t find crate for `crateA` which `crateB` depends on' diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs b/src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs new file mode 100644 index 00000000000..4e111f29e8a --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/crateA.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Base crate +pub fn func() {} diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs b/src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs new file mode 100644 index 00000000000..bf55017c646 --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/crateB.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateA; diff --git a/src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs b/src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs new file mode 100644 index 00000000000..174d9382b76 --- /dev/null +++ b/src/test/run-make-fulldeps/missing-crate-dependency/crateC.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateB; + +fn main() {} diff --git a/src/test/run-make-fulldeps/mixing-deps/Makefile b/src/test/run-make-fulldeps/mixing-deps/Makefile new file mode 100644 index 00000000000..0e52d4a8bef --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) both.rs -C prefer-dynamic + $(RUSTC) dylib.rs -C prefer-dynamic + $(RUSTC) prog.rs + $(call RUN,prog) diff --git a/src/test/run-make-fulldeps/mixing-deps/both.rs b/src/test/run-make-fulldeps/mixing-deps/both.rs new file mode 100644 index 00000000000..c44335e2bbc --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/both.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_type = "dylib"] + +pub static foo: isize = 4; diff --git a/src/test/run-make-fulldeps/mixing-deps/dylib.rs b/src/test/run-make-fulldeps/mixing-deps/dylib.rs new file mode 100644 index 00000000000..78af525f386 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/dylib.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate both; + +use std::mem; + +pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } } diff --git a/src/test/run-make-fulldeps/mixing-deps/prog.rs b/src/test/run-make-fulldeps/mixing-deps/prog.rs new file mode 100644 index 00000000000..c3d88016fda --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-deps/prog.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dylib; +extern crate both; + +use std::mem; + +fn main() { + assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) }, + dylib::addr()); +} diff --git a/src/test/run-make-fulldeps/mixing-formats/Makefile b/src/test/run-make-fulldeps/mixing-formats/Makefile new file mode 100644 index 00000000000..48257669baf --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/Makefile @@ -0,0 +1,74 @@ +-include ../tools.mk + +# Testing various mixings of rlibs and dylibs. Makes sure that it's possible to +# link an rlib to a dylib. The dependency tree among the file looks like: +# +# foo +# / \ +# bar1 bar2 +# / \ / +# baz baz2 +# +# This is generally testing the permutations of the foo/bar1/bar2 layer against +# the baz/baz2 layer + +all: + # Building just baz + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz.rs + rm $(TMPDIR)/* + # Building baz2 + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0 + $(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0 + rm $(TMPDIR)/* + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=rlib foo.rs + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar2.rs + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=rlib bar1.rs + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs + rm $(TMPDIR)/* + $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic + $(RUSTC) --crate-type=dylib,rlib baz2.rs + $(RUSTC) --crate-type=bin baz2.rs diff --git a/src/test/run-make-fulldeps/mixing-formats/bar1.rs b/src/test/run-make-fulldeps/mixing-formats/bar1.rs new file mode 100644 index 00000000000..4b4916fe96d --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/bar1.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; diff --git a/src/test/run-make-fulldeps/mixing-formats/bar2.rs b/src/test/run-make-fulldeps/mixing-formats/bar2.rs new file mode 100644 index 00000000000..4b4916fe96d --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/bar2.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; diff --git a/src/test/run-make-fulldeps/mixing-formats/baz.rs b/src/test/run-make-fulldeps/mixing-formats/baz.rs new file mode 100644 index 00000000000..3fb90f6a854 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/baz.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar1; + +fn main() {} diff --git a/src/test/run-make-fulldeps/mixing-formats/baz2.rs b/src/test/run-make-fulldeps/mixing-formats/baz2.rs new file mode 100644 index 00000000000..c5066ccd656 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/baz2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar1; +extern crate bar2; + +fn main() {} diff --git a/src/test/run-make-fulldeps/mixing-formats/foo.rs b/src/test/run-make-fulldeps/mixing-formats/foo.rs new file mode 100644 index 00000000000..e6c76025738 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-formats/foo.rs @@ -0,0 +1,9 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/mixing-libs/Makefile b/src/test/run-make-fulldeps/mixing-libs/Makefile new file mode 100644 index 00000000000..babeeef164d --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + $(RUSTC) rlib.rs + $(RUSTC) dylib.rs + $(RUSTC) rlib.rs --crate-type=dylib + $(RUSTC) dylib.rs + $(call REMOVE_DYLIBS,rlib) + $(RUSTC) prog.rs && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/mixing-libs/dylib.rs b/src/test/run-make-fulldeps/mixing-libs/dylib.rs new file mode 100644 index 00000000000..1a5bd658cd9 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/dylib.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] +extern crate rlib; + +pub fn dylib() { rlib::rlib() } diff --git a/src/test/run-make-fulldeps/mixing-libs/prog.rs b/src/test/run-make-fulldeps/mixing-libs/prog.rs new file mode 100644 index 00000000000..5e1a4274756 --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/prog.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate dylib; +extern crate rlib; + +fn main() { + dylib::dylib(); + rlib::rlib(); +} diff --git a/src/test/run-make-fulldeps/mixing-libs/rlib.rs b/src/test/run-make-fulldeps/mixing-libs/rlib.rs new file mode 100644 index 00000000000..ad0ea67b9ab --- /dev/null +++ b/src/test/run-make-fulldeps/mixing-libs/rlib.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +pub fn rlib() {} diff --git a/src/test/run-make-fulldeps/msvc-opt-minsize/Makefile b/src/test/run-make-fulldeps/msvc-opt-minsize/Makefile new file mode 100644 index 00000000000..1095a047dd1 --- /dev/null +++ b/src/test/run-make-fulldeps/msvc-opt-minsize/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -Copt-level=z 2>&1 + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs b/src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs new file mode 100644 index 00000000000..30b12691afe --- /dev/null +++ b/src/test/run-make-fulldeps/msvc-opt-minsize/foo.rs @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(test)] +extern crate test; + +fn foo(x: i32, y: i32) -> i64 { + (x + y) as i64 +} + +#[inline(never)] +fn bar() { + let _f = Box::new(0); + // This call used to trigger an LLVM bug in opt-level z where the base + // pointer gets corrupted, see issue #45034 + let y: fn(i32, i32) -> i64 = test::black_box(foo); + test::black_box(y(1, 2)); +} + +fn main() { + bar(); +} diff --git a/src/test/run-make-fulldeps/multiple-emits/Makefile b/src/test/run-make-fulldeps/multiple-emits/Makefile new file mode 100644 index 00000000000..e126422835c --- /dev/null +++ b/src/test/run-make-fulldeps/multiple-emits/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out 2>&1 + rm $(TMPDIR)/out.ll $(TMPDIR)/out.s + $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out2.ext 2>&1 + rm $(TMPDIR)/out2.ll $(TMPDIR)/out2.s diff --git a/src/test/run-make-fulldeps/multiple-emits/foo.rs b/src/test/run-make-fulldeps/multiple-emits/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/multiple-emits/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/no-builtins-lto/Makefile b/src/test/run-make-fulldeps/no-builtins-lto/Makefile new file mode 100644 index 00000000000..b9688f16c64 --- /dev/null +++ b/src/test/run-make-fulldeps/no-builtins-lto/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + # Compile a `#![no_builtins]` rlib crate + $(RUSTC) no_builtins.rs + # Build an executable that depends on that crate using LTO. The no_builtins crate doesn't + # participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by + # grepping the linker arguments. + $(RUSTC) main.rs -C lto -Z print-link-args | $(CGREP) 'libno_builtins.rlib' diff --git a/src/test/run-make-fulldeps/no-builtins-lto/main.rs b/src/test/run-make-fulldeps/no-builtins-lto/main.rs new file mode 100644 index 00000000000..e960c726a98 --- /dev/null +++ b/src/test/run-make-fulldeps/no-builtins-lto/main.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate no_builtins; + +fn main() {} diff --git a/src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs b/src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs new file mode 100644 index 00000000000..be95e7c5521 --- /dev/null +++ b/src/test/run-make-fulldeps/no-builtins-lto/no_builtins.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![no_builtins] diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/Makefile b/src/test/run-make-fulldeps/no-duplicate-libs/Makefile new file mode 100644 index 00000000000..13d8366c60a --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +ifdef IS_MSVC +# FIXME(#27979) +all: +else +all: $(call STATICLIB,foo) $(call STATICLIB,bar) + $(RUSTC) main.rs + $(call RUN,main) +endif diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/bar.c b/src/test/run-make-fulldeps/no-duplicate-libs/bar.c new file mode 100644 index 00000000000..b9dcd0f5e5e --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/bar.c @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void foo(); + +void bar() { + foo(); +} diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/foo.c b/src/test/run-make-fulldeps/no-duplicate-libs/foo.c new file mode 100644 index 00000000000..906cd5682b8 --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/foo.c @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo() {} diff --git a/src/test/run-make-fulldeps/no-duplicate-libs/main.rs b/src/test/run-make-fulldeps/no-duplicate-libs/main.rs new file mode 100644 index 00000000000..824946fe9c2 --- /dev/null +++ b/src/test/run-make-fulldeps/no-duplicate-libs/main.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name = "foo")] // linker should drop this library, no symbols used +#[link(name = "bar")] // symbol comes from this library +#[link(name = "foo")] // now linker picks up `foo` b/c `bar` library needs it +extern { + fn bar(); +} + +fn main() { + unsafe { bar() } +} diff --git a/src/test/run-make-fulldeps/no-integrated-as/Makefile b/src/test/run-make-fulldeps/no-integrated-as/Makefile new file mode 100644 index 00000000000..78e3025b99a --- /dev/null +++ b/src/test/run-make-fulldeps/no-integrated-as/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: +ifeq ($(TARGET),x86_64-unknown-linux-gnu) + $(RUSTC) hello.rs -C no_integrated_as + $(call RUN,hello) +endif diff --git a/src/test/run-make-fulldeps/no-integrated-as/hello.rs b/src/test/run-make-fulldeps/no-integrated-as/hello.rs new file mode 100644 index 00000000000..68e7f6d94d1 --- /dev/null +++ b/src/test/run-make-fulldeps/no-integrated-as/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/run-make-fulldeps/no-intermediate-extras/Makefile b/src/test/run-make-fulldeps/no-intermediate-extras/Makefile new file mode 100644 index 00000000000..258cbf04c61 --- /dev/null +++ b/src/test/run-make-fulldeps/no-intermediate-extras/Makefile @@ -0,0 +1,7 @@ +# Regression test for issue #10973 + +-include ../tools.mk + +all: + $(RUSTC) --crate-type=rlib --test foo.rs + rm $(TMPDIR)/foo.bc && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/no-intermediate-extras/foo.rs b/src/test/run-make-fulldeps/no-intermediate-extras/foo.rs new file mode 100644 index 00000000000..e6c76025738 --- /dev/null +++ b/src/test/run-make-fulldeps/no-intermediate-extras/foo.rs @@ -0,0 +1,9 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/run-make-fulldeps/obey-crate-type-flag/Makefile b/src/test/run-make-fulldeps/obey-crate-type-flag/Makefile new file mode 100644 index 00000000000..903349152df --- /dev/null +++ b/src/test/run-make-fulldeps/obey-crate-type-flag/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# check that rustc builds all crate_type attributes +# delete rlib +# delete whatever dylib is made for this system +# check that rustc only builds --crate-type flags, ignoring attributes +# fail if an rlib was built +all: + $(RUSTC) test.rs + $(call REMOVE_RLIBS,test) + $(call REMOVE_DYLIBS,test) + $(RUSTC) --crate-type dylib test.rs + $(call REMOVE_RLIBS,test) && exit 1 || exit 0 diff --git a/src/test/run-make-fulldeps/obey-crate-type-flag/test.rs b/src/test/run-make-fulldeps/obey-crate-type-flag/test.rs new file mode 100644 index 00000000000..e6c8b8eb179 --- /dev/null +++ b/src/test/run-make-fulldeps/obey-crate-type-flag/test.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_type = "dylib"] diff --git a/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile new file mode 100644 index 00000000000..74e5dcfcf36 --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR)/foo.rs + mkdir $(TMPDIR)/foo + $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \ + | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\"" diff --git a/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs new file mode 100644 index 00000000000..3f07b46791d --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-conflicts-with-directory/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile b/src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile new file mode 100644 index 00000000000..6377038b7be --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-overwrites-input/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR)/foo + $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \ + | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable" + cp bar.rs $(TMPDIR)/bar.rlib + $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \ + | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable" + $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1 + cp foo.rs $(TMPDIR)/foo.rs + $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \ + | $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable" diff --git a/src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs b/src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs new file mode 100644 index 00000000000..8e4e35fdee6 --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-overwrites-input/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs b/src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs new file mode 100644 index 00000000000..3f07b46791d --- /dev/null +++ b/src/test/run-make-fulldeps/output-filename-overwrites-input/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/output-type-permutations/Makefile b/src/test/run-make-fulldeps/output-type-permutations/Makefile new file mode 100644 index 00000000000..c2715027bc1 --- /dev/null +++ b/src/test/run-make-fulldeps/output-type-permutations/Makefile @@ -0,0 +1,146 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib + $(call REMOVE_RLIBS,bar) + $(call REMOVE_DYLIBS,bar) + rm $(call STATICLIB,bar) + rm -f $(TMPDIR)/bar.{dll.exp,dll.lib,pdb} + # Check that $(TMPDIR) is empty. + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=bin + rm $(TMPDIR)/$(call BIN,bar) + rm -f $(TMPDIR)/bar.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link + rm $(TMPDIR)/bar.ll + rm $(TMPDIR)/bar.bc + rm $(TMPDIR)/bar.s + rm $(TMPDIR)/bar.o + rm $(TMPDIR)/$(call BIN,bar) + rm -f $(TMPDIR)/bar.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit asm -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit asm=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit llvm-bc -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit llvm-bc=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=llvm-bc=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit llvm-ir -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=llvm-ir=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit obj -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit obj=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --emit=obj=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit link -o $(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --emit link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + rm -f $(TMPDIR)/foo.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=rlib --emit link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=rlib --emit=link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=dylib --emit link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=dylib --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + rm -f $(TMPDIR)/foo.{dll.exp,dll.lib,pdb} + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=staticlib --emit link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + $(RUSTC) foo.rs --crate-type=staticlib --emit=link=$(TMPDIR)/foo + rm $(TMPDIR)/foo + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=bin --emit link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + $(RUSTC) foo.rs --crate-type=bin --emit=link=$(TMPDIR)/$(call BIN,foo) + rm $(TMPDIR)/$(call BIN,foo) + rm -f $(TMPDIR)/foo.pdb + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/ir \ + --emit link \ + --crate-type=rlib + rm $(TMPDIR)/ir + rm $(TMPDIR)/libbar.rlib + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit asm=$(TMPDIR)/asm \ + --emit llvm-ir=$(TMPDIR)/ir \ + --emit llvm-bc=$(TMPDIR)/bc \ + --emit obj=$(TMPDIR)/obj \ + --emit link=$(TMPDIR)/link \ + --crate-type=staticlib + rm $(TMPDIR)/asm + rm $(TMPDIR)/ir + rm $(TMPDIR)/bc + rm $(TMPDIR)/obj + rm $(TMPDIR)/link + $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/asm \ + --emit llvm-ir=$(TMPDIR)/ir \ + --emit=llvm-bc=$(TMPDIR)/bc \ + --emit obj=$(TMPDIR)/obj \ + --emit=link=$(TMPDIR)/link \ + --crate-type=staticlib + rm $(TMPDIR)/asm + rm $(TMPDIR)/ir + rm $(TMPDIR)/bc + rm $(TMPDIR)/obj + rm $(TMPDIR)/link + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] + + $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib + rm $(TMPDIR)/bar.ll + rm $(TMPDIR)/bar.s + rm $(TMPDIR)/bar.o + rm $(call STATICLIB,bar) + mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc + # Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later + # comparison. + + $(RUSTC) foo.rs --emit=llvm-bc,link --crate-type=rlib + cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc + rm $(TMPDIR)/bar.bc + rm $(TMPDIR)/foo.bc + $(call REMOVE_RLIBS,bar) + [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] diff --git a/src/test/run-make-fulldeps/output-type-permutations/foo.rs b/src/test/run-make-fulldeps/output-type-permutations/foo.rs new file mode 100644 index 00000000000..bb5796bd873 --- /dev/null +++ b/src/test/run-make-fulldeps/output-type-permutations/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name = "bar"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/output-with-hyphens/Makefile b/src/test/run-make-fulldeps/output-with-hyphens/Makefile new file mode 100644 index 00000000000..783d826a53d --- /dev/null +++ b/src/test/run-make-fulldeps/output-with-hyphens/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) foo-bar.rs + [ -f $(TMPDIR)/$(call BIN,foo-bar) ] + [ -f $(TMPDIR)/libfoo_bar.rlib ] diff --git a/src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs b/src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs new file mode 100644 index 00000000000..2f93b2d1ead --- /dev/null +++ b/src/test/run-make-fulldeps/output-with-hyphens/foo-bar.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![crate_type = "bin"] + +fn main() {} diff --git a/src/test/run-make-fulldeps/prefer-dylib/Makefile b/src/test/run-make-fulldeps/prefer-dylib/Makefile new file mode 100644 index 00000000000..bd44feecf2a --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-dylib/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib -C prefer-dynamic + $(RUSTC) foo.rs -C prefer-dynamic + $(call RUN,foo) + rm $(TMPDIR)/*bar* + $(call FAIL,foo) diff --git a/src/test/run-make-fulldeps/prefer-dylib/bar.rs b/src/test/run-make-fulldeps/prefer-dylib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-dylib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/prefer-dylib/foo.rs b/src/test/run-make-fulldeps/prefer-dylib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-dylib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/prefer-rlib/Makefile b/src/test/run-make-fulldeps/prefer-rlib/Makefile new file mode 100644 index 00000000000..c6a239eef08 --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-rlib/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib + ls $(TMPDIR)/$(call RLIB_GLOB,bar) + $(RUSTC) foo.rs + rm $(TMPDIR)/*bar* + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/prefer-rlib/bar.rs b/src/test/run-make-fulldeps/prefer-rlib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-rlib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/prefer-rlib/foo.rs b/src/test/run-make-fulldeps/prefer-rlib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/prefer-rlib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile b/src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile new file mode 100644 index 00000000000..136d7643ade --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded-hygiene/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +REPLACEMENT := s/[0-9][0-9]*\#[0-9][0-9]*/$(shell date)/g + +all: + $(RUSTC) -o $(TMPDIR)/input.out -Z unstable-options \ + --pretty expanded,hygiene input.rs + + # the name/ctxt numbers are very internals-dependent and thus + # change relatively frequently, and testing for their exact values + # them will fail annoyingly, so we just check their positions + # (using a non-constant replacement like this will make it less + # likely the compiler matches whatever other dummy value we + # choose). + # + # (These need to be out-of-place because OSX/BSD & GNU sed + # differ.) + sed "$(REPLACEMENT)" input.pp.rs > $(TMPDIR)/input.pp.rs + sed "$(REPLACEMENT)" $(TMPDIR)/input.out > $(TMPDIR)/input.out.replaced + + diff -u $(TMPDIR)/input.out.replaced $(TMPDIR)/input.pp.rs diff --git a/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs new file mode 100644 index 00000000000..3d2dd380e48 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.pp.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// minimal junk +#![feature(no_core)] +#![no_core] + +macro_rules! foo /* 60#0 */(( $ x : ident ) => { y + $ x }); + +fn bar /* 62#0 */() { let x /* 59#2 */ = 1; y /* 61#4 */ + x /* 59#5 */ } + +fn y /* 61#0 */() { } diff --git a/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs new file mode 100644 index 00000000000..422fbdb0884 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded-hygiene/input.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// minimal junk +#![feature(no_core)] +#![no_core] + +macro_rules! foo { + ($x: ident) => { y + $x } +} + +fn bar() { + let x = 1; + foo!(x) +} + +fn y() {} diff --git a/src/test/run-make-fulldeps/pretty-expanded/Makefile b/src/test/run-make-fulldeps/pretty-expanded/Makefile new file mode 100644 index 00000000000..7a8dc8d871c --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \ + --pretty=expanded input.rs diff --git a/src/test/run-make-fulldeps/pretty-expanded/input.rs b/src/test/run-make-fulldeps/pretty-expanded/input.rs new file mode 100644 index 00000000000..04bf17dc28a --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-expanded/input.rs @@ -0,0 +1,22 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[crate_type="lib"] + +// #13544 + +extern crate serialize; + +#[derive(Encodable)] pub struct A; +#[derive(Encodable)] pub struct B(isize); +#[derive(Encodable)] pub struct C { x: isize } +#[derive(Encodable)] pub enum D {} +#[derive(Encodable)] pub enum E { y } +#[derive(Encodable)] pub enum F { z(isize) } diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile b/src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile new file mode 100644 index 00000000000..899457fc748 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + $(RUSTC) -o $(TMPDIR)/foo.out -Z unpretty=hir=foo input.rs + $(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unpretty=hir=nest::foo input.rs + $(RUSTC) -o $(TMPDIR)/foo_method.out -Z unpretty=hir=foo_method input.rs + diff -u $(TMPDIR)/foo.out foo.pp + diff -u $(TMPDIR)/nest_foo.out nest_foo.pp + diff -u $(TMPDIR)/foo_method.out foo_method.pp diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp new file mode 100644 index 00000000000..f3130a8044a --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo.pp @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +pub fn foo() -> i32 { 45 } /* foo */ + + +pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp new file mode 100644 index 00000000000..fae13498687 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/foo_method.pp @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + + + +fn foo_method(self: &Self) + -> &'static str { return "i am very similar to foo."; } /* +nest::{{impl}}::foo_method */ diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs b/src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs new file mode 100644 index 00000000000..8ea86a94f93 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/input.rs @@ -0,0 +1,28 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub fn +foo() -> i32 +{ 45 } + +pub fn bar() -> &'static str { "i am not a foo." } + +pub mod nest { + pub fn foo() -> &'static str { "i am a foo." } + + struct S; + impl S { + fn foo_method(&self) -> &'static str { + return "i am very similar to foo."; + } + } +} diff --git a/src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp b/src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp new file mode 100644 index 00000000000..88eaa062b03 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-path-suffix/nest_foo.pp @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + + +pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make-fulldeps/pretty-print-to-file/Makefile b/src/test/run-make-fulldeps/pretty-print-to-file/Makefile new file mode 100644 index 00000000000..8909dee11f0 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-to-file/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -o $(TMPDIR)/input.out --pretty=normal -Z unstable-options input.rs + diff -u $(TMPDIR)/input.out input.pp diff --git a/src/test/run-make-fulldeps/pretty-print-to-file/input.pp b/src/test/run-make-fulldeps/pretty-print-to-file/input.pp new file mode 100644 index 00000000000..a6dd6b6778e --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-to-file/input.pp @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#[crate_type = "lib"] +pub fn foo() -> i32 { 45 } diff --git a/src/test/run-make-fulldeps/pretty-print-to-file/input.rs b/src/test/run-make-fulldeps/pretty-print-to-file/input.rs new file mode 100644 index 00000000000..8e3ec363187 --- /dev/null +++ b/src/test/run-make-fulldeps/pretty-print-to-file/input.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[crate_type="lib"] + +pub fn +foo() -> i32 +{ 45 } diff --git a/src/test/run-make-fulldeps/print-cfg/Makefile b/src/test/run-make-fulldeps/print-cfg/Makefile new file mode 100644 index 00000000000..08303a46d19 --- /dev/null +++ b/src/test/run-make-fulldeps/print-cfg/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +all: default + $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows + $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64 + $(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc + $(RUSTC) --target i686-apple-darwin --print cfg | $(CGREP) macos + $(RUSTC) --target i686-unknown-linux-gnu --print cfg | $(CGREP) gnu + +ifdef IS_WINDOWS +default: + $(RUSTC) --print cfg | $(CGREP) windows +else +default: + $(RUSTC) --print cfg | $(CGREP) unix +endif diff --git a/src/test/run-make-fulldeps/print-target-list/Makefile b/src/test/run-make-fulldeps/print-target-list/Makefile new file mode 100644 index 00000000000..144c5ba10cc --- /dev/null +++ b/src/test/run-make-fulldeps/print-target-list/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# Checks that all the targets returned by `rustc --print target-list` are valid +# target specifications +# TODO remove the '*ios*' case when rust-lang/rust#29812 is fixed +all: + for target in $(shell $(BARE_RUSTC) --print target-list); do \ + case $$target in \ + *ios*) \ + ;; \ + *) \ + $(BARE_RUSTC) --target $$target --print sysroot \ + ;; \ + esac \ + done diff --git a/src/test/run-make-fulldeps/profile/Makefile b/src/test/run-make-fulldeps/profile/Makefile new file mode 100644 index 00000000000..7300bfc9553 --- /dev/null +++ b/src/test/run-make-fulldeps/profile/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: +ifeq ($(PROFILER_SUPPORT),1) + $(RUSTC) -g -Z profile test.rs + $(call RUN,test) || exit 1 + [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1) + [ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1) +endif diff --git a/src/test/run-make-fulldeps/profile/test.rs b/src/test/run-make-fulldeps/profile/test.rs new file mode 100644 index 00000000000..046d27a9f0f --- /dev/null +++ b/src/test/run-make-fulldeps/profile/test.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/prune-link-args/Makefile b/src/test/run-make-fulldeps/prune-link-args/Makefile new file mode 100644 index 00000000000..a6e219873df --- /dev/null +++ b/src/test/run-make-fulldeps/prune-link-args/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk +ifdef IS_WINDOWS +# ignore windows +RUSTC_FLAGS = +else +# Notice the space in the end, this emulates the output of pkg-config +RUSTC_FLAGS = -C link-args="-lc " +endif + +all: + $(RUSTC) $(RUSTC_FLAGS) empty.rs diff --git a/src/test/run-make-fulldeps/prune-link-args/empty.rs b/src/test/run-make-fulldeps/prune-link-args/empty.rs new file mode 100644 index 00000000000..a9e231b0ea8 --- /dev/null +++ b/src/test/run-make-fulldeps/prune-link-args/empty.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { } diff --git a/src/test/run-make-fulldeps/relocation-model/Makefile b/src/test/run-make-fulldeps/relocation-model/Makefile new file mode 100644 index 00000000000..485ecbb4b5a --- /dev/null +++ b/src/test/run-make-fulldeps/relocation-model/Makefile @@ -0,0 +1,19 @@ +-include ../tools.mk + +all: others + $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs + $(call RUN,foo) + + $(RUSTC) -C relocation-model=default foo.rs + $(call RUN,foo) + + $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj + +ifdef IS_MSVC +# FIXME(#28026) +others: +else +others: + $(RUSTC) -C relocation-model=static foo.rs + $(call RUN,foo) +endif diff --git a/src/test/run-make-fulldeps/relocation-model/foo.rs b/src/test/run-make-fulldeps/relocation-model/foo.rs new file mode 100644 index 00000000000..e06d81cd60b --- /dev/null +++ b/src/test/run-make-fulldeps/relocation-model/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() {} diff --git a/src/test/run-make-fulldeps/relro-levels/Makefile b/src/test/run-make-fulldeps/relro-levels/Makefile new file mode 100644 index 00000000000..673ba9a9a02 --- /dev/null +++ b/src/test/run-make-fulldeps/relro-levels/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +# This tests the different -Zrelro-level values, and makes sure that they they work properly. + +all: +ifeq ($(UNAME),Linux) + # Ensure that binaries built with the full relro level links them with both + # RELRO and BIND_NOW for doing eager symbol resolving. + $(RUSTC) -Zrelro-level=full hello.rs + readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO + readelf -d $(TMPDIR)/hello | grep -q BIND_NOW + + $(RUSTC) -Zrelro-level=partial hello.rs + readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO + + # Ensure that we're *not* built with RELRO when setting it to off. We do + # not want to check for BIND_NOW however, as the linker might have that + # enabled by default. + $(RUSTC) -Zrelro-level=off hello.rs + ! readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO +endif diff --git a/src/test/run-make-fulldeps/relro-levels/hello.rs b/src/test/run-make-fulldeps/relro-levels/hello.rs new file mode 100644 index 00000000000..41782851a1a --- /dev/null +++ b/src/test/run-make-fulldeps/relro-levels/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/run-make-fulldeps/reproducible-build/Makefile b/src/test/run-make-fulldeps/reproducible-build/Makefile new file mode 100644 index 00000000000..ca76a5e5d77 --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/Makefile @@ -0,0 +1,74 @@ +-include ../tools.mk +all: \ + smoke \ + debug \ + opt \ + link_paths \ + remap_paths \ + different_source_dirs \ + extern_flags + +smoke: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" + +debug: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O + $(RUSTC) reproducible-build-aux.rs -g + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" + +opt: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) linker.rs -O + $(RUSTC) reproducible-build-aux.rs -O + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O + $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O + diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" + +link_paths: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs --crate-type rlib -L /b + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + $(RUSTC) reproducible-build.rs --crate-type rlib -L /a + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 + +remap_paths: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/a=/c + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/b=/c + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 + +different_source_dirs: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + mkdir $(TMPDIR)/test + cp reproducible-build.rs $(TMPDIR)/test + $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=$$PWD=/b + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \ + --remap-path-prefix=$(TMPDIR)/test=/b \ + --crate-type rlib) + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 + +extern_flags: + rm -rf $(TMPDIR) && mkdir $(TMPDIR) + $(RUSTC) reproducible-build-aux.rs + $(RUSTC) reproducible-build.rs \ + --extern reproducible_build_aux=$(TMPDIR)/libreproducible_build_aux.rlib \ + --crate-type rlib + cp $(TMPDIR)/libreproducible_build_aux.rlib $(TMPDIR)/libbar.rlib + cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib + $(RUSTC) reproducible-build.rs \ + --extern reproducible_build_aux=$(TMPDIR)/libbar.rlib \ + --crate-type rlib + cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 diff --git a/src/test/run-make-fulldeps/reproducible-build/linker.rs b/src/test/run-make-fulldeps/reproducible-build/linker.rs new file mode 100644 index 00000000000..fd8946708bf --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/linker.rs @@ -0,0 +1,54 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::env; +use std::path::Path; +use std::fs::File; +use std::io::{Read, Write}; + +fn main() { + let mut dst = env::current_exe().unwrap(); + dst.pop(); + dst.push("linker-arguments1"); + if dst.exists() { + dst.pop(); + dst.push("linker-arguments2"); + assert!(!dst.exists()); + } + + let mut out = String::new(); + for arg in env::args().skip(1) { + let path = Path::new(&arg); + if !path.is_file() { + out.push_str(&arg); + out.push_str("\n"); + continue + } + + let mut contents = Vec::new(); + File::open(path).unwrap().read_to_end(&mut contents).unwrap(); + + out.push_str(&format!("{}: {}\n", arg, hash(&contents))); + } + + File::create(dst).unwrap().write_all(out.as_bytes()).unwrap(); +} + +// fnv hash for now +fn hash(contents: &[u8]) -> u64 { + let mut hash = 0xcbf29ce484222325; + + for byte in contents { + hash = hash ^ (*byte as u64); + hash = hash.wrapping_mul(0x100000001b3); + } + + hash +} diff --git a/src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs b/src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs new file mode 100644 index 00000000000..9ef853e7996 --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/reproducible-build-aux.rs @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub static STATIC: i32 = 1234; + +pub struct Struct { + _t1: std::marker::PhantomData, + _t2: std::marker::PhantomData, +} + +pub fn regular_fn(_: i32) {} + +pub fn generic_fn() {} + +impl Drop for Struct { + fn drop(&mut self) {} +} + +pub enum Enum { + Variant1, + Variant2(u32), + Variant3 { x: u32 } +} + +pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64); + +pub trait Trait { + fn foo(&self); +} diff --git a/src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs b/src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs new file mode 100644 index 00000000000..a040c0f858d --- /dev/null +++ b/src/test/run-make-fulldeps/reproducible-build/reproducible-build.rs @@ -0,0 +1,126 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test case makes sure that two identical invocations of the compiler +// (i.e. same code base, same compile-flags, same compiler-versions, etc.) +// produce the same output. In the past, symbol names of monomorphized functions +// were not deterministic (which we want to avoid). +// +// The test tries to exercise as many different paths into symbol name +// generation as possible: +// +// - regular functions +// - generic functions +// - methods +// - statics +// - closures +// - enum variant constructors +// - tuple struct constructors +// - drop glue +// - FnOnce adapters +// - Trait object shims +// - Fn Pointer shims + +#![allow(dead_code, warnings)] + +extern crate reproducible_build_aux; + +static STATIC: i32 = 1234; + +pub struct Struct { + x: T1, + y: T2, +} + +fn regular_fn(_: i32) {} + +fn generic_fn() {} + +impl Drop for Struct { + fn drop(&mut self) {} +} + +pub enum Enum { + Variant1, + Variant2(u32), + Variant3 { x: u32 } +} + +struct TupleStruct(i8, i16, i32, i64); + +impl TupleStruct { + pub fn bar(&self) {} +} + +trait Trait { + fn foo(&self); +} + +impl Trait for u64 { + fn foo(&self) {} +} + +impl reproducible_build_aux::Trait for TupleStruct { + fn foo(&self) {} +} + +fn main() { + regular_fn(STATIC); + generic_fn::(); + generic_fn::>(); + generic_fn::, reproducible_build_aux::Struct>(); + + let dropped = Struct { + x: "", + y: 'a', + }; + + let _ = Enum::Variant1; + let _ = Enum::Variant2(0); + let _ = Enum::Variant3 { x: 0 }; + let _ = TupleStruct(1, 2, 3, 4); + + let closure = |x| { + x + 1i32 + }; + + fn inner i32>(f: F) -> i32 { + f(STATIC) + } + + println!("{}", inner(closure)); + + let object_shim: &Trait = &0u64; + object_shim.foo(); + + fn with_fn_once_adapter(f: F) { + f(0); + } + + with_fn_once_adapter(|_:i32| { }); + + reproducible_build_aux::regular_fn(STATIC); + reproducible_build_aux::generic_fn::(); + reproducible_build_aux::generic_fn::>(); + reproducible_build_aux::generic_fn::, + reproducible_build_aux::Struct>(); + + let _ = reproducible_build_aux::Enum::Variant1; + let _ = reproducible_build_aux::Enum::Variant2(0); + let _ = reproducible_build_aux::Enum::Variant3 { x: 0 }; + let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4); + + let object_shim: &reproducible_build_aux::Trait = &TupleStruct(0, 1, 2, 3); + object_shim.foo(); + + let pointer_shim: &Fn(i32) = ®ular_fn; + + TupleStruct(1, 2, 3, 4).bar(); +} diff --git a/src/test/run-make-fulldeps/rlib-chain/Makefile b/src/test/run-make-fulldeps/rlib-chain/Makefile new file mode 100644 index 00000000000..30b6811a388 --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: + $(RUSTC) m1.rs + $(RUSTC) m2.rs + $(RUSTC) m3.rs + $(RUSTC) m4.rs + $(call RUN,m4) + rm $(TMPDIR)/*lib + $(call RUN,m4) diff --git a/src/test/run-make-fulldeps/rlib-chain/m1.rs b/src/test/run-make-fulldeps/rlib-chain/m1.rs new file mode 100644 index 00000000000..e3afa352938 --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m1.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +pub fn m1() {} diff --git a/src/test/run-make-fulldeps/rlib-chain/m2.rs b/src/test/run-make-fulldeps/rlib-chain/m2.rs new file mode 100644 index 00000000000..2b4c181134b --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m2.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +extern crate m1; + +pub fn m2() { m1::m1() } diff --git a/src/test/run-make-fulldeps/rlib-chain/m3.rs b/src/test/run-make-fulldeps/rlib-chain/m3.rs new file mode 100644 index 00000000000..6323a9e65aa --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m3.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +extern crate m2; + +pub fn m3() { m2::m2() } diff --git a/src/test/run-make-fulldeps/rlib-chain/m4.rs b/src/test/run-make-fulldeps/rlib-chain/m4.rs new file mode 100644 index 00000000000..6c2a6685802 --- /dev/null +++ b/src/test/run-make-fulldeps/rlib-chain/m4.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate m3; + +fn main() { m3::m3() } diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile b/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile new file mode 100644 index 00000000000..d2c8e7fd043 --- /dev/null +++ b/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else +all: + $(RUSTC) foo.rs + $(RUSTC) bar.rs --emit dep-info + $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d +endif diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs b/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs new file mode 100644 index 00000000000..03330c3d170 --- /dev/null +++ b/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate foo; + +#[derive(A)] +struct A; + +fn main() { + let _b = B; +} diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs b/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs new file mode 100644 index 00000000000..2f2524f6ef1 --- /dev/null +++ b/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("struct A;")); + "struct B;".parse().unwrap() +} diff --git a/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile b/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile new file mode 100644 index 00000000000..0019e5ee794 --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-error-lines/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +# Test that hir-tree output doens't crash and includes +# the string constant we would expect to see. + +all: + $(RUSTDOC) --test input.rs > $(TMPDIR)/output || true + $(CGREP) 'input.rs:17:15' < $(TMPDIR)/output diff --git a/src/test/run-make-fulldeps/rustdoc-error-lines/input.rs b/src/test/run-make-fulldeps/rustdoc-error-lines/input.rs new file mode 100644 index 00000000000..6dc7060bc48 --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-error-lines/input.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for #45868 + +// random #![feature] to ensure that crate attrs +// do not offset things +/// ```rust +/// #![feature(nll)] +/// let x: char = 1; +/// ``` +pub fn foo() { + +} diff --git a/src/test/run-make-fulldeps/rustdoc-output-path/Makefile b/src/test/run-make-fulldeps/rustdoc-output-path/Makefile new file mode 100644 index 00000000000..8ce1c699526 --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-output-path/Makefile @@ -0,0 +1,4 @@ +-include ../tools.mk + +all: + $(RUSTDOC) -o "$(TMPDIR)/foo/bar/doc" foo.rs diff --git a/src/test/run-make-fulldeps/rustdoc-output-path/foo.rs b/src/test/run-make-fulldeps/rustdoc-output-path/foo.rs new file mode 100644 index 00000000000..11fc2cd2b8d --- /dev/null +++ b/src/test/run-make-fulldeps/rustdoc-output-path/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo; diff --git a/src/test/run-make-fulldeps/sanitizer-address/Makefile b/src/test/run-make-fulldeps/sanitizer-address/Makefile new file mode 100644 index 00000000000..207615bfbd5 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-address/Makefile @@ -0,0 +1,29 @@ +-include ../tools.mk + +LOG := $(TMPDIR)/log.txt + +# NOTE the address sanitizer only supports x86_64 linux and macOS + +ifeq ($(TARGET),x86_64-apple-darwin) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG=-C rpath +else +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) + +# Apparently there are very specific Linux kernels, notably the one that's +# currently on Travis CI, which contain a buggy commit that triggers failures in +# the ASan implementation, detailed at google/sanitizers#837. As noted in +# google/sanitizers#856 the "fix" is to avoid using PIE binaries, so we pass a +# different relocation model to avoid generating a PIE binary. Once Travis is no +# longer running kernel 4.4.0-93 we can remove this and pass an empty set of +# flags again. +EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic +endif +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan + $(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow +endif diff --git a/src/test/run-make-fulldeps/sanitizer-address/overflow.rs b/src/test/run-make-fulldeps/sanitizer-address/overflow.rs new file mode 100644 index 00000000000..1f3c64c8c32 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-address/overflow.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile new file mode 100644 index 00000000000..bea5519ec5f --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +LOG := $(TMPDIR)/log.txt + +# This test builds a shared object, then an executable that links it as a native +# rust library (constrast to an rlib). The shared library and executable both +# are compiled with address sanitizer, and we assert that a fault in the cdylib +# is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) + +# See comment in sanitizer-address/Makefile for why this is here +EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs + $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow +endif diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs new file mode 100644 index 00000000000..4ceef5d3f52 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs b/src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs new file mode 100644 index 00000000000..9f52817c851 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-cdylib-link/program.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn overflow(); +} + +fn main() { + unsafe { overflow() } +} diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile new file mode 100644 index 00000000000..0cc8f73da8b --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile @@ -0,0 +1,22 @@ +-include ../tools.mk + +LOG := $(TMPDIR)/log.txt + +# This test builds a shared object, then an executable that links it as a native +# rust library (constrast to an rlib). The shared library and executable both +# are compiled with address sanitizer, and we assert that a fault in the dylib +# is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) + +# See comment in sanitizer-address/Makefile for why this is here +EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs + $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow +endif diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs new file mode 100644 index 00000000000..4ceef5d3f52 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs b/src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs new file mode 100644 index 00000000000..9f52817c851 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-dylib-link/program.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern { + fn overflow(); +} + +fn main() { + unsafe { overflow() } +} diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile new file mode 100644 index 00000000000..dc37c0d0bc9 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# NOTE the address sanitizer only supports x86_64 linux and macOS + +ifeq ($(TARGET),x86_64-apple-darwin) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG=-C rpath +else +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | $(CGREP) '-Z sanitizer' +endif diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs new file mode 100644 index 00000000000..41782851a1a --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-cratetype/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello, world!"); +} diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile b/src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile new file mode 100644 index 00000000000..df8afee15ce --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-target/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) -Z sanitizer=leak --target i686-unknown-linux-gnu hello.rs 2>&1 | \ + $(CGREP) 'LeakSanitizer only works with the `x86_64-unknown-linux-gnu` target' diff --git a/src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs b/src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs new file mode 100644 index 00000000000..e9e46b7702a --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-invalid-target/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/src/test/run-make-fulldeps/sanitizer-leak/Makefile b/src/test/run-make-fulldeps/sanitizer-leak/Makefile new file mode 100644 index 00000000000..ab43fac2e99 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-leak/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +# FIXME(#46126) ThinLTO for libstd broke this test +ifeq (1,0) +all: +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ifdef SANITIZER_SUPPORT + $(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) librustc_lsan + $(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks' +endif +endif + +else +all: +endif + diff --git a/src/test/run-make-fulldeps/sanitizer-leak/leak.rs b/src/test/run-make-fulldeps/sanitizer-leak/leak.rs new file mode 100644 index 00000000000..279da6aaae7 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-leak/leak.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; + +fn main() { + let xs = vec![1, 2, 3, 4]; + mem::forget(xs); +} diff --git a/src/test/run-make-fulldeps/sanitizer-memory/Makefile b/src/test/run-make-fulldeps/sanitizer-memory/Makefile new file mode 100644 index 00000000000..3507ca2bef2 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory/Makefile @@ -0,0 +1,10 @@ +-include ../tools.mk + +all: +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ifdef SANITIZER_SUPPORT + $(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | $(CGREP) librustc_msan + $(TMPDIR)/uninit 2>&1 | $(CGREP) use-of-uninitialized-value +endif +endif + diff --git a/src/test/run-make-fulldeps/sanitizer-memory/uninit.rs b/src/test/run-make-fulldeps/sanitizer-memory/uninit.rs new file mode 100644 index 00000000000..8350c7de3ac --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory/uninit.rs @@ -0,0 +1,16 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; + +fn main() { + let xs: [u8; 4] = unsafe { mem::uninitialized() }; + let y = xs[0] + xs[1]; +} diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile new file mode 100644 index 00000000000..2b444d667bf --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile @@ -0,0 +1,18 @@ +-include ../tools.mk + +# This test builds a staticlib, then an executable that links to it. +# The staticlib and executable both are compiled with address sanitizer, +# and we assert that a fault in the staticlib is correctly detected. + +ifeq ($(TARGET),x86_64-unknown-linux-gnu) +ASAN_SUPPORT=$(SANITIZER_SUPPORT) +EXTRA_RUSTFLAG= +endif + +all: +ifeq ($(ASAN_SUPPORT),1) + $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs + $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) + LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow +endif + diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs b/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs new file mode 100644 index 00000000000..4ceef5d3f52 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/library.rs @@ -0,0 +1,15 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[no_mangle] +pub extern fn overflow() { + let xs = [0, 1, 2, 3]; + let _y = unsafe { *xs.as_ptr().offset(4) }; +} diff --git a/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c b/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c new file mode 100644 index 00000000000..abd5d508e72 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-staticlib-link/program.c @@ -0,0 +1,8 @@ +// ignore-license +void overflow(); + +int main() { + overflow(); + return 0; +} + diff --git a/src/test/run-make-fulldeps/save-analysis-fail/Makefile b/src/test/run-make-fulldeps/save-analysis-fail/Makefile new file mode 100644 index 00000000000..f29f907cf38 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk +all: code +krate2: krate2.rs + $(RUSTC) $< +code: foo.rs krate2 + $(RUSTC) foo.rs -Zsave-analysis || exit 0 diff --git a/src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs b/src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs new file mode 100644 index 00000000000..fe70ac1edef --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/SameDir.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// sub-module in the same directory as the main crate file + +pub struct SameStruct { + pub name: String +} diff --git a/src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs b/src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs new file mode 100644 index 00000000000..315f900868b --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/SameDir3.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn hello(x: isize) { + println!("macro {} :-(", x); +} diff --git a/src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs b/src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs new file mode 100644 index 00000000000..fe84db08da9 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs @@ -0,0 +1,37 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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/src/test/run-make-fulldeps/save-analysis-fail/foo.rs b/src/test/run-make-fulldeps/save-analysis-fail/foo.rs new file mode 100644 index 00000000000..b844f2e49e7 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/foo.rs @@ -0,0 +1,468 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ crate_name = "test" ] +#![feature(box_syntax)] +#![feature(rustc_private)] + +extern crate graphviz; +// A simple rust project + +extern crate krate2; +extern crate krate2 as krate3; + +use graphviz::RenderOption; +use std::collections::{HashMap,HashSet}; +use std::cell::RefCell; +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 = None; + +// buglink test - see issue #1337. + +fn test_alias(i: Option<::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); + +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(&mut self) { + + } + + fn test(&mut self) { + self.align_to::(); + } +} + +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, Box) {} + +fn f_with_params(x: &T) { + x.Method(41); +} + +type MyType = Box; + +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((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 = box some_fields {field1: 43}; + let s2: Box = box some_fields {field1: 43}; + let s3 = box 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; + 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 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> = 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 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 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 some_fields{ field1:10 }, + f2: box 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) { + panic!() + } +} + +trait Pattern<'a> { + type Searcher; +} + +struct CharEqPattern; + +impl<'a> Pattern<'a> for CharEqPattern { + type Searcher = CharEqPattern; +} + +struct CharSearcher<'a>(>::Searcher); + +pub trait Error { +} + +impl Error + 'static { + pub fn is(&self) -> bool { + panic!() + } +} + +impl Error + 'static + Send { + pub fn is(&self) -> bool { + ::is::(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 { + 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/src/test/run-make-fulldeps/save-analysis-fail/krate2.rs b/src/test/run-make-fulldeps/save-analysis-fail/krate2.rs new file mode 100644 index 00000000000..2c6f517ff38 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis-fail/krate2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ 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/src/test/run-make-fulldeps/save-analysis/Makefile b/src/test/run-make-fulldeps/save-analysis/Makefile new file mode 100644 index 00000000000..7296fb9cc59 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk +all: code +krate2: krate2.rs + $(RUSTC) $< +code: foo.rs krate2 + $(RUSTC) foo.rs -Zsave-analysis diff --git a/src/test/run-make-fulldeps/save-analysis/SameDir.rs b/src/test/run-make-fulldeps/save-analysis/SameDir.rs new file mode 100644 index 00000000000..fe70ac1edef --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/SameDir.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// sub-module in the same directory as the main crate file + +pub struct SameStruct { + pub name: String +} diff --git a/src/test/run-make-fulldeps/save-analysis/SameDir3.rs b/src/test/run-make-fulldeps/save-analysis/SameDir3.rs new file mode 100644 index 00000000000..315f900868b --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/SameDir3.rs @@ -0,0 +1,13 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn hello(x: isize) { + println!("macro {} :-(", x); +} diff --git a/src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs b/src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs new file mode 100644 index 00000000000..fe84db08da9 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/SubDir/mod.rs @@ -0,0 +1,37 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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/src/test/run-make-fulldeps/save-analysis/extra-docs.md b/src/test/run-make-fulldeps/save-analysis/extra-docs.md new file mode 100644 index 00000000000..0605ca517ff --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/extra-docs.md @@ -0,0 +1 @@ +Extra docs for this struct. diff --git a/src/test/run-make-fulldeps/save-analysis/foo.rs b/src/test/run-make-fulldeps/save-analysis/foo.rs new file mode 100644 index 00000000000..5b4e4802957 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/foo.rs @@ -0,0 +1,467 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ crate_name = "test" ] +#![feature(box_syntax)] +#![feature(rustc_private)] +#![feature(associated_type_defaults)] +#![feature(external_doc)] + +extern crate graphviz; +// A simple rust project + +extern crate krate2; +extern crate krate2 as krate3; + +use graphviz::RenderOption; +use std::collections::{HashMap,HashSet}; +use std::cell::RefCell; +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 = None; + +// buglink test - see issue #1337. + +fn test_alias(i: Option<::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); + +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(&mut self) { + + } + + fn test(&mut self) { + self.align_to::(); + } +} + +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, Box) {} + +fn f_with_params(x: &T) { + x.Method(41); +} + +type MyType = Box; + +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((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 = box some_fields {field1: 43}; + let s2: Box = box some_fields {field1: 43}; + let s3 = box 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; + 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 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> = 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 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 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 some_fields{ field1:10 }, + f2: box 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) { + panic!() + } +} + +trait Pattern<'a> { + type Searcher; +} + +struct CharEqPattern; + +impl<'a> Pattern<'a> for CharEqPattern { + type Searcher = CharEqPattern; +} + +struct CharSearcher<'a>(>::Searcher); + +pub trait Error { +} + +impl Error + 'static { + pub fn is(&self) -> bool { + panic!() + } +} + +impl Error + 'static + Send { + pub fn is(&self) -> bool { + ::is::(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); +} + + +union TestUnion { + f1: u32 +} + +struct FrameBuffer; + +struct SilenceGenerator; + +impl Iterator for SilenceGenerator { + type Item = FrameBuffer; + + fn next(&mut self) -> Option { + panic!(); + } +} + +trait Foo { + type Bar = FrameBuffer; +} + +#[doc(include="extra-docs.md")] +struct StructWithDocs; diff --git a/src/test/run-make-fulldeps/save-analysis/krate2.rs b/src/test/run-make-fulldeps/save-analysis/krate2.rs new file mode 100644 index 00000000000..2c6f517ff38 --- /dev/null +++ b/src/test/run-make-fulldeps/save-analysis/krate2.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![ 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/src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile b/src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile new file mode 100644 index 00000000000..36f913ff3fa --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-cci-copies/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +# Check that cross-crate inlined items are inlined in all compilation units +# that refer to them, and not in any other compilation units. +# Note that we have to pass `-C codegen-units=6` because up to two CGUs may be +# created for each source module (see `rustc_mir::monomorphize::partitioning`). + +all: + $(RUSTC) cci_lib.rs + $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=6 \ + -Z inline-in-all-cgus + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ] diff --git a/src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs b/src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs new file mode 100644 index 00000000000..62bc3294286 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-cci-copies/cci_lib.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +#[inline] +pub fn cci_fn() -> usize { + 1234 +} diff --git a/src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs b/src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs new file mode 100644 index 00000000000..e00cab20f6b --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-cci-copies/foo.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate cci_lib; +use cci_lib::cci_fn; + +fn call1() -> usize { + cci_fn() +} + +mod a { + use cci_lib::cci_fn; + pub fn call2() -> usize { + cci_fn() + } +} + +mod b { + pub fn call3() -> usize { + 0 + } +} + +fn main() { + call1(); + a::call2(); + b::call3(); +} diff --git a/src/test/run-make-fulldeps/sepcomp-inlining/Makefile b/src/test/run-make-fulldeps/sepcomp-inlining/Makefile new file mode 100644 index 00000000000..1d20d940000 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-inlining/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# Test that #[inline] functions still get inlined across compilation unit +# boundaries. Compilation should produce three IR files, but only the two +# compilation units that have a usage of the #[inline] function should +# contain a definition. Also, the non-#[inline] function should be defined +# in only one compilation unit. + +all: + $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \ + -Z inline-in-all-cgus + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ] + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ] + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ] + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c declare\ hidden\ i32\ .*normal)" -eq "2" ] diff --git a/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs b/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs new file mode 100644 index 00000000000..5b62c1b0626 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-inlining/foo.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(start)] + +#[inline] +fn inlined() -> u32 { + 1234 +} + +fn normal() -> u32 { + 2345 +} + +mod a { + pub fn f() -> u32 { + ::inlined() + ::normal() + } +} + +mod b { + pub fn f() -> u32 { + ::inlined() + ::normal() + } +} + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + a::f(); + b::f(); + + 0 +} diff --git a/src/test/run-make-fulldeps/sepcomp-separate/Makefile b/src/test/run-make-fulldeps/sepcomp-separate/Makefile new file mode 100644 index 00000000000..5b8bdb0fad8 --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-separate/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# Test that separate compilation actually puts code into separate compilation +# units. `foo.rs` defines `magic_fn` in three different modules, which should +# wind up in three different compilation units. + +all: + $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 + [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*magic_fn)" -eq "3" ] diff --git a/src/test/run-make-fulldeps/sepcomp-separate/foo.rs b/src/test/run-make-fulldeps/sepcomp-separate/foo.rs new file mode 100644 index 00000000000..64a76e9e0ed --- /dev/null +++ b/src/test/run-make-fulldeps/sepcomp-separate/foo.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + + +fn magic_fn() -> usize { + 1234 +} + +mod a { + pub fn magic_fn() -> usize { + 2345 + } +} + +mod b { + pub fn magic_fn() -> usize { + 3456 + } +} + +fn main() { + magic_fn(); + a::magic_fn(); + b::magic_fn(); +} diff --git a/src/test/run-make-fulldeps/simd-ffi/Makefile b/src/test/run-make-fulldeps/simd-ffi/Makefile new file mode 100644 index 00000000000..e9c974a0137 --- /dev/null +++ b/src/test/run-make-fulldeps/simd-ffi/Makefile @@ -0,0 +1,47 @@ +-include ../tools.mk + +TARGETS = +ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) +# construct a fairly exhaustive list of platforms that we +# support. These ones don't follow a pattern +TARGETS += arm-linux-androideabi arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabi +endif + +ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) +X86_ARCHS = i686 x86_64 +else +X86_ARCHS = +endif + +# these ones do, each OS lists the architectures it supports +LINUX=$(filter aarch64 mips,$(LLVM_COMPONENTS)) $(X86_ARCHS) +ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) +LINUX += mipsel +endif + +WINDOWS=$(X86_ARCHS) +# fails with: failed to get iphonesimulator SDK path: no such file or directory +#IOS=i386 aarch64 armv7 +DARWIN=$(X86_ARCHS) + +$(foreach arch,$(LINUX),$(eval TARGETS += $(arch)-unknown-linux-gnu)) +$(foreach arch,$(WINDOWS),$(eval TARGETS += $(arch)-pc-windows-gnu)) +#$(foreach arch,$(IOS),$(eval TARGETS += $(arch)-apple-ios)) +$(foreach arch,$(DARWIN),$(eval TARGETS += $(arch)-apple-darwin)) + +all: $(TARGETS) + +define MK_TARGETS +# compile the rust file to the given target, but only to asm and IR +# form, to avoid having to have an appropriate linker. +# +# we need some features because the integer SIMD instructions are not +# enabled by-default for i686 and ARM; these features will be invalid +# on some platforms, but LLVM just prints a warning so that's fine for +# now. +$(1): simd.rs + $$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \ + -C target-feature='+neon,+sse2' -C extra-filename=-$(1) +endef + +$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx)))) diff --git a/src/test/run-make-fulldeps/simd-ffi/simd.rs b/src/test/run-make-fulldeps/simd-ffi/simd.rs new file mode 100644 index 00000000000..94b91c711cc --- /dev/null +++ b/src/test/run-make-fulldeps/simd-ffi/simd.rs @@ -0,0 +1,83 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ensures that public symbols are not removed completely +#![crate_type = "lib"] +// we can compile to a variety of platforms, because we don't need +// cross-compiled standard libraries. +#![feature(no_core, optin_builtin_traits)] +#![no_core] + +#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items)] + + +#[repr(C)] +#[derive(Copy)] +#[repr(simd)] +pub struct f32x4(f32, f32, f32, f32); + + +extern { + #[link_name = "llvm.sqrt.v4f32"] + fn vsqrt(x: f32x4) -> f32x4; +} + +pub fn foo(x: f32x4) -> f32x4 { + unsafe {vsqrt(x)} +} + +#[repr(C)] +#[derive(Copy)] +#[repr(simd)] +pub struct i32x4(i32, i32, i32, i32); + + +extern { + // _mm_sll_epi32 + #[cfg(any(target_arch = "x86", + target_arch = "x86-64"))] + #[link_name = "llvm.x86.sse2.psll.d"] + fn integer(a: i32x4, b: i32x4) -> i32x4; + + // vmaxq_s32 + #[cfg(target_arch = "arm")] + #[link_name = "llvm.arm.neon.vmaxs.v4i32"] + fn integer(a: i32x4, b: i32x4) -> i32x4; + // vmaxq_s32 + #[cfg(target_arch = "aarch64")] + #[link_name = "llvm.aarch64.neon.maxs.v4i32"] + fn integer(a: i32x4, b: i32x4) -> i32x4; + + // just some substitute foreign symbol, not an LLVM intrinsic; so + // we still get type checking, but not as detailed as (ab)using + // LLVM. + #[cfg(not(any(target_arch = "x86", + target_arch = "x86-64", + target_arch = "arm", + target_arch = "aarch64")))] + fn integer(a: i32x4, b: i32x4) -> i32x4; +} + +pub fn bar(a: i32x4, b: i32x4) -> i32x4 { + unsafe {integer(a, b)} +} + +#[lang = "sized"] +pub trait Sized { } + +#[lang = "copy"] +pub trait Copy { } + +pub mod marker { + pub use Copy; +} + +#[lang = "freeze"] +auto trait Freeze {} diff --git a/src/test/run-make-fulldeps/simple-dylib/Makefile b/src/test/run-make-fulldeps/simple-dylib/Makefile new file mode 100644 index 00000000000..26730820fea --- /dev/null +++ b/src/test/run-make-fulldeps/simple-dylib/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk +all: + $(RUSTC) bar.rs --crate-type=dylib -C prefer-dynamic + $(RUSTC) foo.rs + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/simple-dylib/bar.rs b/src/test/run-make-fulldeps/simple-dylib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/simple-dylib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/simple-dylib/foo.rs b/src/test/run-make-fulldeps/simple-dylib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/simple-dylib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/simple-rlib/Makefile b/src/test/run-make-fulldeps/simple-rlib/Makefile new file mode 100644 index 00000000000..7b156cb8748 --- /dev/null +++ b/src/test/run-make-fulldeps/simple-rlib/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk +all: + $(RUSTC) bar.rs --crate-type=rlib + $(RUSTC) foo.rs + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/simple-rlib/bar.rs b/src/test/run-make-fulldeps/simple-rlib/bar.rs new file mode 100644 index 00000000000..4c79f7e2855 --- /dev/null +++ b/src/test/run-make-fulldeps/simple-rlib/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/simple-rlib/foo.rs b/src/test/run-make-fulldeps/simple-rlib/foo.rs new file mode 100644 index 00000000000..858ef492ace --- /dev/null +++ b/src/test/run-make-fulldeps/simple-rlib/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; + +fn main() { + bar::bar(); +} diff --git a/src/test/run-make-fulldeps/stable-symbol-names/Makefile b/src/test/run-make-fulldeps/stable-symbol-names/Makefile new file mode 100644 index 00000000000..3cbc5593ac0 --- /dev/null +++ b/src/test/run-make-fulldeps/stable-symbol-names/Makefile @@ -0,0 +1,40 @@ +-include ../tools.mk + +# The following command will: +# 1. dump the symbols of a library using `nm` +# 2. extract only those lines that we are interested in via `grep` +# 3. from those lines, extract just the symbol name via `sed` +# (symbol names always start with "_ZN" and end with "E") +# 4. sort those symbol names for deterministic comparison +# 5. write the result into a file + +dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \ + | grep -E "$(2)" \ + | sed "s/.*\(_ZN.*E\).*/\1/" \ + | sort \ + > "$(TMPDIR)/$(1)$(3).nm" + +# This test +# - compiles each of the two crates 2 times and makes sure each time we get +# exactly the same symbol names +# - makes sure that both crates agree on the same symbol names for monomorphic +# functions + +all: + $(RUSTC) stable-symbol-names1.rs + $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v1) + rm $(TMPDIR)/libstable_symbol_names1.rlib + $(RUSTC) stable-symbol-names1.rs + $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v2) + cmp "$(TMPDIR)/stable_symbol_names1_v1.nm" "$(TMPDIR)/stable_symbol_names1_v2.nm" + + $(RUSTC) stable-symbol-names2.rs + $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v1) + rm $(TMPDIR)/libstable_symbol_names2.rlib + $(RUSTC) stable-symbol-names2.rs + $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v2) + cmp "$(TMPDIR)/stable_symbol_names2_v1.nm" "$(TMPDIR)/stable_symbol_names2_v2.nm" + + $(call dump-symbols,stable_symbol_names1,mono_,_cross) + $(call dump-symbols,stable_symbol_names2,mono_,_cross) + cmp "$(TMPDIR)/stable_symbol_names1_cross.nm" "$(TMPDIR)/stable_symbol_names2_cross.nm" diff --git a/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs new file mode 100644 index 00000000000..7344bdf49f6 --- /dev/null +++ b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names1.rs @@ -0,0 +1,41 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +pub trait Foo { + fn generic_method(); +} + +pub struct Bar; + +impl Foo for Bar { + fn generic_method() {} +} + +pub fn mono_function() { + Bar::generic_method::(); +} + +pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 { + *x +} + +pub fn generic_function(t: T) -> T { + t +} + +pub fn user() { + generic_function(0u32); + generic_function("abc"); + let x = 2u64; + generic_function(&x); + let _ = mono_function_lifetime(&x); +} diff --git a/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs new file mode 100644 index 00000000000..eacba4ddb25 --- /dev/null +++ b/src/test/run-make-fulldeps/stable-symbol-names/stable-symbol-names2.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +extern crate stable_symbol_names1; + +pub fn user() { + stable_symbol_names1::generic_function(1u32); + stable_symbol_names1::generic_function("def"); + let x = 2u64; + stable_symbol_names1::generic_function(&x); + stable_symbol_names1::mono_function(); + stable_symbol_names1::mono_function_lifetime(&0); +} + +pub fn trait_impl_test_function() { + use stable_symbol_names1::*; + Bar::generic_method::(); +} + diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/Makefile b/src/test/run-make-fulldeps/static-dylib-by-default/Makefile new file mode 100644 index 00000000000..6409aa66ae0 --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +TO_LINK := $(call DYLIB,bar) +ifdef IS_MSVC +LINK_ARG = $(TO_LINK:dll=dll.lib) +else +LINK_ARG = $(TO_LINK) +endif + +all: + $(RUSTC) foo.rs + $(RUSTC) bar.rs + $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS) + rm $(TMPDIR)/*.rlib + rm $(call DYLIB,foo) + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs b/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs new file mode 100644 index 00000000000..63da277dece --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/bar.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +extern crate foo; + +#[no_mangle] +pub extern fn bar() { + foo::foo(); +} diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/foo.rs b/src/test/run-make-fulldeps/static-dylib-by-default/foo.rs new file mode 100644 index 00000000000..341040e653c --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/foo.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![crate_type = "dylib"] + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/static-dylib-by-default/main.c b/src/test/run-make-fulldeps/static-dylib-by-default/main.c new file mode 100644 index 00000000000..30bb0783edf --- /dev/null +++ b/src/test/run-make-fulldeps/static-dylib-by-default/main.c @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern void bar(); + +int main() { + bar(); + return 0; +} diff --git a/src/test/run-make-fulldeps/static-nobundle/Makefile b/src/test/run-make-fulldeps/static-nobundle/Makefile new file mode 100644 index 00000000000..abc32d4423b --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +# aaa is a native static library +# bbb is a rlib +# ccc is a dylib +# ddd is an executable + +all: $(call NATIVE_STATICLIB,aaa) + $(RUSTC) bbb.rs --crate-type=rlib + + # Check that bbb does NOT contain the definition of `native_func` + nm $(TMPDIR)/libbbb.rlib | $(CGREP) -ve "T _*native_func" + nm $(TMPDIR)/libbbb.rlib | $(CGREP) -e "U _*native_func" + + # Check that aaa gets linked (either as `-l aaa` or `aaa.lib`) when building ccc. + $(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib -Z print-link-args | $(CGREP) -e '-l[" ]*aaa|aaa\.lib' + + # Check that aaa does NOT get linked when building ddd. + $(RUSTC) ddd.rs -Z print-link-args | $(CGREP) -ve '-l[" ]*aaa|aaa\.lib' + + $(call RUN,ddd) diff --git a/src/test/run-make-fulldeps/static-nobundle/aaa.c b/src/test/run-make-fulldeps/static-nobundle/aaa.c new file mode 100644 index 00000000000..806ef878c70 --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/aaa.c @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void native_func() {} diff --git a/src/test/run-make-fulldeps/static-nobundle/bbb.rs b/src/test/run-make-fulldeps/static-nobundle/bbb.rs new file mode 100644 index 00000000000..2bd69c99327 --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/bbb.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(static_nobundle)] + +#[link(name = "aaa", kind = "static-nobundle")] +extern { + pub fn native_func(); +} + +pub fn wrapped_func() { + unsafe { + native_func(); + } +} diff --git a/src/test/run-make-fulldeps/static-nobundle/ccc.rs b/src/test/run-make-fulldeps/static-nobundle/ccc.rs new file mode 100644 index 00000000000..bd34753a00d --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/ccc.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +extern crate bbb; + +pub fn do_work() { + unsafe { bbb::native_func(); } + bbb::wrapped_func(); +} + +pub fn do_work_generic() { + unsafe { bbb::native_func(); } + bbb::wrapped_func(); +} diff --git a/src/test/run-make-fulldeps/static-nobundle/ddd.rs b/src/test/run-make-fulldeps/static-nobundle/ddd.rs new file mode 100644 index 00000000000..f7d23a899f7 --- /dev/null +++ b/src/test/run-make-fulldeps/static-nobundle/ddd.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate ccc; + +fn main() { + ccc::do_work(); + ccc::do_work_generic::(); + ccc::do_work_generic::(); +} diff --git a/src/test/run-make-fulldeps/static-unwinding/Makefile b/src/test/run-make-fulldeps/static-unwinding/Makefile new file mode 100644 index 00000000000..cb039744265 --- /dev/null +++ b/src/test/run-make-fulldeps/static-unwinding/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) lib.rs + $(RUSTC) main.rs + $(call RUN,main) diff --git a/src/test/run-make-fulldeps/static-unwinding/lib.rs b/src/test/run-make-fulldeps/static-unwinding/lib.rs new file mode 100644 index 00000000000..12c72d54c09 --- /dev/null +++ b/src/test/run-make-fulldeps/static-unwinding/lib.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub static mut statik: isize = 0; + +struct A; +impl Drop for A { + fn drop(&mut self) { + unsafe { statik = 1; } + } +} + +pub fn callback(f: F) where F: FnOnce() { + let _a = A; + f(); +} diff --git a/src/test/run-make-fulldeps/static-unwinding/main.rs b/src/test/run-make-fulldeps/static-unwinding/main.rs new file mode 100644 index 00000000000..1cd785334f6 --- /dev/null +++ b/src/test/run-make-fulldeps/static-unwinding/main.rs @@ -0,0 +1,34 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate lib; + +use std::thread; + +static mut statik: isize = 0; + +struct A; +impl Drop for A { + fn drop(&mut self) { + unsafe { statik = 1; } + } +} + +fn main() { + thread::spawn(move|| { + let _a = A; + lib::callback(|| panic!()); + }).join().unwrap_err(); + + unsafe { + assert_eq!(lib::statik, 1); + assert_eq!(statik, 1); + } +} diff --git a/src/test/run-make-fulldeps/staticlib-blank-lib/Makefile b/src/test/run-make-fulldeps/staticlib-blank-lib/Makefile new file mode 100644 index 00000000000..92a278825c2 --- /dev/null +++ b/src/test/run-make-fulldeps/staticlib-blank-lib/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(AR) crus $(TMPDIR)/libfoo.a foo.rs + $(AR) d $(TMPDIR)/libfoo.a foo.rs + $(RUSTC) foo.rs diff --git a/src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs b/src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs new file mode 100644 index 00000000000..6010e60e95c --- /dev/null +++ b/src/test/run-make-fulldeps/staticlib-blank-lib/foo.rs @@ -0,0 +1,16 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +#[link(name = "foo", kind = "static")] +extern {} + +fn main() {} diff --git a/src/test/run-make-fulldeps/stdin-non-utf8/Makefile b/src/test/run-make-fulldeps/stdin-non-utf8/Makefile new file mode 100644 index 00000000000..7948c442616 --- /dev/null +++ b/src/test/run-make-fulldeps/stdin-non-utf8/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + cp non-utf8 $(TMPDIR)/non-utf.rs + cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \ + | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8" diff --git a/src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 b/src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 new file mode 100644 index 00000000000..bc87051a852 --- /dev/null +++ b/src/test/run-make-fulldeps/stdin-non-utf8/non-utf8 @@ -0,0 +1 @@ +Ò diff --git a/src/test/run-make-fulldeps/suspicious-library/Makefile b/src/test/run-make-fulldeps/suspicious-library/Makefile new file mode 100644 index 00000000000..12f437075fb --- /dev/null +++ b/src/test/run-make-fulldeps/suspicious-library/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -C prefer-dynamic + touch $(call DYLIB,foo-something-special) + touch $(call DYLIB,foo-something-special2) + $(RUSTC) bar.rs diff --git a/src/test/run-make-fulldeps/suspicious-library/bar.rs b/src/test/run-make-fulldeps/suspicious-library/bar.rs new file mode 100644 index 00000000000..ed0e8a7e23e --- /dev/null +++ b/src/test/run-make-fulldeps/suspicious-library/bar.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { foo::foo() } diff --git a/src/test/run-make-fulldeps/suspicious-library/foo.rs b/src/test/run-make-fulldeps/suspicious-library/foo.rs new file mode 100644 index 00000000000..2ec6e3834a1 --- /dev/null +++ b/src/test/run-make-fulldeps/suspicious-library/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +pub fn foo() {} diff --git a/src/test/run-make-fulldeps/symbol-visibility/Makefile b/src/test/run-make-fulldeps/symbol-visibility/Makefile new file mode 100644 index 00000000000..f1ada814bdb --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/Makefile @@ -0,0 +1,60 @@ +include ../tools.mk + +ifdef IS_WINDOWS +# Do nothing on MSVC. +# On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't +# seem to work reliably. +all: + exit 0 +else + +NM=nm -D +CDYLIB_NAME=liba_cdylib.so +RDYLIB_NAME=liba_rust_dylib.so +EXE_NAME=an_executable +COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so + +ifeq ($(UNAME),Darwin) +NM=nm -gU +CDYLIB_NAME=liba_cdylib.dylib +RDYLIB_NAME=liba_rust_dylib.dylib +EXE_NAME=an_executable +COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib +endif + +all: + $(RUSTC) an_rlib.rs + $(RUSTC) a_cdylib.rs + $(RUSTC) a_rust_dylib.rs + $(RUSTC) an_executable.rs + $(RUSTC) a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib + + # Check that a cdylib exports its public #[no_mangle] functions + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] + # Check that a cdylib exports the public #[no_mangle] functions of dependencies + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + # Check that a cdylib DOES NOT export any public Rust functions + [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] + + # Check that a Rust dylib exports its monomorphic functions + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ] + + # Check that a Rust dylib exports the monomorphic functions from its dependencies + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ] + + # Check that an executable does not export any dynamic symbols + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ] + [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ] + + + # Check the combined case, where we generate a cdylib and an rlib in the same + # compilation session: + # Check that a cdylib exports its public #[no_mangle] functions + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] + # Check that a cdylib exports the public #[no_mangle] functions of dependencies + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] + # Check that a cdylib DOES NOT export any public Rust functions + [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] +endif diff --git a/src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs b/src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs new file mode 100644 index 00000000000..9a70542c06c --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/a_cdylib.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="cdylib"] + +extern crate an_rlib; + +// This should not be exported +pub fn public_rust_function_from_cdylib() {} + +// This should be exported +#[no_mangle] +pub extern "C" fn public_c_function_from_cdylib() { + an_rlib::public_c_function_from_rlib(); +} diff --git a/src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs b/src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs new file mode 100644 index 00000000000..b826211c9a4 --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/a_rust_dylib.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="dylib"] + +extern crate an_rlib; + +// This should be exported +pub fn public_rust_function_from_rust_dylib() {} + +// This should be exported +#[no_mangle] +pub extern "C" fn public_c_function_from_rust_dylib() {} diff --git a/src/test/run-make-fulldeps/symbol-visibility/an_executable.rs b/src/test/run-make-fulldeps/symbol-visibility/an_executable.rs new file mode 100644 index 00000000000..73059c5e374 --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/an_executable.rs @@ -0,0 +1,17 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="bin"] + +extern crate an_rlib; + +pub fn public_rust_function_from_exe() {} + +fn main() {} diff --git a/src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs b/src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs new file mode 100644 index 00000000000..cd19500d140 --- /dev/null +++ b/src/test/run-make-fulldeps/symbol-visibility/an_rlib.rs @@ -0,0 +1,16 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +pub fn public_rust_function_from_rlib() {} + +#[no_mangle] +pub extern "C" fn public_c_function_from_rlib() {} diff --git a/src/test/run-make-fulldeps/symbols-are-reasonable/Makefile b/src/test/run-make-fulldeps/symbols-are-reasonable/Makefile new file mode 100644 index 00000000000..a6d294d2a1c --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-are-reasonable/Makefile @@ -0,0 +1,13 @@ +-include ../tools.mk + +# check that the compile generated symbols for strings, binaries, +# vtables, etc. have semisane names (e.g. `str.1234`); it's relatively +# easy to accidentally modify the compiler internals to make them +# become things like `str"str"(1234)`. + +OUT=$(TMPDIR)/lib.s + +all: + $(RUSTC) lib.rs --emit=asm --crate-type=staticlib + # just check for symbol declarations with the names we're expecting. + $(CGREP) -e 'str\.[0-9]+:' 'byte_str\.[0-9]+:' 'vtable\.[0-9]+' < $(OUT) diff --git a/src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs b/src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs new file mode 100644 index 00000000000..b9285b24cd6 --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-are-reasonable/lib.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub static X: &'static str = "foobarbaz"; +pub static Y: &'static [u8] = include_bytes!("lib.rs"); + +trait Foo { fn dummy(&self) { } } +impl Foo for usize {} + +#[no_mangle] +pub extern "C" fn dummy() { + // force the vtable to be created + let _x = &1usize as &Foo; +} diff --git a/src/test/run-make-fulldeps/symbols-include-type-name/Makefile b/src/test/run-make-fulldeps/symbols-include-type-name/Makefile new file mode 100644 index 00000000000..0850a2633e5 --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-include-type-name/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +# Check that symbol names for methods include type names, instead of . + +OUT=$(TMPDIR)/lib.s + +all: + $(RUSTC) --crate-type staticlib --emit asm lib.rs + $(CGREP) Def < $(OUT) diff --git a/src/test/run-make-fulldeps/symbols-include-type-name/lib.rs b/src/test/run-make-fulldeps/symbols-include-type-name/lib.rs new file mode 100644 index 00000000000..d84f1617db5 --- /dev/null +++ b/src/test/run-make-fulldeps/symbols-include-type-name/lib.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Def { + pub id: i32, +} + +impl Def { + pub fn new(id: i32) -> Def { + Def { id: id } + } +} + +#[no_mangle] +pub fn user() { + let _ = Def::new(0); +} diff --git a/src/test/run-make-fulldeps/symlinked-extern/Makefile b/src/test/run-make-fulldeps/symlinked-extern/Makefile new file mode 100644 index 00000000000..88dbad51e48 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/Makefile @@ -0,0 +1,16 @@ +-include ../tools.mk + +# ignore windows: `ln` is actually `cp` on msys. +ifndef IS_WINDOWS + +all: + $(RUSTC) foo.rs + mkdir -p $(TMPDIR)/other + ln -nsf $(TMPDIR)/libfoo.rlib $(TMPDIR)/other + $(RUSTC) bar.rs -L $(TMPDIR) + $(RUSTC) baz.rs --extern foo=$(TMPDIR)/other/libfoo.rlib -L $(TMPDIR) + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/symlinked-extern/bar.rs b/src/test/run-make-fulldeps/symlinked-extern/bar.rs new file mode 100644 index 00000000000..79103f24017 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/bar.rs @@ -0,0 +1,16 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +extern crate foo; + +pub fn bar(_s: foo::S) { +} diff --git a/src/test/run-make-fulldeps/symlinked-extern/baz.rs b/src/test/run-make-fulldeps/symlinked-extern/baz.rs new file mode 100644 index 00000000000..0f6ba254368 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/baz.rs @@ -0,0 +1,16 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate bar; +extern crate foo; + +fn main() { + bar::bar(foo::foo()); +} diff --git a/src/test/run-make-fulldeps/symlinked-extern/foo.rs b/src/test/run-make-fulldeps/symlinked-extern/foo.rs new file mode 100644 index 00000000000..0b8bb64d375 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-extern/foo.rs @@ -0,0 +1,15 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] + +pub struct S; + +pub fn foo() -> S { S } diff --git a/src/test/run-make-fulldeps/symlinked-libraries/Makefile b/src/test/run-make-fulldeps/symlinked-libraries/Makefile new file mode 100644 index 00000000000..ac595546aa7 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-libraries/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +# ignore windows: `ln` is actually `cp` on msys. +ifndef IS_WINDOWS + +all: + $(RUSTC) foo.rs -C prefer-dynamic + mkdir -p $(TMPDIR)/other + ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other + $(RUSTC) bar.rs -L $(TMPDIR)/other + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/symlinked-libraries/bar.rs b/src/test/run-make-fulldeps/symlinked-libraries/bar.rs new file mode 100644 index 00000000000..73596f93f56 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-libraries/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::bar(); +} diff --git a/src/test/run-make-fulldeps/symlinked-libraries/foo.rs b/src/test/run-make-fulldeps/symlinked-libraries/foo.rs new file mode 100644 index 00000000000..fdb29974cd8 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-libraries/foo.rs @@ -0,0 +1,13 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/symlinked-rlib/Makefile b/src/test/run-make-fulldeps/symlinked-rlib/Makefile new file mode 100644 index 00000000000..2709f786e0a --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-rlib/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +# ignore windows: `ln` is actually `cp` on msys. +ifndef IS_WINDOWS + +all: + $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo.xxx + ln -nsf $(TMPDIR)/foo.xxx $(TMPDIR)/libfoo.rlib + $(RUSTC) bar.rs -L $(TMPDIR) + +else +all: + +endif diff --git a/src/test/run-make-fulldeps/symlinked-rlib/bar.rs b/src/test/run-make-fulldeps/symlinked-rlib/bar.rs new file mode 100644 index 00000000000..e8f06680862 --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-rlib/bar.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate foo; + +fn main() { + foo::bar(); +} diff --git a/src/test/run-make-fulldeps/symlinked-rlib/foo.rs b/src/test/run-make-fulldeps/symlinked-rlib/foo.rs new file mode 100644 index 00000000000..5abbb1dcbce --- /dev/null +++ b/src/test/run-make-fulldeps/symlinked-rlib/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn bar() {} diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile new file mode 100644 index 00000000000..a35174b3c2a --- /dev/null +++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile @@ -0,0 +1,2 @@ +all: + python2.7 test.py diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py new file mode 100644 index 00000000000..210059e1010 --- /dev/null +++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/test.py @@ -0,0 +1,71 @@ +# Copyright 2015 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +import sys +import os +from os import listdir +from os.path import isfile, join +from subprocess import PIPE, Popen + + +# This is a whitelist of files which are stable crates or simply are not crates, +# we don't check for the instability of these crates as they're all stable! +STABLE_CRATES = ['std', 'core', 'proc_macro', 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', + 'clang_rt'] + + +def convert_to_string(s): + if s.__class__.__name__ == 'bytes': + return s.decode('utf-8') + return s + + +def exec_command(command, to_input=None): + child = None + if to_input is None: + child = Popen(command, stdout=PIPE, stderr=PIPE) + else: + child = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) + stdout, stderr = child.communicate(input=to_input) + return (convert_to_string(stdout), convert_to_string(stderr)) + + +def check_lib(lib): + if lib['name'] in STABLE_CRATES: + return True + print('verifying if {} is an unstable crate'.format(lib['name'])) + stdout, stderr = exec_command([os.environ['RUSTC'], '-', '--crate-type', 'rlib', + '--extern', '{}={}'.format(lib['name'], lib['path'])], + to_input='extern crate {};'.format(lib['name'])) + if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr): + print('crate {} "{}" is not unstable'.format(lib['name'], lib['path'])) + print('{}{}'.format(stdout, stderr)) + print('') + return False + return True + +# Generate a list of all crates in the sysroot. To do this we list all files in +# rustc's sysroot, look at the filename, strip everything after the `-`, and +# strip the leading `lib` (if present) +def get_all_libs(dir_path): + return [{ 'path': join(dir_path, f), 'name': f[3:].split('-')[0] } + for f in listdir(dir_path) + if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES] + + +sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '') +libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET']))) + +ret = 0 +for lib in libs: + if not check_lib(lib): + # We continue so users can see all the not unstable crates. + ret = 1 +sys.exit(ret) diff --git a/src/test/run-make-fulldeps/target-cpu-native/Makefile b/src/test/run-make-fulldeps/target-cpu-native/Makefile new file mode 100644 index 00000000000..0c9d93ecb2a --- /dev/null +++ b/src/test/run-make-fulldeps/target-cpu-native/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) foo.rs -C target-cpu=native + $(call RUN,foo) diff --git a/src/test/run-make-fulldeps/target-cpu-native/foo.rs b/src/test/run-make-fulldeps/target-cpu-native/foo.rs new file mode 100644 index 00000000000..f7a9f969060 --- /dev/null +++ b/src/test/run-make-fulldeps/target-cpu-native/foo.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { +} diff --git a/src/test/run-make-fulldeps/target-specs/Makefile b/src/test/run-make-fulldeps/target-specs/Makefile new file mode 100644 index 00000000000..aff15ce38b4 --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk +all: + $(RUSTC) foo.rs --target=my-awesome-platform.json --crate-type=lib --emit=asm + $(CGREP) -v morestack < $(TMPDIR)/foo.s + $(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | $(CGREP) "Error loading target specification" + $(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | $(CGREP) 'Field llvm-target' + RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm + RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm + $(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json - diff --git a/src/test/run-make-fulldeps/target-specs/foo.rs b/src/test/run-make-fulldeps/target-specs/foo.rs new file mode 100644 index 00000000000..bbd1c5d900f --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/foo.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(lang_items, no_core, optin_builtin_traits)] +#![no_core] + +#[lang="copy"] +trait Copy { } + +#[lang="sized"] +trait Sized { } + +#[lang = "freeze"] +auto trait Freeze {} + +#[lang="start"] +fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize { 0 } + +extern { + fn _foo() -> [u8; 16]; +} + +fn _main() { + let _a = unsafe { _foo() }; +} diff --git a/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json new file mode 100644 index 00000000000..8d028280a8d --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json @@ -0,0 +1,11 @@ +{ + "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", + "linker-flavor": "gcc", + "llvm-target": "i686-unknown-linux-gnu", + "target-endian": "little", + "target-pointer-width": "32", + "target-c-int-width": "32", + "arch": "x86", + "os": "linux", + "morestack": false +} diff --git a/src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json b/src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json new file mode 100644 index 00000000000..ceaa25cdf2f --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-incomplete-platform.json @@ -0,0 +1,10 @@ +{ + "data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32", + "linker-flavor": "gcc", + "target-endian": "little", + "target-pointer-width": "32", + "target-c-int-width": "32", + "arch": "x86", + "os": "foo", + "morestack": false +} diff --git a/src/test/run-make-fulldeps/target-specs/my-invalid-platform.json b/src/test/run-make-fulldeps/target-specs/my-invalid-platform.json new file mode 100644 index 00000000000..3feac45b7d6 --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-invalid-platform.json @@ -0,0 +1 @@ +wow this json is really broke! diff --git a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json new file mode 100644 index 00000000000..3ae01d72fcc --- /dev/null +++ b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json @@ -0,0 +1,12 @@ +{ + "pre-link-args": ["-m64"], + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "linker-flavor": "gcc", + "llvm-target": "x86_64-unknown-linux-gnu", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "arch": "x86_64", + "os": "linux", + "morestack": false +} diff --git a/src/test/run-make-fulldeps/target-without-atomics/Makefile b/src/test/run-make-fulldeps/target-without-atomics/Makefile new file mode 100644 index 00000000000..c5f575ddf84 --- /dev/null +++ b/src/test/run-make-fulldeps/target-without-atomics/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +# The target used below doesn't support atomic operations. Verify that's the case +all: + $(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v target_has_atomic diff --git a/src/test/run-make-fulldeps/test-harness/Makefile b/src/test/run-make-fulldeps/test-harness/Makefile new file mode 100644 index 00000000000..39477c07ced --- /dev/null +++ b/src/test/run-make-fulldeps/test-harness/Makefile @@ -0,0 +1,8 @@ +-include ../tools.mk + +all: + # check that #[cfg_attr(..., ignore)] does the right thing. + $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg + $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored' + $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$" + $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should' diff --git a/src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs b/src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs new file mode 100644 index 00000000000..990d3d10485 --- /dev/null +++ b/src/test/run-make-fulldeps/test-harness/test-ignore-cfg.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[test] +#[cfg_attr(ignorecfg, ignore)] +fn shouldignore() { +} + +#[test] +#[cfg_attr(noignorecfg, ignore)] +fn shouldnotignore() { +} diff --git a/src/test/run-make-fulldeps/tools.mk b/src/test/run-make-fulldeps/tools.mk new file mode 100644 index 00000000000..af1707de6c0 --- /dev/null +++ b/src/test/run-make-fulldeps/tools.mk @@ -0,0 +1,134 @@ +# These deliberately use `=` and not `:=` so that client makefiles can +# augment HOST_RPATH_DIR / TARGET_RPATH_DIR. +HOST_RPATH_ENV = \ + $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" +TARGET_RPATH_ENV = \ + $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" + +RUSTC_ORIGINAL := $(RUSTC) +BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)' +BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)' +RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS) +RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR) +ifdef RUSTC_LINKER +RUSTC := $(RUSTC) -Clinker=$(RUSTC_LINKER) +RUSTDOC := $(RUSTDOC) --linker $(RUSTC_LINKER) -Z unstable-options +endif +#CC := $(CC) -L $(TMPDIR) +HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py +CGREP := "$(S)/src/etc/cat-and-grep.sh" + +# This is the name of the binary we will generate and run; use this +# e.g. for `$(CC) -o $(RUN_BINFILE)`. +RUN_BINFILE = $(TMPDIR)/$(1) + +# RUN and FAIL are basic way we will invoke the generated binary. On +# non-windows platforms, they set the LD_LIBRARY_PATH environment +# variable before running the binary. + +RLIB_GLOB = lib$(1)*.rlib +BIN = $(1) + +UNAME = $(shell uname) + +ifeq ($(UNAME),Darwin) +RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) +FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 +DYLIB_GLOB = lib$(1)*.dylib +DYLIB = $(TMPDIR)/lib$(1).dylib +STATICLIB = $(TMPDIR)/lib$(1).a +STATICLIB_GLOB = lib$(1)*.a +else +ifdef IS_WINDOWS +RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) +FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0 +DYLIB_GLOB = $(1)*.dll +DYLIB = $(TMPDIR)/$(1).dll +STATICLIB = $(TMPDIR)/$(1).lib +STATICLIB_GLOB = $(1)*.lib +BIN = $(1).exe +else +RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) +FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 +DYLIB_GLOB = lib$(1)*.so +DYLIB = $(TMPDIR)/lib$(1).so +STATICLIB = $(TMPDIR)/lib$(1).a +STATICLIB_GLOB = lib$(1)*.a +endif +endif + +ifdef IS_MSVC +COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2) +NATIVE_STATICLIB_FILE = $(1).lib +NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1)) +OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \ + -Fo:`cygpath -w $(TMPDIR)/$(1).obj` +else +COMPILE_OBJ = $(CC) -c -o $(1) $(2) +NATIVE_STATICLIB_FILE = lib$(1).a +NATIVE_STATICLIB = $(call STATICLIB,$(1)) +OUT_EXE=-o $(TMPDIR)/$(1) +endif + + +# Extra flags needed to compile a working executable with the standard library +ifdef IS_WINDOWS +ifdef IS_MSVC + EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib +else + EXTRACFLAGS := -lws2_32 -luserenv +endif +else +ifeq ($(UNAME),Darwin) + EXTRACFLAGS := -lresolv +else +ifeq ($(UNAME),FreeBSD) + EXTRACFLAGS := -lm -lpthread -lgcc_s +else +ifeq ($(UNAME),Bitrig) + EXTRACFLAGS := -lm -lpthread + EXTRACXXFLAGS := -lc++ -lc++abi +else +ifeq ($(UNAME),SunOS) + EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv +else +ifeq ($(UNAME),OpenBSD) + EXTRACFLAGS := -lm -lpthread -lc++abi + RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))" +else + EXTRACFLAGS := -lm -lrt -ldl -lpthread + EXTRACXXFLAGS := -lstdc++ +endif +endif +endif +endif +endif +endif + +REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1)) +REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1)) + +%.a: %.o + $(AR) crus $@ $< +ifdef IS_MSVC +%.lib: lib%.o + $(MSVC_LIB) -out:`cygpath -w $@` $< +else +%.lib: lib%.o + $(AR) crus $@ $< +endif +%.dylib: %.o + $(CC) -dynamiclib -Wl,-dylib -o $@ $< +%.so: %.o + $(CC) -o $@ $< -shared + +ifdef IS_MSVC +%.dll: lib%.o + $(CC) $< -link -dll -out:`cygpath -w $@` +else +%.dll: lib%.o + $(CC) -o $@ $< -shared +endif + +$(TMPDIR)/lib%.o: %.c + $(call COMPILE_OBJ,$@,$<) diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/Makefile b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile new file mode 100644 index 00000000000..f99e4611174 --- /dev/null +++ b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \ + | $(CGREP) "panicked at 'encountered error with \`-Z treat_err_as_bug'" diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/err.rs b/src/test/run-make-fulldeps/treat-err-as-bug/err.rs new file mode 100644 index 00000000000..078495663ac --- /dev/null +++ b/src/test/run-make-fulldeps/treat-err-as-bug/err.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="rlib"] + +pub static C: u32 = 0-1; diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile new file mode 100644 index 00000000000..9fd1377322b --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/Makefile @@ -0,0 +1,19 @@ +-include ../tools.mk + +all: + # compile two different versions of crateA + $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1 + $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2 + # make crateB depend on version 1 of crateA + $(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib + # make crateC depend on version 2 of crateA + $(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \ + tr -d '\r\n' | $(CGREP) -e \ + "mismatched types.*\ + crateB::try_foo\(foo2\);.*\ + expected struct \`crateA::foo::Foo\`, found struct \`crateA::Foo\`.*\ + different versions of crate \`crateA\`.*\ + mismatched types.*\ + crateB::try_bar\(bar2\);.*\ + expected trait \`crateA::bar::Bar\`, found trait \`crateA::Bar\`.*\ + different versions of crate \`crateA\`" diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs new file mode 100644 index 00000000000..e40266bb4cd --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateA.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod foo { + pub struct Foo; +} + +mod bar { + pub trait Bar{} + + pub fn bar() -> Box { + unimplemented!() + } +} + +// This makes the publicly accessible path +// differ from the internal one. +pub use foo::Foo; +pub use bar::{Bar, bar}; diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs new file mode 100644 index 00000000000..da4ea1c9387 --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateB.rs @@ -0,0 +1,14 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate crateA; + +pub fn try_foo(x: crateA::Foo){} +pub fn try_bar(x: Box){} diff --git a/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs new file mode 100644 index 00000000000..210bc4c8320 --- /dev/null +++ b/src/test/run-make-fulldeps/type-mismatch-same-crate-name/crateC.rs @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This tests the extra note reported when a type error deals with +// seemingly identical types. +// The main use case of this error is when there are two crates +// (generally different versions of the same crate) with the same name +// causing a type mismatch. + +// The test is nearly the same as the one in +// compile-fail/type-mismatch-same-crate-name.rs +// but deals with the case where one of the crates +// is only introduced as an indirect dependency. +// and the type is accessed via a re-export. +// This is similar to how the error can be introduced +// when using cargo's automatic dependency resolution. + +extern crate crateA; + +fn main() { + let foo2 = crateA::Foo; + let bar2 = crateA::bar(); + { + extern crate crateB; + crateB::try_foo(foo2); + crateB::try_bar(bar2); + } +} diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile new file mode 100644 index 00000000000..cc7bc176f49 --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +SKIP_OS := 'FreeBSD OpenBSD Bitrig SunOS' + +ifneq ($(UNAME),$(findstring $(UNAME),$(SKIP_OS))) + +HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //') +ifeq ($(findstring i686,$(HOST)),i686) +TARGET := $(subst i686,x86_64,$(HOST)) +else +TARGET := $(subst x86_64,i686,$(HOST)) +endif + +all: + $(RUSTC) foo.rs -C extra-filename=-host + $(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET) + $(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET) +else +# FreeBSD, OpenBSD, and Bitrig support only x86_64 architecture for now +all: +endif diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs b/src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs new file mode 100644 index 00000000000..3e99ed60c62 --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/bar.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] +#![crate_name = "a"] + +#[macro_export] +macro_rules! bar { + () => () +} diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs b/src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs new file mode 100644 index 00000000000..3f15d0e6e05 --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/baz.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] + +#[macro_use] +extern crate a; + +bar!(); diff --git a/src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs b/src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs new file mode 100644 index 00000000000..0afd3be466d --- /dev/null +++ b/src/test/run-make-fulldeps/use-extern-for-plugins/foo.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![no_std] +#![crate_type = "lib"] +#![crate_name = "a"] + +#[macro_export] +macro_rules! foo { + () => () +} diff --git a/src/test/run-make-fulldeps/used/Makefile b/src/test/run-make-fulldeps/used/Makefile new file mode 100644 index 00000000000..47edcbb5d0a --- /dev/null +++ b/src/test/run-make-fulldeps/used/Makefile @@ -0,0 +1,11 @@ +-include ../tools.mk + +ifdef IS_WINDOWS +# Do nothing on MSVC. +all: + exit 0 +else +all: + $(RUSTC) -C opt-level=3 --emit=obj used.rs + nm $(TMPDIR)/used.o | $(CGREP) FOO +endif diff --git a/src/test/run-make-fulldeps/used/used.rs b/src/test/run-make-fulldeps/used/used.rs new file mode 100644 index 00000000000..186cd0fdf5e --- /dev/null +++ b/src/test/run-make-fulldeps/used/used.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![feature(used)] + +#[used] +static FOO: u32 = 0; + +static BAR: u32 = 0; diff --git a/src/test/run-make-fulldeps/version/Makefile b/src/test/run-make-fulldeps/version/Makefile new file mode 100644 index 00000000000..23e14a9cb93 --- /dev/null +++ b/src/test/run-make-fulldeps/version/Makefile @@ -0,0 +1,6 @@ +-include ../tools.mk + +all: + $(RUSTC) -V + $(RUSTC) -vV + $(RUSTC) --version --verbose diff --git a/src/test/run-make-fulldeps/volatile-intrinsics/Makefile b/src/test/run-make-fulldeps/volatile-intrinsics/Makefile new file mode 100644 index 00000000000..acbadbef9fb --- /dev/null +++ b/src/test/run-make-fulldeps/volatile-intrinsics/Makefile @@ -0,0 +1,9 @@ +-include ../tools.mk + +all: + # The tests must pass... + $(RUSTC) main.rs + $(call RUN,main) + # ... and the loads/stores must not be optimized out. + $(RUSTC) main.rs --emit=llvm-ir + $(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll diff --git a/src/test/run-make-fulldeps/volatile-intrinsics/main.rs b/src/test/run-make-fulldeps/volatile-intrinsics/main.rs new file mode 100644 index 00000000000..4d0d7672101 --- /dev/null +++ b/src/test/run-make-fulldeps/volatile-intrinsics/main.rs @@ -0,0 +1,27 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(core_intrinsics, volatile)] + +use std::intrinsics::{volatile_load, volatile_store}; +use std::ptr::{read_volatile, write_volatile}; + +pub fn main() { + unsafe { + let mut i : isize = 1; + volatile_store(&mut i, 2); + assert_eq!(volatile_load(&i), 2); + } + unsafe { + let mut i : isize = 1; + write_volatile(&mut i, 2); + assert_eq!(read_volatile(&i), 2); + } +} diff --git a/src/test/run-make-fulldeps/weird-output-filenames/Makefile b/src/test/run-make-fulldeps/weird-output-filenames/Makefile new file mode 100644 index 00000000000..f161fe9f8e8 --- /dev/null +++ b/src/test/run-make-fulldeps/weird-output-filenames/Makefile @@ -0,0 +1,15 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR)/.foo.rs + $(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \ + | $(CGREP) -e "invalid character.*in crate name:" + cp foo.rs $(TMPDIR)/.foo.bar + $(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \ + | $(CGREP) -e "invalid character.*in crate name:" + cp foo.rs $(TMPDIR)/+foo+bar.rs + $(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \ + | $(CGREP) -e "invalid character.*in crate name:" + cp foo.rs $(TMPDIR)/-foo.rs + $(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \ + | $(CGREP) 'crate names cannot start with a `-`' diff --git a/src/test/run-make-fulldeps/weird-output-filenames/foo.rs b/src/test/run-make-fulldeps/weird-output-filenames/foo.rs new file mode 100644 index 00000000000..8ae3d072362 --- /dev/null +++ b/src/test/run-make-fulldeps/weird-output-filenames/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} diff --git a/src/test/run-make-fulldeps/windows-spawn/Makefile b/src/test/run-make-fulldeps/windows-spawn/Makefile new file mode 100644 index 00000000000..f0d4242260f --- /dev/null +++ b/src/test/run-make-fulldeps/windows-spawn/Makefile @@ -0,0 +1,14 @@ +-include ../tools.mk + +ifdef IS_WINDOWS + +all: + $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs + $(RUSTC) spawn.rs + $(TMPDIR)/spawn.exe + +else + +all: + +endif diff --git a/src/test/run-make-fulldeps/windows-spawn/hello.rs b/src/test/run-make-fulldeps/windows-spawn/hello.rs new file mode 100644 index 00000000000..b177f41941d --- /dev/null +++ b/src/test/run-make-fulldeps/windows-spawn/hello.rs @@ -0,0 +1,13 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + println!("Hello World!"); +} diff --git a/src/test/run-make-fulldeps/windows-spawn/spawn.rs b/src/test/run-make-fulldeps/windows-spawn/spawn.rs new file mode 100644 index 00000000000..2913cbe2260 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-spawn/spawn.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::io::ErrorKind; +use std::process::Command; + +fn main() { + // Make sure it doesn't try to run "hopefullydoesntexist bar.exe". + assert_eq!(Command::new("hopefullydoesntexist") + .arg("bar") + .spawn() + .unwrap_err() + .kind(), + ErrorKind::NotFound); +} diff --git a/src/test/run-make-fulldeps/windows-subsystem/Makefile b/src/test/run-make-fulldeps/windows-subsystem/Makefile new file mode 100644 index 00000000000..34fb5db32f9 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-subsystem/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) windows.rs + $(RUSTC) console.rs diff --git a/src/test/run-make-fulldeps/windows-subsystem/console.rs b/src/test/run-make-fulldeps/windows-subsystem/console.rs new file mode 100644 index 00000000000..ffad1e35ee6 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-subsystem/console.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![windows_subsystem = "console"] + +fn main() {} + diff --git a/src/test/run-make-fulldeps/windows-subsystem/windows.rs b/src/test/run-make-fulldeps/windows-subsystem/windows.rs new file mode 100644 index 00000000000..33cbe320591 --- /dev/null +++ b/src/test/run-make-fulldeps/windows-subsystem/windows.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![windows_subsystem = "windows"] + +fn main() {} diff --git a/src/test/run-make/a-b-a-linker-guard/Makefile b/src/test/run-make/a-b-a-linker-guard/Makefile deleted file mode 100644 index 0962ebfbff5..00000000000 --- a/src/test/run-make/a-b-a-linker-guard/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -# Test that if we build `b` against a version of `a` that has one set -# of types, it will not run with a dylib that has a different set of -# types. - -all: - $(RUSTC) a.rs --cfg x -C prefer-dynamic - $(RUSTC) b.rs -C prefer-dynamic - $(call RUN,b) - $(RUSTC) a.rs --cfg y -C prefer-dynamic - $(call FAIL,b) diff --git a/src/test/run-make/a-b-a-linker-guard/a.rs b/src/test/run-make/a-b-a-linker-guard/a.rs deleted file mode 100644 index c6680a78819..00000000000 --- a/src/test/run-make/a-b-a-linker-guard/a.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "a"] -#![crate_type = "dylib"] - -#[cfg(x)] -pub fn foo(x: u32) { } - -#[cfg(y)] -pub fn foo(x: i32) { } diff --git a/src/test/run-make/a-b-a-linker-guard/b.rs b/src/test/run-make/a-b-a-linker-guard/b.rs deleted file mode 100644 index 89fd48de5bb..00000000000 --- a/src/test/run-make/a-b-a-linker-guard/b.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "b"] - -extern crate a; - -fn main() { - a::foo(22_u32); -} diff --git a/src/test/run-make/alloc-extern-crates/Makefile b/src/test/run-make/alloc-extern-crates/Makefile deleted file mode 100644 index 7197f4e17e3..00000000000 --- a/src/test/run-make/alloc-extern-crates/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) fakealloc.rs - $(RUSTC) --crate-type=rlib ../../../liballoc/lib.rs --cfg feature=\"external_crate\" --extern external=$(TMPDIR)/$(shell $(RUSTC) --print file-names fakealloc.rs) diff --git a/src/test/run-make/alloc-extern-crates/fakealloc.rs b/src/test/run-make/alloc-extern-crates/fakealloc.rs deleted file mode 100644 index 43f97489314..00000000000 --- a/src/test/run-make/alloc-extern-crates/fakealloc.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![no_std] - -#[inline] -pub unsafe fn allocate(_size: usize, _align: usize) -> *mut u8 { 0 as *mut u8 } - -#[inline] -pub unsafe fn deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) { } - -#[inline] -pub unsafe fn reallocate(_ptr: *mut u8, _old_size: usize, _size: usize, _align: usize) -> *mut u8 { - 0 as *mut u8 -} - -#[inline] -pub unsafe fn reallocate_inplace(_ptr: *mut u8, old_size: usize, _size: usize, - _align: usize) -> usize { old_size } - -#[inline] -pub fn usable_size(size: usize, _align: usize) -> usize { size } - -#[inline] -pub fn stats_print() { } diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile b/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile deleted file mode 100644 index c14006cc2e0..00000000000 --- a/src/test/run-make/allow-non-lint-warnings-cmdline/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Test that -A warnings makes the 'empty trait list for derive' warning go away -OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) - -all: foo - test -z '$(OUT)' - -# This is just to make sure the above command actually succeeds -foo: - $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs b/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs deleted file mode 100644 index a9e18f5a8f1..00000000000 --- a/src/test/run-make/allow-non-lint-warnings-cmdline/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive()] -#[derive(Copy, Clone)] -pub struct Foo; - -pub fn main() { } diff --git a/src/test/run-make/allow-warnings-cmdline-stability/Makefile b/src/test/run-make/allow-warnings-cmdline-stability/Makefile deleted file mode 100644 index 3eecaf93142..00000000000 --- a/src/test/run-make/allow-warnings-cmdline-stability/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# Test that -A warnings makes the 'empty trait list for derive' warning go away -DEP=$(shell $(RUSTC) bar.rs) -OUT=$(shell $(RUSTC) foo.rs -A warnings 2>&1 | grep "warning" ) - -all: foo bar - test -z '$(OUT)' - -# These are just to ensure that the above commands actually work -bar: - $(RUSTC) bar.rs - -foo: bar - $(RUSTC) foo.rs -A warnings diff --git a/src/test/run-make/allow-warnings-cmdline-stability/bar.rs b/src/test/run-make/allow-warnings-cmdline-stability/bar.rs deleted file mode 100644 index fed1405b7f4..00000000000 --- a/src/test/run-make/allow-warnings-cmdline-stability/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![feature(staged_api)] -#![unstable(feature = "test_feature", issue = "0")] - -pub fn baz() { } diff --git a/src/test/run-make/allow-warnings-cmdline-stability/foo.rs b/src/test/run-make/allow-warnings-cmdline-stability/foo.rs deleted file mode 100644 index a36cc474c2b..00000000000 --- a/src/test/run-make/allow-warnings-cmdline-stability/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(test_feature)] - -extern crate bar; - -pub fn main() { bar::baz() } diff --git a/src/test/run-make/archive-duplicate-names/Makefile b/src/test/run-make/archive-duplicate-names/Makefile deleted file mode 100644 index 93711c41d79..00000000000 --- a/src/test/run-make/archive-duplicate-names/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -all: - mkdir $(TMPDIR)/a - mkdir $(TMPDIR)/b - $(call COMPILE_OBJ,$(TMPDIR)/a/foo.o,foo.c) - $(call COMPILE_OBJ,$(TMPDIR)/b/foo.o,bar.c) - $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/a/foo.o $(TMPDIR)/b/foo.o - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(call RUN,bar) diff --git a/src/test/run-make/archive-duplicate-names/bar.c b/src/test/run-make/archive-duplicate-names/bar.c deleted file mode 100644 index a25fa10f4d3..00000000000 --- a/src/test/run-make/archive-duplicate-names/bar.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void bar() {} diff --git a/src/test/run-make/archive-duplicate-names/bar.rs b/src/test/run-make/archive-duplicate-names/bar.rs deleted file mode 100644 index 1200a6de8e2..00000000000 --- a/src/test/run-make/archive-duplicate-names/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::baz(); -} diff --git a/src/test/run-make/archive-duplicate-names/foo.c b/src/test/run-make/archive-duplicate-names/foo.c deleted file mode 100644 index 61d5d154078..00000000000 --- a/src/test/run-make/archive-duplicate-names/foo.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void foo() {} diff --git a/src/test/run-make/archive-duplicate-names/foo.rs b/src/test/run-make/archive-duplicate-names/foo.rs deleted file mode 100644 index 24b4734f2cd..00000000000 --- a/src/test/run-make/archive-duplicate-names/foo.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "foo", kind = "static")] -extern { - fn foo(); - fn bar(); -} - -pub fn baz() { - unsafe { - foo(); - bar(); - } -} diff --git a/src/test/run-make/atomic-lock-free/Makefile b/src/test/run-make/atomic-lock-free/Makefile deleted file mode 100644 index a7df821f92d..00000000000 --- a/src/test/run-make/atomic-lock-free/Makefile +++ /dev/null @@ -1,46 +0,0 @@ --include ../tools.mk - -# This tests ensure that atomic types are never lowered into runtime library calls that are not -# guaranteed to be lock-free. - -all: -ifeq ($(UNAME),Linux) -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) - $(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) - $(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter aarch64,$(LLVM_COMPONENTS)),aarch64) - $(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) - $(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter powerpc,$(LLVM_COMPONENTS)),powerpc) - $(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc-unknown-linux-gnuspe atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add - $(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) - $(RUSTC) --target=s390x-unknown-linux-gnu atomic_lock_free.rs - nm "$(TMPDIR)/libatomic_lock_free.rlib" | $(CGREP) -v __atomic_fetch_add -endif -endif diff --git a/src/test/run-make/atomic-lock-free/atomic_lock_free.rs b/src/test/run-make/atomic-lock-free/atomic_lock_free.rs deleted file mode 100644 index b41e8e9226b..00000000000 --- a/src/test/run-make/atomic-lock-free/atomic_lock_free.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(cfg_target_has_atomic, no_core, intrinsics, lang_items)] -#![crate_type="rlib"] -#![no_core] - -extern "rust-intrinsic" { - fn atomic_xadd(dst: *mut T, src: T) -> T; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} -#[lang = "freeze"] -trait Freeze {} - -#[cfg(target_has_atomic = "8")] -pub unsafe fn atomic_u8(x: *mut u8) { - atomic_xadd(x, 1); - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "8")] -pub unsafe fn atomic_i8(x: *mut i8) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "16")] -pub unsafe fn atomic_u16(x: *mut u16) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "16")] -pub unsafe fn atomic_i16(x: *mut i16) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "32")] -pub unsafe fn atomic_u32(x: *mut u32) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "32")] -pub unsafe fn atomic_i32(x: *mut i32) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "64")] -pub unsafe fn atomic_u64(x: *mut u64) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "64")] -pub unsafe fn atomic_i64(x: *mut i64) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "ptr")] -pub unsafe fn atomic_usize(x: *mut usize) { - atomic_xadd(x, 1); -} -#[cfg(target_has_atomic = "ptr")] -pub unsafe fn atomic_isize(x: *mut isize) { - atomic_xadd(x, 1); -} diff --git a/src/test/run-make/bare-outfile/Makefile b/src/test/run-make/bare-outfile/Makefile deleted file mode 100644 index baa4c1c0237..00000000000 --- a/src/test/run-make/bare-outfile/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR) - cd $(TMPDIR) && $(RUSTC) -o foo foo.rs - $(call RUN,foo) diff --git a/src/test/run-make/bare-outfile/foo.rs b/src/test/run-make/bare-outfile/foo.rs deleted file mode 100644 index 63e747901ae..00000000000 --- a/src/test/run-make/bare-outfile/foo.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { -} diff --git a/src/test/run-make/c-dynamic-dylib/Makefile b/src/test/run-make/c-dynamic-dylib/Makefile deleted file mode 100644 index 83bddd4c73c..00000000000 --- a/src/test/run-make/c-dynamic-dylib/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# This hits an assertion in the linker on older versions of osx apparently -ifeq ($(shell uname),Darwin) -all: - echo ignored -else -all: $(call DYLIB,cfoo) - $(RUSTC) foo.rs -C prefer-dynamic - $(RUSTC) bar.rs - $(call RUN,bar) - $(call REMOVE_DYLIBS,cfoo) - $(call FAIL,bar) -endif diff --git a/src/test/run-make/c-dynamic-dylib/bar.rs b/src/test/run-make/c-dynamic-dylib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-dynamic-dylib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-dynamic-dylib/cfoo.c b/src/test/run-make/c-dynamic-dylib/cfoo.c deleted file mode 100644 index a9755493541..00000000000 --- a/src/test/run-make/c-dynamic-dylib/cfoo.c +++ /dev/null @@ -1,5 +0,0 @@ -// ignore-license -#ifdef _WIN32 -__declspec(dllexport) -#endif -int foo() { return 0; } diff --git a/src/test/run-make/c-dynamic-dylib/foo.rs b/src/test/run-make/c-dynamic-dylib/foo.rs deleted file mode 100644 index 04253be71d4..00000000000 --- a/src/test/run-make/c-dynamic-dylib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[link(name = "cfoo")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/c-dynamic-rlib/Makefile b/src/test/run-make/c-dynamic-rlib/Makefile deleted file mode 100644 index e15cfd34d6c..00000000000 --- a/src/test/run-make/c-dynamic-rlib/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -# This overrides the LD_LIBRARY_PATH for RUN -TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) - -# This hits an assertion in the linker on older versions of osx apparently -ifeq ($(shell uname),Darwin) -all: - echo ignored -else -all: $(call DYLIB,cfoo) - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(call RUN,bar) - $(call REMOVE_DYLIBS,cfoo) - $(call FAIL,bar) -endif diff --git a/src/test/run-make/c-dynamic-rlib/bar.rs b/src/test/run-make/c-dynamic-rlib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-dynamic-rlib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-dynamic-rlib/cfoo.c b/src/test/run-make/c-dynamic-rlib/cfoo.c deleted file mode 100644 index b2849326a75..00000000000 --- a/src/test/run-make/c-dynamic-rlib/cfoo.c +++ /dev/null @@ -1,6 +0,0 @@ -// ignore-license - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int foo() { return 0; } diff --git a/src/test/run-make/c-dynamic-rlib/foo.rs b/src/test/run-make/c-dynamic-rlib/foo.rs deleted file mode 100644 index a1f01bd2b62..00000000000 --- a/src/test/run-make/c-dynamic-rlib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "cfoo")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/c-link-to-rust-dylib/Makefile b/src/test/run-make/c-link-to-rust-dylib/Makefile deleted file mode 100644 index 98e112a3744..00000000000 --- a/src/test/run-make/c-link-to-rust-dylib/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -all: $(TMPDIR)/$(call BIN,bar) - $(call RUN,bar) - $(call REMOVE_DYLIBS,foo) - $(call FAIL,bar) - -ifdef IS_MSVC -$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) - $(CC) bar.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,bar) -else -$(TMPDIR)/$(call BIN,bar): $(call DYLIB,foo) - $(CC) bar.c -lfoo -o $(call RUN_BINFILE,bar) -L $(TMPDIR) -endif - -$(call DYLIB,foo): foo.rs - $(RUSTC) foo.rs diff --git a/src/test/run-make/c-link-to-rust-dylib/bar.c b/src/test/run-make/c-link-to-rust-dylib/bar.c deleted file mode 100644 index 5729d411c5b..00000000000 --- a/src/test/run-make/c-link-to-rust-dylib/bar.c +++ /dev/null @@ -1,7 +0,0 @@ -// ignore-license -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/c-link-to-rust-dylib/foo.rs b/src/test/run-make/c-link-to-rust-dylib/foo.rs deleted file mode 100644 index 32675bcba1e..00000000000 --- a/src/test/run-make/c-link-to-rust-dylib/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[no_mangle] -pub extern "C" fn foo() {} diff --git a/src/test/run-make/c-link-to-rust-staticlib/Makefile b/src/test/run-make/c-link-to-rust-staticlib/Makefile deleted file mode 100644 index 47264e82165..00000000000 --- a/src/test/run-make/c-link-to-rust-staticlib/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd -ifneq ($(shell uname),FreeBSD) -all: - $(RUSTC) foo.rs - $(CC) bar.c $(call STATICLIB,foo) $(call OUT_EXE,bar) \ - $(EXTRACFLAGS) $(EXTRACXXFLAGS) - $(call RUN,bar) - rm $(call STATICLIB,foo) - $(call RUN,bar) - -else -all: - -endif diff --git a/src/test/run-make/c-link-to-rust-staticlib/bar.c b/src/test/run-make/c-link-to-rust-staticlib/bar.c deleted file mode 100644 index 5729d411c5b..00000000000 --- a/src/test/run-make/c-link-to-rust-staticlib/bar.c +++ /dev/null @@ -1,7 +0,0 @@ -// ignore-license -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/c-link-to-rust-staticlib/foo.rs b/src/test/run-make/c-link-to-rust-staticlib/foo.rs deleted file mode 100644 index 1bb19016700..00000000000 --- a/src/test/run-make/c-link-to-rust-staticlib/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -#[no_mangle] -pub extern "C" fn foo() {} diff --git a/src/test/run-make/c-static-dylib/Makefile b/src/test/run-make/c-static-dylib/Makefile deleted file mode 100644 index f88786857cc..00000000000 --- a/src/test/run-make/c-static-dylib/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,cfoo) - $(RUSTC) foo.rs -C prefer-dynamic - $(RUSTC) bar.rs - rm $(call NATIVE_STATICLIB,cfoo) - $(call RUN,bar) - $(call REMOVE_DYLIBS,foo) - $(call FAIL,bar) diff --git a/src/test/run-make/c-static-dylib/bar.rs b/src/test/run-make/c-static-dylib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-static-dylib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-static-dylib/cfoo.c b/src/test/run-make/c-static-dylib/cfoo.c deleted file mode 100644 index 113717a776a..00000000000 --- a/src/test/run-make/c-static-dylib/cfoo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int foo() { return 0; } diff --git a/src/test/run-make/c-static-dylib/foo.rs b/src/test/run-make/c-static-dylib/foo.rs deleted file mode 100644 index 44be5ac890d..00000000000 --- a/src/test/run-make/c-static-dylib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[link(name = "cfoo", kind = "static")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/c-static-rlib/Makefile b/src/test/run-make/c-static-rlib/Makefile deleted file mode 100644 index be22b2728f0..00000000000 --- a/src/test/run-make/c-static-rlib/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,cfoo) - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(call REMOVE_RLIBS,foo) - rm $(call NATIVE_STATICLIB,cfoo) - $(call RUN,bar) diff --git a/src/test/run-make/c-static-rlib/bar.rs b/src/test/run-make/c-static-rlib/bar.rs deleted file mode 100644 index 37b120decd1..00000000000 --- a/src/test/run-make/c-static-rlib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::rsfoo(); -} diff --git a/src/test/run-make/c-static-rlib/cfoo.c b/src/test/run-make/c-static-rlib/cfoo.c deleted file mode 100644 index 113717a776a..00000000000 --- a/src/test/run-make/c-static-rlib/cfoo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int foo() { return 0; } diff --git a/src/test/run-make/c-static-rlib/foo.rs b/src/test/run-make/c-static-rlib/foo.rs deleted file mode 100644 index cbd7b020bd8..00000000000 --- a/src/test/run-make/c-static-rlib/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "cfoo", kind = "static")] -extern { - fn foo(); -} - -pub fn rsfoo() { - unsafe { foo() } -} diff --git a/src/test/run-make/cat-and-grep-sanity-check/Makefile b/src/test/run-make/cat-and-grep-sanity-check/Makefile deleted file mode 100644 index fead197ce39..00000000000 --- a/src/test/run-make/cat-and-grep-sanity-check/Makefile +++ /dev/null @@ -1,46 +0,0 @@ --include ../tools.mk - -all: - echo a | $(CGREP) a - ! echo b | $(CGREP) a - echo xyz | $(CGREP) x y z - ! echo abc | $(CGREP) b c d - printf "x\ny\nz" | $(CGREP) x y z - - echo AbCd | $(CGREP) -i a b C D - ! echo AbCd | $(CGREP) a b C D - - true | $(CGREP) -v nothing - ! echo nothing | $(CGREP) -v nothing - ! echo xyz | $(CGREP) -v w x y - ! echo xyz | $(CGREP) -v x y z - echo xyz | $(CGREP) -v a b c - - ! echo 'foo bar baz' | $(CGREP) 'foo baz' - echo 'foo bar baz' | $(CGREP) foo baz - echo 'x a `b` c y z' | $(CGREP) 'a `b` c' - - echo baaac | $(CGREP) -e 'ba*c' - echo bc | $(CGREP) -e 'ba*c' - ! echo aaac | $(CGREP) -e 'ba*c' - - echo aaa | $(CGREP) -e 'a+' - ! echo bbb | $(CGREP) -e 'a+' - - echo abc | $(CGREP) -e 'a|e|i|o|u' - ! echo fgh | $(CGREP) -e 'a|e|i|o|u' - echo abc | $(CGREP) -e '[aeiou]' - ! echo fgh | $(CGREP) -e '[aeiou]' - ! echo abc | $(CGREP) -e '[^aeiou]{3}' - echo fgh | $(CGREP) -e '[^aeiou]{3}' - echo ab cd ef gh | $(CGREP) -e '\bcd\b' - ! echo abcdefgh | $(CGREP) -e '\bcd\b' - echo xyz | $(CGREP) -e '...' - ! echo xy | $(CGREP) -e '...' - ! echo xyz | $(CGREP) -e '\.\.\.' - echo ... | $(CGREP) -e '\.\.\.' - - echo foo bar baz | $(CGREP) -e 'foo.*baz' - ! echo foo bar baz | $(CGREP) -ve 'foo.*baz' - ! echo foo bar baz | $(CGREP) -e 'baz.*foo' - echo foo bar baz | $(CGREP) -ve 'baz.*foo' diff --git a/src/test/run-make/cdylib-fewer-symbols/Makefile b/src/test/run-make/cdylib-fewer-symbols/Makefile deleted file mode 100644 index 1a0664dfafd..00000000000 --- a/src/test/run-make/cdylib-fewer-symbols/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# Test that allocator-related symbols don't show up as exported from a cdylib as -# they're internal to Rust and not part of the public ABI. - --include ../tools.mk - -# FIXME: The __rdl_ and __rust_ symbol still remains, no matter using MSVC or GNU -# See https://github.com/rust-lang/rust/pull/46207#issuecomment-347561753 -ifdef IS_WINDOWS -all: - true -else -all: - $(RUSTC) foo.rs - nm -g "$(call DYLIB,foo)" | $(CGREP) -v __rdl_ __rde_ __rg_ __rust_ -endif diff --git a/src/test/run-make/cdylib-fewer-symbols/foo.rs b/src/test/run-make/cdylib-fewer-symbols/foo.rs deleted file mode 100644 index 4ec8d4ee860..00000000000 --- a/src/test/run-make/cdylib-fewer-symbols/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "cdylib"] - -#[no_mangle] -pub extern fn foo() -> u32 { - 3 -} diff --git a/src/test/run-make/cdylib/Makefile b/src/test/run-make/cdylib/Makefile deleted file mode 100644 index 47ec762b3e9..00000000000 --- a/src/test/run-make/cdylib/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -include ../tools.mk - -all: $(call RUN_BINFILE,foo) - $(call RUN,foo) - rm $(call DYLIB,foo) - $(RUSTC) foo.rs -C lto - $(call RUN,foo) - -ifdef IS_MSVC -$(call RUN_BINFILE,foo): $(call DYLIB,foo) - $(CC) $(CFLAGS) foo.c $(TMPDIR)/foo.dll.lib $(call OUT_EXE,foo) -else -$(call RUN_BINFILE,foo): $(call DYLIB,foo) - $(CC) $(CFLAGS) foo.c -lfoo -o $(call RUN_BINFILE,foo) -L $(TMPDIR) -endif - -$(call DYLIB,foo): - $(RUSTC) bar.rs - $(RUSTC) foo.rs diff --git a/src/test/run-make/cdylib/bar.rs b/src/test/run-make/cdylib/bar.rs deleted file mode 100644 index 2c97298604c..00000000000 --- a/src/test/run-make/cdylib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub fn bar() { - println!("hello!"); -} diff --git a/src/test/run-make/cdylib/foo.c b/src/test/run-make/cdylib/foo.c deleted file mode 100644 index 1c950427c65..00000000000 --- a/src/test/run-make/cdylib/foo.c +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include - -extern void foo(); -extern unsigned bar(unsigned a, unsigned b); - -int main() { - foo(); - assert(bar(1, 2) == 3); - return 0; -} diff --git a/src/test/run-make/cdylib/foo.rs b/src/test/run-make/cdylib/foo.rs deleted file mode 100644 index cdac6d19035..00000000000 --- a/src/test/run-make/cdylib/foo.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "cdylib"] - -extern crate bar; - -#[no_mangle] -pub extern fn foo() { - bar::bar(); -} - -#[no_mangle] -pub extern fn bar(a: u32, b: u32) -> u32 { - a + b -} diff --git a/src/test/run-make/codegen-options-parsing/Makefile b/src/test/run-make/codegen-options-parsing/Makefile deleted file mode 100644 index fda96a8b1fb..00000000000 --- a/src/test/run-make/codegen-options-parsing/Makefile +++ /dev/null @@ -1,31 +0,0 @@ --include ../tools.mk - -all: - #Option taking a number - $(RUSTC) -C codegen-units dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `codegen-units` requires a number' - $(RUSTC) -C codegen-units= dummy.rs 2>&1 | \ - $(CGREP) 'incorrect value `` for codegen option `codegen-units` - a number was expected' - $(RUSTC) -C codegen-units=foo dummy.rs 2>&1 | \ - $(CGREP) 'incorrect value `foo` for codegen option `codegen-units` - a number was expected' - $(RUSTC) -C codegen-units=1 dummy.rs - #Option taking a string - $(RUSTC) -C extra-filename dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `extra-filename` requires a string' - $(RUSTC) -C extra-filename= dummy.rs 2>&1 - $(RUSTC) -C extra-filename=foo dummy.rs 2>&1 - #Option taking no argument - $(RUSTC) -C lto= dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' - $(RUSTC) -C lto=1 dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' - $(RUSTC) -C lto=foo dummy.rs 2>&1 | \ - $(CGREP) 'codegen option `lto` - one of `thin`, `fat`, or' - $(RUSTC) -C lto dummy.rs - - # Should not link dead code... - $(RUSTC) -Z print-link-args dummy.rs 2>&1 | \ - $(CGREP) -e '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' - # ... unless you specifically ask to keep it - $(RUSTC) -Z print-link-args -C link-dead-code dummy.rs 2>&1 | \ - $(CGREP) -ve '--gc-sections|-z[^ ]* [^ ]*|-dead_strip|/OPT:REF' diff --git a/src/test/run-make/codegen-options-parsing/dummy.rs b/src/test/run-make/codegen-options-parsing/dummy.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/codegen-options-parsing/dummy.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/compile-stdin/Makefile b/src/test/run-make/compile-stdin/Makefile deleted file mode 100644 index 1442224cf9a..00000000000 --- a/src/test/run-make/compile-stdin/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - echo 'fn main(){}' | $(RUSTC) - - $(call RUN,rust_out) diff --git a/src/test/run-make/compiler-lookup-paths-2/Makefile b/src/test/run-make/compiler-lookup-paths-2/Makefile deleted file mode 100644 index bd7f62d5c2d..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - mkdir -p $(TMPDIR)/a $(TMPDIR)/b - $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a - $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b - $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \ - && exit 1 || exit 0 diff --git a/src/test/run-make/compiler-lookup-paths-2/a.rs b/src/test/run-make/compiler-lookup-paths-2/a.rs deleted file mode 100644 index e7572a5f615..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/a.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/compiler-lookup-paths-2/b.rs b/src/test/run-make/compiler-lookup-paths-2/b.rs deleted file mode 100644 index fee0da9b4c1..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate a; diff --git a/src/test/run-make/compiler-lookup-paths-2/c.rs b/src/test/run-make/compiler-lookup-paths-2/c.rs deleted file mode 100644 index 66fe51d1099..00000000000 --- a/src/test/run-make/compiler-lookup-paths-2/c.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate b; -extern crate a; diff --git a/src/test/run-make/compiler-lookup-paths/Makefile b/src/test/run-make/compiler-lookup-paths/Makefile deleted file mode 100644 index e22b937a087..00000000000 --- a/src/test/run-make/compiler-lookup-paths/Makefile +++ /dev/null @@ -1,38 +0,0 @@ --include ../tools.mk - -all: $(TMPDIR)/libnative.a - mkdir -p $(TMPDIR)/crate - mkdir -p $(TMPDIR)/native - mv $(TMPDIR)/libnative.a $(TMPDIR)/native - $(RUSTC) a.rs - mv $(TMPDIR)/liba.rlib $(TMPDIR)/crate - $(RUSTC) b.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) b.rs -L dependency=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) b.rs -L crate=$(TMPDIR)/crate - $(RUSTC) b.rs -L all=$(TMPDIR)/crate - $(RUSTC) c.rs -L native=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) c.rs -L crate=$(TMPDIR)/crate && exit 1 || exit 0 - $(RUSTC) c.rs -L dependency=$(TMPDIR)/crate - $(RUSTC) c.rs -L all=$(TMPDIR)/crate - $(RUSTC) d.rs -L dependency=$(TMPDIR)/native && exit 1 || exit 0 - $(RUSTC) d.rs -L crate=$(TMPDIR)/native && exit 1 || exit 0 - $(RUSTC) d.rs -L native=$(TMPDIR)/native - $(RUSTC) d.rs -L all=$(TMPDIR)/native - # Deduplication tests: - # Same hash, no errors. - mkdir -p $(TMPDIR)/e1 - mkdir -p $(TMPDIR)/e2 - $(RUSTC) e.rs -o $(TMPDIR)/e1/libe.rlib - $(RUSTC) e.rs -o $(TMPDIR)/e2/libe.rlib - $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 - # Different hash, errors. - $(RUSTC) e2.rs -o $(TMPDIR)/e2/libe.rlib - $(RUSTC) f.rs -L $(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L $(TMPDIR)/e2 && exit 1 || exit 0 - $(RUSTC) f.rs -L crate=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 && exit 1 || exit 0 - # Native/dependency paths don't cause errors. - $(RUSTC) f.rs -L native=$(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L $(TMPDIR)/e2 - $(RUSTC) f.rs -L dependency=$(TMPDIR)/e1 -L crate=$(TMPDIR)/e2 diff --git a/src/test/run-make/compiler-lookup-paths/a.rs b/src/test/run-make/compiler-lookup-paths/a.rs deleted file mode 100644 index 4ddf231fba2..00000000000 --- a/src/test/run-make/compiler-lookup-paths/a.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/compiler-lookup-paths/b.rs b/src/test/run-make/compiler-lookup-paths/b.rs deleted file mode 100644 index c38300f976e..00000000000 --- a/src/test/run-make/compiler-lookup-paths/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate a; diff --git a/src/test/run-make/compiler-lookup-paths/c.rs b/src/test/run-make/compiler-lookup-paths/c.rs deleted file mode 100644 index b5c54558a4f..00000000000 --- a/src/test/run-make/compiler-lookup-paths/c.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate b; diff --git a/src/test/run-make/compiler-lookup-paths/d.rs b/src/test/run-make/compiler-lookup-paths/d.rs deleted file mode 100644 index 295b6e00e41..00000000000 --- a/src/test/run-make/compiler-lookup-paths/d.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "native", kind = "static")] -extern {} diff --git a/src/test/run-make/compiler-lookup-paths/e.rs b/src/test/run-make/compiler-lookup-paths/e.rs deleted file mode 100644 index c0407aba7c9..00000000000 --- a/src/test/run-make/compiler-lookup-paths/e.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "e"] -#![crate_type = "rlib"] diff --git a/src/test/run-make/compiler-lookup-paths/e2.rs b/src/test/run-make/compiler-lookup-paths/e2.rs deleted file mode 100644 index f8c8c029c0b..00000000000 --- a/src/test/run-make/compiler-lookup-paths/e2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "e"] -#![crate_type = "rlib"] - -pub fn f() {} diff --git a/src/test/run-make/compiler-lookup-paths/f.rs b/src/test/run-make/compiler-lookup-paths/f.rs deleted file mode 100644 index e6160422576..00000000000 --- a/src/test/run-make/compiler-lookup-paths/f.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -extern crate e; diff --git a/src/test/run-make/compiler-lookup-paths/native.c b/src/test/run-make/compiler-lookup-paths/native.c deleted file mode 100644 index 30669470522..00000000000 --- a/src/test/run-make/compiler-lookup-paths/native.c +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/compiler-rt-works-on-mingw/Makefile b/src/test/run-make/compiler-rt-works-on-mingw/Makefile deleted file mode 100644 index 06d1bb6698e..00000000000 --- a/src/test/run-make/compiler-rt-works-on-mingw/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -ifneq (,$(findstring MINGW,$(UNAME))) -ifndef IS_MSVC -all: - $(CXX) foo.cpp -c -o $(TMPDIR)/foo.o - $(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o - $(RUSTC) foo.rs -lfoo -lstdc++ - $(call RUN,foo) -else -all: - -endif -else -all: - -endif diff --git a/src/test/run-make/compiler-rt-works-on-mingw/foo.cpp b/src/test/run-make/compiler-rt-works-on-mingw/foo.cpp deleted file mode 100644 index aac3ba42201..00000000000 --- a/src/test/run-make/compiler-rt-works-on-mingw/foo.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// ignore-license -extern "C" void foo() { - int *a = new int(3); - delete a; -} diff --git a/src/test/run-make/compiler-rt-works-on-mingw/foo.rs b/src/test/run-make/compiler-rt-works-on-mingw/foo.rs deleted file mode 100644 index 293f9d58294..00000000000 --- a/src/test/run-make/compiler-rt-works-on-mingw/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { fn foo(); } - -pub fn main() { - unsafe { foo(); } - assert_eq!(7f32.powi(3), 343f32); -} diff --git a/src/test/run-make/crate-data-smoke/Makefile b/src/test/run-make/crate-data-smoke/Makefile deleted file mode 100644 index 1afda457411..00000000000 --- a/src/test/run-make/crate-data-smoke/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - [ `$(RUSTC) --print crate-name crate.rs` = "foo" ] - [ `$(RUSTC) --print file-names crate.rs` = "$(call BIN,foo)" ] - [ `$(RUSTC) --print file-names --crate-type=lib \ - --test crate.rs` = "$(call BIN,foo)" ] - [ `$(RUSTC) --print file-names --test lib.rs` = "$(call BIN,mylib)" ] - $(RUSTC) --print file-names lib.rs - $(RUSTC) --print file-names rlib.rs diff --git a/src/test/run-make/crate-data-smoke/crate.rs b/src/test/run-make/crate-data-smoke/crate.rs deleted file mode 100644 index 305b3dc70a6..00000000000 --- a/src/test/run-make/crate-data-smoke/crate.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -// Querying about the crate metadata should *not* parse the entire crate, it -// only needs the crate attributes (which are guaranteed to be at the top) be -// sure that if we have an error like a missing module that we can still query -// about the crate id. -mod error; diff --git a/src/test/run-make/crate-data-smoke/lib.rs b/src/test/run-make/crate-data-smoke/lib.rs deleted file mode 100644 index 639a5d0387b..00000000000 --- a/src/test/run-make/crate-data-smoke/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "mylib"] -#![crate_type = "lib"] diff --git a/src/test/run-make/crate-data-smoke/rlib.rs b/src/test/run-make/crate-data-smoke/rlib.rs deleted file mode 100644 index 4e093748600..00000000000 --- a/src/test/run-make/crate-data-smoke/rlib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "mylib"] -#![crate_type = "rlib"] diff --git a/src/test/run-make/crate-name-priority/Makefile b/src/test/run-make/crate-name-priority/Makefile deleted file mode 100644 index 17ecb33ab28..00000000000 --- a/src/test/run-make/crate-name-priority/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-name bar - rm $(TMPDIR)/$(call BIN,bar) - $(RUSTC) foo1.rs - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo1.rs -o $(TMPDIR)/$(call BIN,bar1) - rm $(TMPDIR)/$(call BIN,bar1) diff --git a/src/test/run-make/crate-name-priority/foo.rs b/src/test/run-make/crate-name-priority/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/crate-name-priority/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/crate-name-priority/foo1.rs b/src/test/run-make/crate-name-priority/foo1.rs deleted file mode 100644 index a397d6bc749..00000000000 --- a/src/test/run-make/crate-name-priority/foo1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -fn main() {} diff --git a/src/test/run-make/debug-assertions/Makefile b/src/test/run-make/debug-assertions/Makefile deleted file mode 100644 index 76ada90f1e2..00000000000 --- a/src/test/run-make/debug-assertions/Makefile +++ /dev/null @@ -1,25 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) debug.rs -C debug-assertions=no - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=0 - $(call RUN,debug) bad - $(RUSTC) debug.rs -C opt-level=1 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=2 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=3 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=s - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=z - $(call RUN,debug) good - $(RUSTC) debug.rs -O - $(call RUN,debug) good - $(RUSTC) debug.rs - $(call RUN,debug) bad - $(RUSTC) debug.rs -C debug-assertions=yes -O - $(call RUN,debug) bad - $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1 - $(call RUN,debug) bad diff --git a/src/test/run-make/debug-assertions/debug.rs b/src/test/run-make/debug-assertions/debug.rs deleted file mode 100644 index 65682cb86c3..00000000000 --- a/src/test/run-make/debug-assertions/debug.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![deny(warnings)] - -use std::env; -use std::thread; - -fn main() { - let should_fail = env::args().nth(1) == Some("bad".to_string()); - - assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail); - assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail); - assert_eq!(thread::spawn(overflow).join().is_err(), should_fail); -} - -fn debug_assert_eq() { - let mut hit1 = false; - let mut hit2 = false; - debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 }); - assert!(!hit1); - assert!(!hit2); -} - -fn debug_assert() { - let mut hit = false; - debug_assert!({ hit = true; false }); - assert!(!hit); -} - -fn overflow() { - fn add(a: u8, b: u8) -> u8 { a + b } - - add(200u8, 200u8); -} diff --git a/src/test/run-make/dep-info-doesnt-run-much/Makefile b/src/test/run-make/dep-info-doesnt-run-much/Makefile deleted file mode 100644 index 2fd84639f21..00000000000 --- a/src/test/run-make/dep-info-doesnt-run-much/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --emit dep-info diff --git a/src/test/run-make/dep-info-doesnt-run-much/foo.rs b/src/test/run-make/dep-info-doesnt-run-much/foo.rs deleted file mode 100644 index 35911821044..00000000000 --- a/src/test/run-make/dep-info-doesnt-run-much/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// We're only emitting dep info, so we shouldn't be running static analysis to -// figure out that this program is erroneous. -fn main() { - let a: u8 = "a"; -} diff --git a/src/test/run-make/dep-info-spaces/Makefile b/src/test/run-make/dep-info-spaces/Makefile deleted file mode 100644 index 82686ffdd9d..00000000000 --- a/src/test/run-make/dep-info-spaces/Makefile +++ /dev/null @@ -1,28 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd/windows -# (windows: see `../dep-info/Makefile`) -ifneq ($(shell uname),FreeBSD) -ifndef IS_WINDOWS -all: - cp lib.rs $(TMPDIR)/ - cp 'foo foo.rs' $(TMPDIR)/ - cp bar.rs $(TMPDIR)/ - $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs - sleep 1 - touch $(TMPDIR)/'foo foo.rs' - -rm -f $(TMPDIR)/done - $(MAKE) -drf Makefile.foo - rm $(TMPDIR)/done - pwd - $(MAKE) -drf Makefile.foo - rm $(TMPDIR)/done && exit 1 || exit 0 -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/dep-info-spaces/Makefile.foo b/src/test/run-make/dep-info-spaces/Makefile.foo deleted file mode 100644 index 80a5d4333cd..00000000000 --- a/src/test/run-make/dep-info-spaces/Makefile.foo +++ /dev/null @@ -1,7 +0,0 @@ -LIB := $(shell $(RUSTC) --print file-names --crate-type=lib $(TMPDIR)/lib.rs) - -$(TMPDIR)/$(LIB): - $(RUSTC) --emit link,dep-info --crate-type=lib $(TMPDIR)/lib.rs - touch $(TMPDIR)/done - --include $(TMPDIR)/lib.d diff --git a/src/test/run-make/dep-info-spaces/bar.rs b/src/test/run-make/dep-info-spaces/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/dep-info-spaces/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/dep-info-spaces/foo foo.rs b/src/test/run-make/dep-info-spaces/foo foo.rs deleted file mode 100644 index 2661b1f4eb4..00000000000 --- a/src/test/run-make/dep-info-spaces/foo foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/run-make/dep-info-spaces/lib.rs b/src/test/run-make/dep-info-spaces/lib.rs deleted file mode 100644 index bfbe41baeac..00000000000 --- a/src/test/run-make/dep-info-spaces/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[path="foo foo.rs"] -pub mod foo; - -pub mod bar; diff --git a/src/test/run-make/dep-info/Makefile b/src/test/run-make/dep-info/Makefile deleted file mode 100644 index 9b79d1af521..00000000000 --- a/src/test/run-make/dep-info/Makefile +++ /dev/null @@ -1,34 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd/windows -# on windows `rustc --dep-info` produces Makefile dependency with -# windows native paths (e.g. `c:\path\to\libfoo.a`) -# but msys make seems to fail to recognize such paths, so test fails. -ifneq ($(shell uname),FreeBSD) -ifndef IS_WINDOWS -all: - cp *.rs $(TMPDIR) - $(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs - sleep 2 - touch $(TMPDIR)/foo.rs - -rm -f $(TMPDIR)/done - $(MAKE) -drf Makefile.foo - sleep 2 - rm $(TMPDIR)/done - pwd - $(MAKE) -drf Makefile.foo - rm $(TMPDIR)/done && exit 1 || exit 0 - - # When a source file is deleted `make` should still work - rm $(TMPDIR)/bar.rs - cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs - $(MAKE) -drf Makefile.foo -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/dep-info/Makefile.foo b/src/test/run-make/dep-info/Makefile.foo deleted file mode 100644 index e5df31f88c1..00000000000 --- a/src/test/run-make/dep-info/Makefile.foo +++ /dev/null @@ -1,7 +0,0 @@ -LIB := $(shell $(RUSTC) --print file-names --crate-type=lib lib.rs) - -$(TMPDIR)/$(LIB): - $(RUSTC) --emit dep-info,link --crate-type=lib lib.rs - touch $(TMPDIR)/done - --include $(TMPDIR)/foo.d diff --git a/src/test/run-make/dep-info/bar.rs b/src/test/run-make/dep-info/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/dep-info/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/dep-info/foo.rs b/src/test/run-make/dep-info/foo.rs deleted file mode 100644 index 2661b1f4eb4..00000000000 --- a/src/test/run-make/dep-info/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/run-make/dep-info/lib.rs b/src/test/run-make/dep-info/lib.rs deleted file mode 100644 index 7c15785bbb2..00000000000 --- a/src/test/run-make/dep-info/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -pub mod foo; -pub mod bar; diff --git a/src/test/run-make/dep-info/lib2.rs b/src/test/run-make/dep-info/lib2.rs deleted file mode 100644 index 1b70fb4eb4b..00000000000 --- a/src/test/run-make/dep-info/lib2.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] - -pub mod foo; diff --git a/src/test/run-make/duplicate-output-flavors/Makefile b/src/test/run-make/duplicate-output-flavors/Makefile deleted file mode 100644 index e33279966c9..00000000000 --- a/src/test/run-make/duplicate-output-flavors/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib,rlib foo.rs diff --git a/src/test/run-make/duplicate-output-flavors/foo.rs b/src/test/run-make/duplicate-output-flavors/foo.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/duplicate-output-flavors/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/dylib-chain/Makefile b/src/test/run-make/dylib-chain/Makefile deleted file mode 100644 index a33177197b1..00000000000 --- a/src/test/run-make/dylib-chain/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) m1.rs -C prefer-dynamic - $(RUSTC) m2.rs -C prefer-dynamic - $(RUSTC) m3.rs -C prefer-dynamic - $(RUSTC) m4.rs - $(call RUN,m4) - $(call REMOVE_DYLIBS,m1) - $(call REMOVE_DYLIBS,m2) - $(call REMOVE_DYLIBS,m3) - $(call FAIL,m4) diff --git a/src/test/run-make/dylib-chain/m1.rs b/src/test/run-make/dylib-chain/m1.rs deleted file mode 100644 index 5437c935c4e..00000000000 --- a/src/test/run-make/dylib-chain/m1.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -pub fn m1() {} diff --git a/src/test/run-make/dylib-chain/m2.rs b/src/test/run-make/dylib-chain/m2.rs deleted file mode 100644 index b464f32eae2..00000000000 --- a/src/test/run-make/dylib-chain/m2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate m1; - -pub fn m2() { m1::m1() } diff --git a/src/test/run-make/dylib-chain/m3.rs b/src/test/run-make/dylib-chain/m3.rs deleted file mode 100644 index bf431cc827b..00000000000 --- a/src/test/run-make/dylib-chain/m3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate m2; - -pub fn m3() { m2::m2() } diff --git a/src/test/run-make/dylib-chain/m4.rs b/src/test/run-make/dylib-chain/m4.rs deleted file mode 100644 index 6c2a6685802..00000000000 --- a/src/test/run-make/dylib-chain/m4.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate m3; - -fn main() { m3::m3() } diff --git a/src/test/run-make/emit/Makefile b/src/test/run-make/emit/Makefile deleted file mode 100644 index e0b57107e5b..00000000000 --- a/src/test/run-make/emit/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-24876.rs - $(RUSTC) -Copt-level=0 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=1 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=2 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=3 --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=s --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 - $(RUSTC) -Copt-level=z --emit=llvm-bc,llvm-ir,asm,obj,link test-26235.rs - $(call RUN,test-26235) || exit 1 diff --git a/src/test/run-make/emit/test-24876.rs b/src/test/run-make/emit/test-24876.rs deleted file mode 100644 index ab69decbf00..00000000000 --- a/src/test/run-make/emit/test-24876.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks for issue #24876 - -fn main() { - let mut v = 0; - for i in 0..0 { - v += i; - } - println!("{}", v) -} diff --git a/src/test/run-make/emit/test-26235.rs b/src/test/run-make/emit/test-26235.rs deleted file mode 100644 index 97b58a3671b..00000000000 --- a/src/test/run-make/emit/test-26235.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Checks for issue #26235 - -fn main() { - use std::thread; - - type Key = u32; - const NUM_THREADS: usize = 2; - - #[derive(Clone,Copy)] - struct Stats { - upsert: S, - delete: S, - insert: S, - update: S - }; - - impl Stats where S: Copy { - fn dot(self, s: Stats, f: F) -> Stats where F: Fn(S, T) -> B { - let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self; - 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) } - } - - fn new(init: S) -> Self { - Stats { upsert: init, delete: init, insert: init, update: init } - } - } - - fn make_threads() -> Vec> { - let mut t = Vec::with_capacity(NUM_THREADS); - for _ in 0..NUM_THREADS { - t.push(thread::spawn(move || {})); - } - t - } - - let stats = [Stats::new(0); NUM_THREADS]; - make_threads(); - - { - let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold( - Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y))); - println!("upserts: {}, deletes: {}, inserts: {}, updates: {}", - upsert, delete, insert, update); - } -} diff --git a/src/test/run-make/error-found-staticlib-instead-crate/Makefile b/src/test/run-make/error-found-staticlib-instead-crate/Makefile deleted file mode 100644 index fef12c4da67..00000000000 --- a/src/test/run-make/error-found-staticlib-instead-crate/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --crate-type staticlib - $(RUSTC) bar.rs 2>&1 | $(CGREP) "found staticlib" diff --git a/src/test/run-make/error-found-staticlib-instead-crate/bar.rs b/src/test/run-make/error-found-staticlib-instead-crate/bar.rs deleted file mode 100644 index 5ab3e5ee99d..00000000000 --- a/src/test/run-make/error-found-staticlib-instead-crate/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::foo(); -} diff --git a/src/test/run-make/error-found-staticlib-instead-crate/foo.rs b/src/test/run-make/error-found-staticlib-instead-crate/foo.rs deleted file mode 100644 index 222d98a12de..00000000000 --- a/src/test/run-make/error-found-staticlib-instead-crate/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() {} diff --git a/src/test/run-make/error-writing-dependencies/Makefile b/src/test/run-make/error-writing-dependencies/Makefile deleted file mode 100644 index cbc96901a38..00000000000 --- a/src/test/run-make/error-writing-dependencies/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - # Let's get a nice error message - $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | \ - $(CGREP) "error writing dependencies" - # Make sure the filename shows up - $(BARE_RUSTC) foo.rs --emit dep-info --out-dir foo/bar/baz 2>&1 | $(CGREP) "baz" diff --git a/src/test/run-make/error-writing-dependencies/foo.rs b/src/test/run-make/error-writing-dependencies/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/error-writing-dependencies/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/extern-diff-internal-name/Makefile b/src/test/run-make/extern-diff-internal-name/Makefile deleted file mode 100644 index b84e930757b..00000000000 --- a/src/test/run-make/extern-diff-internal-name/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - $(RUSTC) test.rs --extern foo=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make/extern-diff-internal-name/lib.rs b/src/test/run-make/extern-diff-internal-name/lib.rs deleted file mode 100644 index e8779bba13c..00000000000 --- a/src/test/run-make/extern-diff-internal-name/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "bar"] -#![crate_type = "rlib"] diff --git a/src/test/run-make/extern-diff-internal-name/test.rs b/src/test/run-make/extern-diff-internal-name/test.rs deleted file mode 100644 index 11e042c8c4a..00000000000 --- a/src/test/run-make/extern-diff-internal-name/test.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate foo; - -fn main() { -} diff --git a/src/test/run-make/extern-flag-disambiguates/Makefile b/src/test/run-make/extern-flag-disambiguates/Makefile deleted file mode 100644 index 81930e969a9..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/Makefile +++ /dev/null @@ -1,25 +0,0 @@ --include ../tools.mk - -# Attempt to build this dependency tree: -# -# A.1 A.2 -# |\ | -# | \ | -# B \ C -# \ | / -# \|/ -# D -# -# Note that A.1 and A.2 are crates with the same name. - -all: - $(RUSTC) -C metadata=1 -C extra-filename=-1 a.rs - $(RUSTC) -C metadata=2 -C extra-filename=-2 a.rs - $(RUSTC) b.rs --extern a=$(TMPDIR)/liba-1.rlib - $(RUSTC) c.rs --extern a=$(TMPDIR)/liba-2.rlib - @echo before - $(RUSTC) --cfg before d.rs --extern a=$(TMPDIR)/liba-1.rlib - $(call RUN,d) - @echo after - $(RUSTC) --cfg after d.rs --extern a=$(TMPDIR)/liba-1.rlib - $(call RUN,d) diff --git a/src/test/run-make/extern-flag-disambiguates/a.rs b/src/test/run-make/extern-flag-disambiguates/a.rs deleted file mode 100644 index ac92aede789..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/a.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "a"] -#![crate_type = "rlib"] - -static FOO: usize = 3; - -pub fn token() -> &'static usize { &FOO } diff --git a/src/test/run-make/extern-flag-disambiguates/b.rs b/src/test/run-make/extern-flag-disambiguates/b.rs deleted file mode 100644 index 8ae238f5a48..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/b.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "b"] -#![crate_type = "rlib"] - -extern crate a; - -static FOO: usize = 3; - -pub fn token() -> &'static usize { &FOO } -pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make/extern-flag-disambiguates/c.rs b/src/test/run-make/extern-flag-disambiguates/c.rs deleted file mode 100644 index 6eccdf7e5c8..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/c.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "c"] -#![crate_type = "rlib"] - -extern crate a; - -static FOO: usize = 3; - -pub fn token() -> &'static usize { &FOO } -pub fn a_token() -> &'static usize { a::token() } diff --git a/src/test/run-make/extern-flag-disambiguates/d.rs b/src/test/run-make/extern-flag-disambiguates/d.rs deleted file mode 100644 index 9923ff83a91..00000000000 --- a/src/test/run-make/extern-flag-disambiguates/d.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[cfg(before)] extern crate a; -extern crate b; -extern crate c; -#[cfg(after)] extern crate a; - -fn t(a: &'static usize) -> usize { a as *const _ as usize } - -fn main() { - assert_eq!(t(a::token()), t(b::a_token())); - assert!(t(a::token()) != t(c::a_token())); -} diff --git a/src/test/run-make/extern-flag-fun/Makefile b/src/test/run-make/extern-flag-fun/Makefile deleted file mode 100644 index a9f25853350..00000000000 --- a/src/test/run-make/extern-flag-fun/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=rlib - $(RUSTC) bar.rs --crate-type=rlib -C extra-filename=-a - $(RUSTC) bar-alt.rs --crate-type=rlib - $(RUSTC) foo.rs --extern hello && exit 1 || exit 0 - $(RUSTC) foo.rs --extern bar=no-exist && exit 1 || exit 0 - $(RUSTC) foo.rs --extern bar=foo.rs && exit 1 || exit 0 - $(RUSTC) foo.rs \ - --extern bar=$(TMPDIR)/libbar.rlib \ - --extern bar=$(TMPDIR)/libbar-alt.rlib \ - && exit 1 || exit 0 - $(RUSTC) foo.rs \ - --extern bar=$(TMPDIR)/libbar.rlib \ - --extern bar=$(TMPDIR)/libbar-a.rlib - $(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib diff --git a/src/test/run-make/extern-flag-fun/bar-alt.rs b/src/test/run-make/extern-flag-fun/bar-alt.rs deleted file mode 100644 index d6ebd9d896f..00000000000 --- a/src/test/run-make/extern-flag-fun/bar-alt.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn f() {} diff --git a/src/test/run-make/extern-flag-fun/bar.rs b/src/test/run-make/extern-flag-fun/bar.rs deleted file mode 100644 index e6c76025738..00000000000 --- a/src/test/run-make/extern-flag-fun/bar.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/extern-flag-fun/foo.rs b/src/test/run-make/extern-flag-fun/foo.rs deleted file mode 100644 index 52741668640..00000000000 --- a/src/test/run-make/extern-flag-fun/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() {} diff --git a/src/test/run-make/extern-fn-generic/Makefile b/src/test/run-make/extern-fn-generic/Makefile deleted file mode 100644 index cf897dba1f2..00000000000 --- a/src/test/run-make/extern-fn-generic/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) testcrate.rs - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-generic/test.c b/src/test/run-make/extern-fn-generic/test.c deleted file mode 100644 index f9faef64afc..00000000000 --- a/src/test/run-make/extern-fn-generic/test.c +++ /dev/null @@ -1,17 +0,0 @@ -// ignore-license -#include - -typedef struct TestStruct { - uint8_t x; - int32_t y; -} TestStruct; - -typedef int callback(TestStruct s); - -uint32_t call(callback *c) { - TestStruct s; - s.x = 'a'; - s.y = 3; - - return c(s); -} diff --git a/src/test/run-make/extern-fn-generic/test.rs b/src/test/run-make/extern-fn-generic/test.rs deleted file mode 100644 index 8f5ff091b3b..00000000000 --- a/src/test/run-make/extern-fn-generic/test.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate testcrate; - -extern "C" fn bar(ts: testcrate::TestStruct) -> T { ts.y } - -#[link(name = "test", kind = "static")] -extern { - fn call(c: extern "C" fn(testcrate::TestStruct) -> i32) -> i32; -} - -fn main() { - // Let's test calling it cross crate - let back = unsafe { - testcrate::call(testcrate::foo::) - }; - assert_eq!(3, back); - - // And just within this crate - let back = unsafe { - call(bar::) - }; - assert_eq!(3, back); -} diff --git a/src/test/run-make/extern-fn-generic/testcrate.rs b/src/test/run-make/extern-fn-generic/testcrate.rs deleted file mode 100644 index d02c05047c0..00000000000 --- a/src/test/run-make/extern-fn-generic/testcrate.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[repr(C)] -pub struct TestStruct { - pub x: u8, - pub y: T -} - -pub extern "C" fn foo(ts: TestStruct) -> T { ts.y } - -#[link(name = "test", kind = "static")] -extern { - pub fn call(c: extern "C" fn(TestStruct) -> i32) -> i32; -} diff --git a/src/test/run-make/extern-fn-mangle/Makefile b/src/test/run-make/extern-fn-mangle/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/extern-fn-mangle/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-mangle/test.c b/src/test/run-make/extern-fn-mangle/test.c deleted file mode 100644 index 1a9855dedec..00000000000 --- a/src/test/run-make/extern-fn-mangle/test.c +++ /dev/null @@ -1,9 +0,0 @@ -// ignore-license -#include - -uint32_t foo(); -uint32_t bar(); - -uint32_t add() { - return foo() + bar(); -} diff --git a/src/test/run-make/extern-fn-mangle/test.rs b/src/test/run-make/extern-fn-mangle/test.rs deleted file mode 100644 index 35b5a9278a4..00000000000 --- a/src/test/run-make/extern-fn-mangle/test.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern "C" fn foo() -> i32 { 3 } - -#[no_mangle] -pub extern "C" fn bar() -> i32 { 5 } - -#[link(name = "test", kind = "static")] -extern { - fn add() -> i32; -} - -fn main() { - let back = unsafe { add() }; - assert_eq!(8, back); -} diff --git a/src/test/run-make/extern-fn-reachable/Makefile b/src/test/run-make/extern-fn-reachable/Makefile deleted file mode 100644 index 79a9a3c640f..00000000000 --- a/src/test/run-make/extern-fn-reachable/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# This overrides the LD_LIBRARY_PATH for RUN -TARGET_RPATH_DIR:=$(TARGET_RPATH_DIR):$(TMPDIR) - -all: - $(RUSTC) dylib.rs -o $(TMPDIR)/libdylib.so -C prefer-dynamic - $(RUSTC) main.rs -C prefer-dynamic - $(call RUN,main) diff --git a/src/test/run-make/extern-fn-reachable/dylib.rs b/src/test/run-make/extern-fn-reachable/dylib.rs deleted file mode 100644 index f24265e7a52..00000000000 --- a/src/test/run-make/extern-fn-reachable/dylib.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -#![allow(dead_code)] - -#[no_mangle] pub extern "C" fn fun1() {} -#[no_mangle] extern "C" fn fun2() {} - -mod foo { - #[no_mangle] pub extern "C" fn fun3() {} -} -pub mod bar { - #[no_mangle] pub extern "C" fn fun4() {} -} - -#[no_mangle] pub fn fun5() {} diff --git a/src/test/run-make/extern-fn-reachable/main.rs b/src/test/run-make/extern-fn-reachable/main.rs deleted file mode 100644 index 27387332c1c..00000000000 --- a/src/test/run-make/extern-fn-reachable/main.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_private)] - -extern crate rustc_metadata; - -use rustc_metadata::dynamic_lib::DynamicLibrary; -use std::path::Path; - -pub fn main() { - unsafe { - let path = Path::new("libdylib.so"); - let a = DynamicLibrary::open(Some(&path)).unwrap(); - assert!(a.symbol::("fun1").is_ok()); - assert!(a.symbol::("fun2").is_err()); - assert!(a.symbol::("fun3").is_err()); - assert!(a.symbol::("fun4").is_ok()); - assert!(a.symbol::("fun5").is_ok()); - } -} diff --git a/src/test/run-make/extern-fn-struct-passing-abi/Makefile b/src/test/run-make/extern-fn-struct-passing-abi/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/extern-fn-struct-passing-abi/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-struct-passing-abi/test.c b/src/test/run-make/extern-fn-struct-passing-abi/test.c deleted file mode 100644 index 25cd6da10b8..00000000000 --- a/src/test/run-make/extern-fn-struct-passing-abi/test.c +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include - -struct Rect { - int32_t a; - int32_t b; - int32_t c; - int32_t d; -}; - -struct BiggerRect { - struct Rect s; - int32_t a; - int32_t b; -}; - -struct FloatRect { - int32_t a; - int32_t b; - double c; -}; - -struct Huge { - int32_t a; - int32_t b; - int32_t c; - int32_t d; - int32_t e; -}; - -struct FloatPoint { - double x; - double y; -}; - -struct FloatOne { - double x; -}; - -struct IntOdd { - int8_t a; - int8_t b; - int8_t c; -}; - -// System V x86_64 ABI: -// a, b, c, d, e should be in registers -// s should be byval pointer -// -// Win64 ABI: -// a, b, c, d should be in registers -// e should be on the stack -// s should be byval pointer -void byval_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(d == 4); - assert(e == 5); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 ABI: -// a, b, c, d, e, f should be in registers -// s should be byval pointer on the stack -// -// Win64 ABI: -// a, b, c, d should be in registers -// e, f should be on the stack -// s should be byval pointer on the stack -void byval_many_rect(int32_t a, int32_t b, int32_t c, int32_t d, int32_t e, - int32_t f, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(d == 4); - assert(e == 5); - assert(f == 6); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 ABI: -// a, b, c, d, e, f, g should be in sse registers -// s should be split across 2 registers -// t should be byval pointer -// -// Win64 ABI: -// a, b, c, d should be in sse registers -// e, f, g should be on the stack -// s should be on the stack (treated as 2 i64's) -// t should be on the stack (treated as an i64 and a double) -void byval_rect_floats(float a, float b, double c, float d, float e, - float f, double g, struct Rect s, struct FloatRect t) { - assert(a == 1.); - assert(b == 2.); - assert(c == 3.); - assert(d == 4.); - assert(e == 5.); - assert(f == 6.); - assert(g == 7.); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - assert(t.a == 3489); - assert(t.b == 3490); - assert(t.c == 8.); -} - -// System V x86_64 ABI: -// a, b, d, e, f should be in registers -// c passed via sse registers -// s should be byval pointer -// -// Win64 ABI: -// a, b, d should be in registers -// c passed via sse registers -// e, f should be on the stack -// s should be byval pointer -void byval_rect_with_float(int32_t a, int32_t b, float c, int32_t d, - int32_t e, int32_t f, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3.); - assert(d == 4); - assert(e == 5); - assert(f == 6); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 ABI: -// a, b, d, e, f should be byval pointer (on the stack) -// g passed via register (fixes #41375) -// -// Win64 ABI: -// a, b, d, e, f, g should be byval pointer -void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c, - struct Huge d, struct Huge e, struct Huge f, - struct Rect g) { - assert(g.a == 123); - assert(g.b == 456); - assert(g.c == 789); - assert(g.d == 420); -} - -// System V x86_64 & Win64 ABI: -// a, b should be in registers -// s should be split across 2 integer registers -void split_rect(int32_t a, int32_t b, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 & Win64 ABI: -// a, b should be in sse registers -// s should be split across integer & sse registers -void split_rect_floats(float a, float b, struct FloatRect s) { - assert(a == 1.); - assert(b == 2.); - assert(s.a == 3489); - assert(s.b == 3490); - assert(s.c == 8.); -} - -// System V x86_64 ABI: -// a, b, d, f should be in registers -// c, e passed via sse registers -// s should be split across 2 registers -// -// Win64 ABI: -// a, b, d should be in registers -// c passed via sse registers -// e, f should be on the stack -// s should be on the stack (treated as 2 i64's) -void split_rect_with_floats(int32_t a, int32_t b, float c, - int32_t d, float e, int32_t f, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3.); - assert(d == 4); - assert(e == 5.); - assert(f == 6); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); -} - -// System V x86_64 & Win64 ABI: -// a, b, c should be in registers -// s should be split across 2 registers -// t should be a byval pointer -void split_and_byval_rect(int32_t a, int32_t b, int32_t c, struct Rect s, struct Rect t) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - assert(t.a == 553); - assert(t.b == 554); - assert(t.c == 555); - assert(t.d == 556); -} - -// System V x86_64 & Win64 ABI: -// a, b should in registers -// s and return should be split across 2 registers -struct Rect split_ret_byval_struct(int32_t a, int32_t b, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - return s; -} - -// System V x86_64 & Win64 ABI: -// a, b, c, d should be in registers -// return should be in a hidden sret pointer -// s should be a byval pointer -struct BiggerRect sret_byval_struct(int32_t a, int32_t b, int32_t c, int32_t d, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(c == 3); - assert(d == 4); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - - struct BiggerRect t; - t.s = s; t.a = 27834; t.b = 7657; - return t; -} - -// System V x86_64 & Win64 ABI: -// a, b should be in registers -// return should be in a hidden sret pointer -// s should be split across 2 registers -struct BiggerRect sret_split_struct(int32_t a, int32_t b, struct Rect s) { - assert(a == 1); - assert(b == 2); - assert(s.a == 553); - assert(s.b == 554); - assert(s.c == 555); - assert(s.d == 556); - - struct BiggerRect t; - t.s = s; t.a = 27834; t.b = 7657; - return t; -} - -// System V x86_64 & Win64 ABI: -// s should be byval pointer (since sizeof(s) > 16) -// return should in a hidden sret pointer -struct Huge huge_struct(struct Huge s) { - assert(s.a == 5647); - assert(s.b == 5648); - assert(s.c == 5649); - assert(s.d == 5650); - assert(s.e == 5651); - - return s; -} - -// System V x86_64 ABI: -// p should be in registers -// return should be in registers -// -// Win64 ABI and 64-bit PowerPC ELFv1 ABI: -// p should be a byval pointer -// return should be in a hidden sret pointer -struct FloatPoint float_point(struct FloatPoint p) { - assert(p.x == 5.); - assert(p.y == -3.); - - return p; -} - -// 64-bit PowerPC ELFv1 ABI: -// f1 should be in a register -// return should be in a hidden sret pointer -struct FloatOne float_one(struct FloatOne f1) { - assert(f1.x == 7.); - - return f1; -} - -// 64-bit PowerPC ELFv1 ABI: -// i should be in the least-significant bits of a register -// return should be in a hidden sret pointer -struct IntOdd int_odd(struct IntOdd i) { - assert(i.a == 1); - assert(i.b == 2); - assert(i.c == 3); - - return i; -} diff --git a/src/test/run-make/extern-fn-struct-passing-abi/test.rs b/src/test/run-make/extern-fn-struct-passing-abi/test.rs deleted file mode 100644 index 54a4f868eb4..00000000000 --- a/src/test/run-make/extern-fn-struct-passing-abi/test.rs +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Passing structs via FFI should work regardless of whether -// they get passed in multiple registers, byval pointers or the stack - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct Rect { - a: i32, - b: i32, - c: i32, - d: i32 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct BiggerRect { - s: Rect, - a: i32, - b: i32 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct FloatRect { - a: i32, - b: i32, - c: f64 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct Huge { - a: i32, - b: i32, - c: i32, - d: i32, - e: i32 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct FloatPoint { - x: f64, - y: f64 -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct FloatOne { - x: f64, -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[repr(C)] -struct IntOdd { - a: i8, - b: i8, - c: i8, -} - -#[link(name = "test", kind = "static")] -extern { - fn byval_rect(a: i32, b: i32, c: i32, d: i32, e: i32, s: Rect); - - fn byval_many_rect(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, s: Rect); - - fn byval_rect_floats(a: f32, b: f32, c: f64, d: f32, e: f32, - f: f32, g: f64, s: Rect, t: FloatRect); - - fn byval_rect_with_float(a: i32, b: i32, c: f32, d: i32, e: i32, f: i32, s: Rect); - - fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect); - - fn split_rect(a: i32, b: i32, s: Rect); - - fn split_rect_floats(a: f32, b: f32, s: FloatRect); - - fn split_rect_with_floats(a: i32, b: i32, c: f32, d: i32, e: f32, f: i32, s: Rect); - - fn split_and_byval_rect(a: i32, b: i32, c: i32, s: Rect, t: Rect); - - fn split_ret_byval_struct(a: i32, b: i32, s: Rect) -> Rect; - - fn sret_byval_struct(a: i32, b: i32, c: i32, d: i32, s: Rect) -> BiggerRect; - - fn sret_split_struct(a: i32, b: i32, s: Rect) -> BiggerRect; - - fn huge_struct(s: Huge) -> Huge; - - fn float_point(p: FloatPoint) -> FloatPoint; - - fn float_one(f: FloatOne) -> FloatOne; - - fn int_odd(i: IntOdd) -> IntOdd; -} - -fn main() { - let s = Rect { a: 553, b: 554, c: 555, d: 556 }; - let t = BiggerRect { s: s, a: 27834, b: 7657 }; - let u = FloatRect { a: 3489, b: 3490, c: 8. }; - let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 }; - let p = FloatPoint { x: 5., y: -3. }; - let f1 = FloatOne { x: 7. }; - let i = IntOdd { a: 1, b: 2, c: 3 }; - - unsafe { - byval_rect(1, 2, 3, 4, 5, s); - byval_many_rect(1, 2, 3, 4, 5, 6, s); - byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u); - byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s); - byval_rect_with_many_huge(v, v, v, v, v, v, Rect { - a: 123, - b: 456, - c: 789, - d: 420 - }); - split_rect(1, 2, s); - split_rect_floats(1., 2., u); - split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s); - split_and_byval_rect(1, 2, 3, s, s); - split_rect(1, 2, s); - assert_eq!(huge_struct(v), v); - assert_eq!(split_ret_byval_struct(1, 2, s), s); - assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t); - assert_eq!(sret_split_struct(1, 2, s), t); - assert_eq!(float_point(p), p); - assert_eq!(int_odd(i), i); - - // MSVC/GCC/Clang are not consistent in the ABI of single-float aggregates. - // x86_64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82028 - // i686: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82041 - #[cfg(not(all(windows, target_env = "gnu")))] - assert_eq!(float_one(f1), f1); - } -} diff --git a/src/test/run-make/extern-fn-with-extern-types/Makefile b/src/test/run-make/extern-fn-with-extern-types/Makefile deleted file mode 100644 index 8977e14c3ad..00000000000 --- a/src/test/run-make/extern-fn-with-extern-types/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,ctest) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-extern-types/ctest.c b/src/test/run-make/extern-fn-with-extern-types/ctest.c deleted file mode 100644 index c3d6166fb12..00000000000 --- a/src/test/run-make/extern-fn-with-extern-types/ctest.c +++ /dev/null @@ -1,17 +0,0 @@ -// ignore-license -#include -#include - -typedef struct data { - uint32_t magic; -} data; - -data* data_create(uint32_t magic) { - static data d; - d.magic = magic; - return &d; -} - -uint32_t data_get(data* p) { - return p->magic; -} diff --git a/src/test/run-make/extern-fn-with-extern-types/test.rs b/src/test/run-make/extern-fn-with-extern-types/test.rs deleted file mode 100644 index 9d6c87885b1..00000000000 --- a/src/test/run-make/extern-fn-with-extern-types/test.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(extern_types)] - -#[link(name = "ctest", kind = "static")] -extern { - type data; - - fn data_create(magic: u32) -> *mut data; - fn data_get(data: *mut data) -> u32; -} - -const MAGIC: u32 = 0xdeadbeef; -fn main() { - unsafe { - let data = data_create(MAGIC); - assert_eq!(data_get(data), MAGIC); - } -} diff --git a/src/test/run-make/extern-fn-with-packed-struct/Makefile b/src/test/run-make/extern-fn-with-packed-struct/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/extern-fn-with-packed-struct/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-packed-struct/test.c b/src/test/run-make/extern-fn-with-packed-struct/test.c deleted file mode 100644 index 4124e202c1d..00000000000 --- a/src/test/run-make/extern-fn-with-packed-struct/test.c +++ /dev/null @@ -1,27 +0,0 @@ -// ignore-license -// Pragma needed cause of gcc bug on windows: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52991 - -#include - -#ifdef _MSC_VER -#pragma pack(push,1) -struct Foo { - char a; - short b; - char c; -}; -#else -#pragma pack(1) -struct __attribute__((packed)) Foo { - char a; - short b; - char c; -}; -#endif - -struct Foo foo(struct Foo foo) { - assert(foo.a == 1); - assert(foo.b == 2); - assert(foo.c == 3); - return foo; -} diff --git a/src/test/run-make/extern-fn-with-packed-struct/test.rs b/src/test/run-make/extern-fn-with-packed-struct/test.rs deleted file mode 100644 index d2540ad6154..00000000000 --- a/src/test/run-make/extern-fn-with-packed-struct/test.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[repr(C, packed)] -#[derive(Copy, Clone, Debug, PartialEq)] -struct Foo { - a: i8, - b: i16, - c: i8 -} - -#[link(name = "test", kind = "static")] -extern { - fn foo(f: Foo) -> Foo; -} - -fn main() { - unsafe { - let a = Foo { a: 1, b: 2, c: 3 }; - let b = foo(a); - assert_eq!(a, b); - } -} diff --git a/src/test/run-make/extern-fn-with-union/Makefile b/src/test/run-make/extern-fn-with-union/Makefile deleted file mode 100644 index 71a5407e882..00000000000 --- a/src/test/run-make/extern-fn-with-union/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,ctest) - $(RUSTC) testcrate.rs - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/extern-fn-with-union/ctest.c b/src/test/run-make/extern-fn-with-union/ctest.c deleted file mode 100644 index 8c87c230693..00000000000 --- a/src/test/run-make/extern-fn-with-union/ctest.c +++ /dev/null @@ -1,11 +0,0 @@ -// ignore-license -#include -#include - -typedef union TestUnion { - uint64_t bits; -} TestUnion; - -uint64_t give_back(TestUnion tu) { - return tu.bits; -} diff --git a/src/test/run-make/extern-fn-with-union/test.rs b/src/test/run-make/extern-fn-with-union/test.rs deleted file mode 100644 index f9277ba11f4..00000000000 --- a/src/test/run-make/extern-fn-with-union/test.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate testcrate; - -use std::mem; - -extern { - fn give_back(tu: testcrate::TestUnion) -> u64; -} - -fn main() { - let magic: u64 = 0xDEADBEEF; - - // Let's test calling it cross crate - let back = unsafe { - testcrate::give_back(mem::transmute(magic)) - }; - assert_eq!(magic, back); - - // And just within this crate - let back = unsafe { - give_back(mem::transmute(magic)) - }; - assert_eq!(magic, back); -} diff --git a/src/test/run-make/extern-fn-with-union/testcrate.rs b/src/test/run-make/extern-fn-with-union/testcrate.rs deleted file mode 100644 index 66978c38511..00000000000 --- a/src/test/run-make/extern-fn-with-union/testcrate.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[repr(C)] -pub struct TestUnion { - _val: u64 -} - -#[link(name = "ctest", kind = "static")] -extern { - pub fn give_back(tu: TestUnion) -> u64; -} diff --git a/src/test/run-make/extern-multiple-copies/Makefile b/src/test/run-make/extern-multiple-copies/Makefile deleted file mode 100644 index 1631aa806af..00000000000 --- a/src/test/run-make/extern-multiple-copies/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo1.rs - $(RUSTC) foo2.rs - mkdir $(TMPDIR)/foo - cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib - $(RUSTC) bar.rs --extern foo1=$(TMPDIR)/libfoo1.rlib -L $(TMPDIR)/foo diff --git a/src/test/run-make/extern-multiple-copies/bar.rs b/src/test/run-make/extern-multiple-copies/bar.rs deleted file mode 100644 index a50f5de384c..00000000000 --- a/src/test/run-make/extern-multiple-copies/bar.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo2; // foo2 first to exhibit the bug -extern crate foo1; - -fn main() { - /* ... */ -} diff --git a/src/test/run-make/extern-multiple-copies/foo1.rs b/src/test/run-make/extern-multiple-copies/foo1.rs deleted file mode 100644 index 0be200ddcd2..00000000000 --- a/src/test/run-make/extern-multiple-copies/foo1.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/extern-multiple-copies/foo2.rs b/src/test/run-make/extern-multiple-copies/foo2.rs deleted file mode 100644 index 0be200ddcd2..00000000000 --- a/src/test/run-make/extern-multiple-copies/foo2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/extern-multiple-copies2/Makefile b/src/test/run-make/extern-multiple-copies2/Makefile deleted file mode 100644 index 567d7e78a57..00000000000 --- a/src/test/run-make/extern-multiple-copies2/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo1.rs - $(RUSTC) foo2.rs - mkdir $(TMPDIR)/foo - cp $(TMPDIR)/libfoo1.rlib $(TMPDIR)/foo/libfoo1.rlib - $(RUSTC) bar.rs \ - --extern foo1=$(TMPDIR)/foo/libfoo1.rlib \ - --extern foo2=$(TMPDIR)/libfoo2.rlib diff --git a/src/test/run-make/extern-multiple-copies2/bar.rs b/src/test/run-make/extern-multiple-copies2/bar.rs deleted file mode 100644 index b8ac34aa53e..00000000000 --- a/src/test/run-make/extern-multiple-copies2/bar.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate foo2; // foo2 first to exhibit the bug -#[macro_use] -extern crate foo1; - -fn main() { - foo2::foo2(foo1::A); -} diff --git a/src/test/run-make/extern-multiple-copies2/foo1.rs b/src/test/run-make/extern-multiple-copies2/foo1.rs deleted file mode 100644 index 1787772053b..00000000000 --- a/src/test/run-make/extern-multiple-copies2/foo1.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub struct A; - -pub fn foo1(a: A) { - drop(a); -} diff --git a/src/test/run-make/extern-multiple-copies2/foo2.rs b/src/test/run-make/extern-multiple-copies2/foo2.rs deleted file mode 100644 index bad10304387..00000000000 --- a/src/test/run-make/extern-multiple-copies2/foo2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[macro_use] -extern crate foo1; - -pub fn foo2(a: foo1::A) { - foo1::foo1(a); -} diff --git a/src/test/run-make/extern-overrides-distribution/Makefile b/src/test/run-make/extern-overrides-distribution/Makefile deleted file mode 100644 index 7d063a4c83c..00000000000 --- a/src/test/run-make/extern-overrides-distribution/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) libc.rs -Cmetadata=foo - $(RUSTC) main.rs --extern libc=$(TMPDIR)/liblibc.rlib diff --git a/src/test/run-make/extern-overrides-distribution/libc.rs b/src/test/run-make/extern-overrides-distribution/libc.rs deleted file mode 100644 index a489d834a92..00000000000 --- a/src/test/run-make/extern-overrides-distribution/libc.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub fn foo() {} diff --git a/src/test/run-make/extern-overrides-distribution/main.rs b/src/test/run-make/extern-overrides-distribution/main.rs deleted file mode 100644 index 451841e7368..00000000000 --- a/src/test/run-make/extern-overrides-distribution/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate libc; - -fn main() { - libc::foo(); -} diff --git a/src/test/run-make/extra-filename-with-temp-outputs/Makefile b/src/test/run-make/extra-filename-with-temp-outputs/Makefile deleted file mode 100644 index 6de4f97df0c..00000000000 --- a/src/test/run-make/extra-filename-with-temp-outputs/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -C extra-filename=bar foo.rs -C save-temps - rm $(TMPDIR)/foobar.foo0.rcgu.o - rm $(TMPDIR)/$(call BIN,foobar) diff --git a/src/test/run-make/extra-filename-with-temp-outputs/foo.rs b/src/test/run-make/extra-filename-with-temp-outputs/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/extra-filename-with-temp-outputs/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/fpic/Makefile b/src/test/run-make/fpic/Makefile deleted file mode 100644 index 6de58c2db18..00000000000 --- a/src/test/run-make/fpic/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# Test for #39529. -# `-z text` causes ld to error if there are any non-PIC sections - -ifeq ($(UNAME),Darwin) -all: -else ifdef IS_WINDOWS -all: -else -all: - $(RUSTC) hello.rs -C link-args=-Wl,-z,text -endif diff --git a/src/test/run-make/fpic/hello.rs b/src/test/run-make/fpic/hello.rs deleted file mode 100644 index a9e231b0ea8..00000000000 --- a/src/test/run-make/fpic/hello.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/hir-tree/Makefile b/src/test/run-make/hir-tree/Makefile deleted file mode 100644 index 2e100b269e1..00000000000 --- a/src/test/run-make/hir-tree/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -# Test that hir-tree output doens't crash and includes -# the string constant we would expect to see. - -all: - $(RUSTC) -o $(TMPDIR)/input.hir -Z unpretty=hir-tree input.rs - $(CGREP) '"Hello, Rustaceans!\n"' < $(TMPDIR)/input.hir diff --git a/src/test/run-make/hir-tree/input.rs b/src/test/run-make/hir-tree/input.rs deleted file mode 100644 index 12adc083bcd..00000000000 --- a/src/test/run-make/hir-tree/input.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, Rustaceans!"); -} diff --git a/src/test/run-make/hotplug_codegen_backend/Makefile b/src/test/run-make/hotplug_codegen_backend/Makefile deleted file mode 100644 index 2ddf3aa5439..00000000000 --- a/src/test/run-make/hotplug_codegen_backend/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -include ../tools.mk - -all: - /bin/echo || exit 0 # This test requires /bin/echo to exist - $(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \ - -o $(TMPDIR)/the_backend.dylib - $(RUSTC) some_crate.rs --crate-name some_crate --crate-type bin -o $(TMPDIR)/some_crate \ - -Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options - grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate diff --git a/src/test/run-make/hotplug_codegen_backend/some_crate.rs b/src/test/run-make/hotplug_codegen_backend/some_crate.rs deleted file mode 100644 index 26ffce01b2e..00000000000 --- a/src/test/run-make/hotplug_codegen_backend/some_crate.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - ::std::process::exit(1); -} diff --git a/src/test/run-make/hotplug_codegen_backend/the_backend.rs b/src/test/run-make/hotplug_codegen_backend/the_backend.rs deleted file mode 100644 index e266b0f5e83..00000000000 --- a/src/test/run-make/hotplug_codegen_backend/the_backend.rs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_private)] - -extern crate syntax; -extern crate rustc; -extern crate rustc_trans_utils; - -use std::any::Any; -use std::sync::mpsc; -use syntax::symbol::Symbol; -use rustc::session::{Session, CompileIncomplete}; -use rustc::session::config::OutputFilenames; -use rustc::ty::TyCtxt; -use rustc::ty::maps::Providers; -use rustc::middle::cstore::MetadataLoader; -use rustc::dep_graph::DepGraph; -use rustc_trans_utils::trans_crate::{TransCrate, MetadataOnlyTransCrate}; - -struct TheBackend(Box); - -impl TransCrate for TheBackend { - fn metadata_loader(&self) -> Box { - self.0.metadata_loader() - } - - fn provide(&self, providers: &mut Providers) { - self.0.provide(providers); - } - - fn provide_extern(&self, providers: &mut Providers) { - self.0.provide_extern(providers); - } - - fn trans_crate<'a, 'tcx>( - &self, - tcx: TyCtxt<'a, 'tcx, 'tcx>, - _rx: mpsc::Receiver> - ) -> Box { - use rustc::hir::def_id::LOCAL_CRATE; - - Box::new(tcx.crate_name(LOCAL_CRATE) as Symbol) - } - - fn join_trans_and_link( - &self, - trans: Box, - sess: &Session, - _dep_graph: &DepGraph, - outputs: &OutputFilenames, - ) -> Result<(), CompileIncomplete> { - use std::io::Write; - use rustc::session::config::CrateType; - use rustc_trans_utils::link::out_filename; - let crate_name = trans.downcast::() - .expect("in join_trans_and_link: trans is not a Symbol"); - for &crate_type in sess.opts.crate_types.iter() { - if crate_type != CrateType::CrateTypeExecutable { - sess.fatal(&format!("Crate type is {:?}", crate_type)); - } - let output_name = - out_filename(sess, crate_type, &outputs, &*crate_name.as_str()); - let mut out_file = ::std::fs::File::create(output_name).unwrap(); - write!(out_file, "This has been \"compiled\" successfully.").unwrap(); - } - Ok(()) - } -} - -/// This is the entrypoint for a hot plugged rustc_trans -#[no_mangle] -pub fn __rustc_codegen_backend() -> Box { - Box::new(TheBackend(MetadataOnlyTransCrate::new())) -} diff --git a/src/test/run-make/include_bytes_deps/Makefile b/src/test/run-make/include_bytes_deps/Makefile deleted file mode 100644 index 1293695b799..00000000000 --- a/src/test/run-make/include_bytes_deps/Makefile +++ /dev/null @@ -1,20 +0,0 @@ --include ../tools.mk - -# FIXME: ignore freebsd/windows -# on windows `rustc --dep-info` produces Makefile dependency with -# windows native paths (e.g. `c:\path\to\libfoo.a`) -# but msys make seems to fail to recognize such paths, so test fails. -ifneq ($(shell uname),FreeBSD) -ifndef IS_WINDOWS -all: - $(RUSTC) --emit dep-info main.rs - $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/include_bytes_deps/input.bin b/src/test/run-make/include_bytes_deps/input.bin deleted file mode 100644 index cd0875583aa..00000000000 --- a/src/test/run-make/include_bytes_deps/input.bin +++ /dev/null @@ -1 +0,0 @@ -Hello world! diff --git a/src/test/run-make/include_bytes_deps/input.md b/src/test/run-make/include_bytes_deps/input.md deleted file mode 100644 index 2a19b7405f7..00000000000 --- a/src/test/run-make/include_bytes_deps/input.md +++ /dev/null @@ -1 +0,0 @@ -# Hello, world! diff --git a/src/test/run-make/include_bytes_deps/input.txt b/src/test/run-make/include_bytes_deps/input.txt deleted file mode 100644 index cd0875583aa..00000000000 --- a/src/test/run-make/include_bytes_deps/input.txt +++ /dev/null @@ -1 +0,0 @@ -Hello world! diff --git a/src/test/run-make/include_bytes_deps/main.rs b/src/test/run-make/include_bytes_deps/main.rs deleted file mode 100644 index 27ca1a46a50..00000000000 --- a/src/test/run-make/include_bytes_deps/main.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(external_doc)] - -#[doc(include="input.md")] -pub struct SomeStruct; - -pub fn main() { - const INPUT_TXT: &'static str = include_str!("input.txt"); - const INPUT_BIN: &'static [u8] = include_bytes!("input.bin"); - - println!("{}", INPUT_TXT); - println!("{:?}", INPUT_BIN); -} diff --git a/src/test/run-make/inline-always-many-cgu/Makefile b/src/test/run-make/inline-always-many-cgu/Makefile deleted file mode 100644 index 0cab955f644..00000000000 --- a/src/test/run-make/inline-always-many-cgu/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --emit llvm-ir -C codegen-units=2 - if cat $(TMPDIR)/*.ll | $(CGREP) -e '\bcall\b'; then \ - echo "found call instruction when one wasn't expected"; \ - exit 1; \ - fi diff --git a/src/test/run-make/inline-always-many-cgu/foo.rs b/src/test/run-make/inline-always-many-cgu/foo.rs deleted file mode 100644 index 539dcdfa9b3..00000000000 --- a/src/test/run-make/inline-always-many-cgu/foo.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -pub mod a { - #[inline(always)] - pub fn foo() { - } - - pub fn bar() { - } -} - -#[no_mangle] -pub fn bar() { - a::foo(); -} diff --git a/src/test/run-make/interdependent-c-libraries/Makefile b/src/test/run-make/interdependent-c-libraries/Makefile deleted file mode 100644 index 1268022e37b..00000000000 --- a/src/test/run-make/interdependent-c-libraries/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# The rust crate foo will link to the native library foo, while the rust crate -# bar will link to the native library bar. There is also a dependency between -# the native library bar to the natibe library foo. -# -# This test ensures that the ordering of -lfoo and -lbar on the command line is -# correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo' -# library will be stripped out, and the linkage will fail. - -all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(RUSTC) main.rs -Z print-link-args diff --git a/src/test/run-make/interdependent-c-libraries/bar.c b/src/test/run-make/interdependent-c-libraries/bar.c deleted file mode 100644 index c761f029eff..00000000000 --- a/src/test/run-make/interdependent-c-libraries/bar.c +++ /dev/null @@ -1,4 +0,0 @@ -// ignore-license -void foo(); - -void bar() { foo(); } diff --git a/src/test/run-make/interdependent-c-libraries/bar.rs b/src/test/run-make/interdependent-c-libraries/bar.rs deleted file mode 100644 index 1963976b4b0..00000000000 --- a/src/test/run-make/interdependent-c-libraries/bar.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern crate foo; - -#[link(name = "bar", kind = "static")] -extern { - fn bar(); -} - -pub fn doit() { - unsafe { bar(); } -} diff --git a/src/test/run-make/interdependent-c-libraries/foo.c b/src/test/run-make/interdependent-c-libraries/foo.c deleted file mode 100644 index 2895ad473bf..00000000000 --- a/src/test/run-make/interdependent-c-libraries/foo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -void foo() {} diff --git a/src/test/run-make/interdependent-c-libraries/foo.rs b/src/test/run-make/interdependent-c-libraries/foo.rs deleted file mode 100644 index 7a0fe6bb18f..00000000000 --- a/src/test/run-make/interdependent-c-libraries/foo.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "foo", kind = "static")] -extern { - fn foo(); -} - -pub fn doit() { - unsafe { foo(); } -} diff --git a/src/test/run-make/interdependent-c-libraries/main.rs b/src/test/run-make/interdependent-c-libraries/main.rs deleted file mode 100644 index f42e3dd44a9..00000000000 --- a/src/test/run-make/interdependent-c-libraries/main.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; -extern crate bar; - -fn main() { - bar::doit(); -} diff --git a/src/test/run-make/intrinsic-unreachable/Makefile b/src/test/run-make/intrinsic-unreachable/Makefile deleted file mode 100644 index 305e8a7ddc9..00000000000 --- a/src/test/run-make/intrinsic-unreachable/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -ifndef IS_WINDOWS -# The assembly for exit-unreachable.rs should be shorter because it's missing -# (at minimum) a return instruction. - -all: - $(RUSTC) -O --emit asm exit-ret.rs - $(RUSTC) -O --emit asm exit-unreachable.rs - test `wc -l < $(TMPDIR)/exit-unreachable.s` -lt `wc -l < $(TMPDIR)/exit-ret.s` -else -# Because of Windows exception handling, the code is not necessarily any shorter. -# https://github.com/llvm-mirror/llvm/commit/64b2297786f7fd6f5fa24cdd4db0298fbf211466 -all: -endif diff --git a/src/test/run-make/intrinsic-unreachable/exit-ret.rs b/src/test/run-make/intrinsic-unreachable/exit-ret.rs deleted file mode 100644 index 1b8b644dd78..00000000000 --- a/src/test/run-make/intrinsic-unreachable/exit-ret.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(asm)] -#![crate_type="lib"] - -#[deny(unreachable_code)] -pub fn exit(n: usize) -> i32 { - unsafe { - // Pretend this asm is an exit() syscall. - asm!("" :: "r"(n) :: "volatile"); - // Can't actually reach this point, but rustc doesn't know that. - } - // This return value is just here to generate some extra code for a return - // value, making it easier for the test script to detect whether the - // compiler deleted it. - 42 -} diff --git a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs b/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs deleted file mode 100644 index de63809ab66..00000000000 --- a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(asm, core_intrinsics)] -#![crate_type="lib"] - -use std::intrinsics; - -#[allow(unreachable_code)] -pub fn exit(n: usize) -> i32 { - unsafe { - // Pretend this asm is an exit() syscall. - asm!("" :: "r"(n) :: "volatile"); - intrinsics::unreachable() - } - // This return value is just here to generate some extra code for a return - // value, making it easier for the test script to detect whether the - // compiler deleted it. - 42 -} diff --git a/src/test/run-make/invalid-library/Makefile b/src/test/run-make/invalid-library/Makefile deleted file mode 100644 index b6fb122d98b..00000000000 --- a/src/test/run-make/invalid-library/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - touch $(TMPDIR)/rust.metadata.bin - $(AR) crus $(TMPDIR)/libfoo-ffffffff-1.0.rlib $(TMPDIR)/rust.metadata.bin - $(RUSTC) foo.rs 2>&1 | $(CGREP) "can't find crate for" diff --git a/src/test/run-make/invalid-library/foo.rs b/src/test/run-make/invalid-library/foo.rs deleted file mode 100644 index 6316cfa3bba..00000000000 --- a/src/test/run-make/invalid-library/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() {} diff --git a/src/test/run-make/invalid-staticlib/Makefile b/src/test/run-make/invalid-staticlib/Makefile deleted file mode 100644 index 3a91902ccce..00000000000 --- a/src/test/run-make/invalid-staticlib/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - touch $(TMPDIR)/libfoo.a - echo | $(RUSTC) - --crate-type=rlib -lstatic=foo 2>&1 | $(CGREP) "failed to add native library" diff --git a/src/test/run-make/issue-11908/Makefile b/src/test/run-make/issue-11908/Makefile deleted file mode 100644 index cf6572c27ad..00000000000 --- a/src/test/run-make/issue-11908/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# This test ensures that if you have the same rlib or dylib at two locations -# in the same path that you don't hit an assertion in the compiler. -# -# Note that this relies on `liburl` to be in the path somewhere else, -# and then our aux-built libraries will collide with liburl (they have -# the same version listed) - --include ../tools.mk - -all: - mkdir $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic - mv $(call DYLIB,foo) $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=dylib -C prefer-dynamic - $(RUSTC) bar.rs -L $(TMPDIR)/other - rm -rf $(TMPDIR) - mkdir -p $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=rlib - mv $(TMPDIR)/libfoo.rlib $(TMPDIR)/other - $(RUSTC) foo.rs --crate-type=rlib - $(RUSTC) bar.rs -L $(TMPDIR)/other diff --git a/src/test/run-make/issue-11908/bar.rs b/src/test/run-make/issue-11908/bar.rs deleted file mode 100644 index 6316cfa3bba..00000000000 --- a/src/test/run-make/issue-11908/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() {} diff --git a/src/test/run-make/issue-11908/foo.rs b/src/test/run-make/issue-11908/foo.rs deleted file mode 100644 index 0858d3c4e47..00000000000 --- a/src/test/run-make/issue-11908/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] diff --git a/src/test/run-make/issue-14500/Makefile b/src/test/run-make/issue-14500/Makefile deleted file mode 100644 index bd94db09520..00000000000 --- a/src/test/run-make/issue-14500/Makefile +++ /dev/null @@ -1,17 +0,0 @@ --include ../tools.mk - -# Test to make sure that reachable extern fns are always available in final -# productcs, including when LTO is used. In this test, the `foo` crate has a -# reahable symbol, and is a dependency of the `bar` crate. When the `bar` crate -# is compiled with LTO, it shouldn't strip the symbol from `foo`, and that's the -# only way that `foo.c` will successfully compile. - -ifeq ($(UNAME),Bitrig) - EXTRACFLAGS := -lc $(EXTRACFLAGS) $(EXTRACXXFLAGS) -endif - -all: - $(RUSTC) foo.rs --crate-type=rlib - $(RUSTC) bar.rs --crate-type=staticlib -C lto -L. -o $(TMPDIR)/libbar.a - $(CC) foo.c $(TMPDIR)/libbar.a $(EXTRACFLAGS) $(call OUT_EXE,foo) - $(call RUN,foo) diff --git a/src/test/run-make/issue-14500/bar.rs b/src/test/run-make/issue-14500/bar.rs deleted file mode 100644 index 4b4916fe96d..00000000000 --- a/src/test/run-make/issue-14500/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; diff --git a/src/test/run-make/issue-14500/foo.c b/src/test/run-make/issue-14500/foo.c deleted file mode 100644 index e84b5509c50..00000000000 --- a/src/test/run-make/issue-14500/foo.c +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void foo(); -extern char FOO_STATIC; - -int main() { - foo(); - return (int)FOO_STATIC; -} diff --git a/src/test/run-make/issue-14500/foo.rs b/src/test/run-make/issue-14500/foo.rs deleted file mode 100644 index a91d8d6a21d..00000000000 --- a/src/test/run-make/issue-14500/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn foo() {} - -#[no_mangle] -pub static FOO_STATIC: u8 = 0; diff --git a/src/test/run-make/issue-14698/Makefile b/src/test/run-make/issue-14698/Makefile deleted file mode 100644 index dbe8317dbc4..00000000000 --- a/src/test/run-make/issue-14698/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | $(CGREP) "couldn't create a temp dir:" diff --git a/src/test/run-make/issue-14698/foo.rs b/src/test/run-make/issue-14698/foo.rs deleted file mode 100644 index 7dc79f2043b..00000000000 --- a/src/test/run-make/issue-14698/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/issue-15460/Makefile b/src/test/run-make/issue-15460/Makefile deleted file mode 100644 index 846805686a1..00000000000 --- a/src/test/run-make/issue-15460/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) foo.rs -C extra-filename=-383hf8 -C prefer-dynamic - $(RUSTC) bar.rs - $(call RUN,bar) diff --git a/src/test/run-make/issue-15460/bar.rs b/src/test/run-make/issue-15460/bar.rs deleted file mode 100644 index 46777f7fbd2..00000000000 --- a/src/test/run-make/issue-15460/bar.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; -fn main() { - unsafe { foo::foo() } -} diff --git a/src/test/run-make/issue-15460/foo.c b/src/test/run-make/issue-15460/foo.c deleted file mode 100644 index fdf595b574e..00000000000 --- a/src/test/run-make/issue-15460/foo.c +++ /dev/null @@ -1,6 +0,0 @@ -// ignore-license - -#ifdef _WIN32 -__declspec(dllexport) -#endif -void foo() {} diff --git a/src/test/run-make/issue-15460/foo.rs b/src/test/run-make/issue-15460/foo.rs deleted file mode 100644 index 6917fa55579..00000000000 --- a/src/test/run-make/issue-15460/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -#[link(name = "foo", kind = "static")] -extern { - pub fn foo(); -} diff --git a/src/test/run-make/issue-18943/Makefile b/src/test/run-make/issue-18943/Makefile deleted file mode 100644 index bef70a0edaa..00000000000 --- a/src/test/run-make/issue-18943/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -# Regression test for ICE #18943 when compiling as lib - -all: - $(RUSTC) foo.rs --crate-type lib - $(call REMOVE_RLIBS,foo) && exit 0 || exit 1 diff --git a/src/test/run-make/issue-18943/foo.rs b/src/test/run-make/issue-18943/foo.rs deleted file mode 100644 index aadf0f593e7..00000000000 --- a/src/test/run-make/issue-18943/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait Foo { } - -trait Bar { } - -impl<'a> Foo for Bar + 'a { } - diff --git a/src/test/run-make/issue-19371/Makefile b/src/test/run-make/issue-19371/Makefile deleted file mode 100644 index 9f3ec78465b..00000000000 --- a/src/test/run-make/issue-19371/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# This test ensures that rustc compile_input can be called twice in one task -# without causing a panic. -# The program needs the path to rustc to get sysroot. - -all: - $(RUSTC) foo.rs - $(call RUN,foo $(TMPDIR) $(RUSTC)) diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs deleted file mode 100644 index e0db2627d85..00000000000 --- a/src/test/run-make/issue-19371/foo.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_private)] - -extern crate rustc; -extern crate rustc_driver; -extern crate rustc_lint; -extern crate rustc_metadata; -extern crate rustc_errors; -extern crate rustc_trans_utils; -extern crate syntax; - -use rustc::session::{build_session, Session}; -use rustc::session::config::{basic_options, Input, - OutputType, OutputTypes}; -use rustc_driver::driver::{compile_input, CompileController}; -use rustc_metadata::cstore::CStore; -use rustc_errors::registry::Registry; -use syntax::codemap::FileName; -use rustc_trans_utils::trans_crate::TransCrate; - -use std::path::PathBuf; -use std::rc::Rc; - -fn main() { - let src = r#" - fn main() {} - "#; - - let args: Vec = std::env::args().collect(); - - if args.len() < 4 { - panic!("expected rustc path"); - } - - let tmpdir = PathBuf::from(&args[1]); - - let mut sysroot = PathBuf::from(&args[3]); - sysroot.pop(); - sysroot.pop(); - - compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); - - compile(src.to_string(), tmpdir.join("out"), sysroot.clone()); -} - -fn basic_sess(sysroot: PathBuf) -> (Session, Rc, Box) { - let mut opts = basic_options(); - opts.output_types = OutputTypes::new(&[(OutputType::Exe, None)]); - opts.maybe_sysroot = Some(sysroot); - if let Ok(linker) = std::env::var("RUSTC_LINKER") { - opts.cg.linker = Some(linker.into()); - } - - let descriptions = Registry::new(&rustc::DIAGNOSTICS); - let sess = build_session(opts, None, descriptions); - let trans = rustc_driver::get_trans(&sess); - let cstore = Rc::new(CStore::new(trans.metadata_loader())); - rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); - (sess, cstore, trans) -} - -fn compile(code: String, output: PathBuf, sysroot: PathBuf) { - syntax::with_globals(|| { - let (sess, cstore, trans) = basic_sess(sysroot); - let control = CompileController::basic(); - let input = Input::Str { name: FileName::Anon, input: code }; - let _ = compile_input( - trans, - &sess, - &cstore, - &None, - &input, - &None, - &Some(output), - None, - &control - ); - }); -} diff --git a/src/test/run-make/issue-20626/Makefile b/src/test/run-make/issue-20626/Makefile deleted file mode 100644 index 0487b240400..00000000000 --- a/src/test/run-make/issue-20626/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -# Test output to be four -# The original error only occurred when printing, not when comparing using assert! - -all: - $(RUSTC) foo.rs -O - [ `$(call RUN,foo)` = "4" ] diff --git a/src/test/run-make/issue-20626/foo.rs b/src/test/run-make/issue-20626/foo.rs deleted file mode 100644 index 9f727607e4e..00000000000 --- a/src/test/run-make/issue-20626/foo.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn identity(a: &u32) -> &u32 { a } - -fn print_foo(f: &fn(&u32) -> &u32, x: &u32) { - print!("{}", (*f)(x)); -} - -fn main() { - let x = &4; - let f: fn(&u32) -> &u32 = identity; - - // Didn't print 4 on optimized builds - print_foo(&f, x); -} diff --git a/src/test/run-make/issue-22131/Makefile b/src/test/run-make/issue-22131/Makefile deleted file mode 100644 index 6db737a9e72..00000000000 --- a/src/test/run-make/issue-22131/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: foo.rs - $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs - $(RUSTDOC) --test --cfg 'feature="bar"' \ - -L $(TMPDIR) foo.rs |\ - $(CGREP) 'foo.rs - foo (line 11) ... ok' diff --git a/src/test/run-make/issue-22131/foo.rs b/src/test/run-make/issue-22131/foo.rs deleted file mode 100644 index 50c63abc0d4..00000000000 --- a/src/test/run-make/issue-22131/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/// ```rust -/// assert_eq!(foo::foo(), 1); -/// ``` -#[cfg(feature = "bar")] -pub fn foo() -> i32 { 1 } diff --git a/src/test/run-make/issue-24445/Makefile b/src/test/run-make/issue-24445/Makefile deleted file mode 100644 index 2ed971bf7d9..00000000000 --- a/src/test/run-make/issue-24445/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -ifeq ($(UNAME),Linux) -all: - $(RUSTC) foo.rs - $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -o $(TMPDIR)/foo - $(call RUN,foo) - $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -ldl -pie -fPIC -o $(TMPDIR)/foo - $(call RUN,foo) -else -all: -endif diff --git a/src/test/run-make/issue-24445/foo.c b/src/test/run-make/issue-24445/foo.c deleted file mode 100644 index 775e151f236..00000000000 --- a/src/test/run-make/issue-24445/foo.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/issue-24445/foo.rs b/src/test/run-make/issue-24445/foo.rs deleted file mode 100644 index 65e505df5ef..00000000000 --- a/src/test/run-make/issue-24445/foo.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -struct Destroy; -impl Drop for Destroy { - fn drop(&mut self) { println!("drop"); } -} - -thread_local! { - static X: Destroy = Destroy -} - -#[no_mangle] -pub extern "C" fn foo() { - X.with(|_| ()); -} diff --git a/src/test/run-make/issue-25581/Makefile b/src/test/run-make/issue-25581/Makefile deleted file mode 100644 index 042048ec25f..00000000000 --- a/src/test/run-make/issue-25581/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,test) - $(RUSTC) test.rs - $(call RUN,test) || exit 1 diff --git a/src/test/run-make/issue-25581/test.c b/src/test/run-make/issue-25581/test.c deleted file mode 100644 index 5736b173021..00000000000 --- a/src/test/run-make/issue-25581/test.c +++ /dev/null @@ -1,16 +0,0 @@ -// ignore-license -#include -#include - -struct ByteSlice { - uint8_t *data; - size_t len; -}; - -size_t slice_len(struct ByteSlice bs) { - return bs.len; -} - -uint8_t slice_elem(struct ByteSlice bs, size_t idx) { - return bs.data[idx]; -} diff --git a/src/test/run-make/issue-25581/test.rs b/src/test/run-make/issue-25581/test.rs deleted file mode 100644 index 6717d16cb7c..00000000000 --- a/src/test/run-make/issue-25581/test.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(libc)] - -extern crate libc; - -#[link(name = "test", kind = "static")] -extern { - fn slice_len(s: &[u8]) -> libc::size_t; - fn slice_elem(s: &[u8], idx: libc::size_t) -> u8; -} - -fn main() { - let data = [1,2,3,4,5]; - - unsafe { - assert_eq!(data.len(), slice_len(&data) as usize); - assert_eq!(data[0], slice_elem(&data, 0)); - assert_eq!(data[1], slice_elem(&data, 1)); - assert_eq!(data[2], slice_elem(&data, 2)); - assert_eq!(data[3], slice_elem(&data, 3)); - assert_eq!(data[4], slice_elem(&data, 4)); - } -} diff --git a/src/test/run-make/issue-26006/Makefile b/src/test/run-make/issue-26006/Makefile deleted file mode 100644 index 66aa78d5386..00000000000 --- a/src/test/run-make/issue-26006/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -OUT := $(TMPDIR)/out - -ifndef IS_WINDOWS -all: time - -time: libc - mkdir -p $(OUT)/time $(OUT)/time/deps - ln -sf $(OUT)/libc/liblibc.rlib $(OUT)/time/deps/ - $(RUSTC) in/time/lib.rs -Ldependency=$(OUT)/time/deps/ - -libc: - mkdir -p $(OUT)/libc - $(RUSTC) in/libc/lib.rs --crate-name=libc -Cmetadata=foo -o $(OUT)/libc/liblibc.rlib -else -all: -endif diff --git a/src/test/run-make/issue-26006/in/libc/lib.rs b/src/test/run-make/issue-26006/in/libc/lib.rs deleted file mode 100644 index 177ffdce062..00000000000 --- a/src/test/run-make/issue-26006/in/libc/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![crate_type="rlib"] - -pub fn something(){} diff --git a/src/test/run-make/issue-26006/in/time/lib.rs b/src/test/run-make/issue-26006/in/time/lib.rs deleted file mode 100644 index b1d07d57337..00000000000 --- a/src/test/run-make/issue-26006/in/time/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![feature(libc)] -extern crate libc; - -fn main(){} diff --git a/src/test/run-make/issue-26092/Makefile b/src/test/run-make/issue-26092/Makefile deleted file mode 100644 index 27631c31c4a..00000000000 --- a/src/test/run-make/issue-26092/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o "" blank.rs 2>&1 | $(CGREP) -i 'No such file or directory' diff --git a/src/test/run-make/issue-26092/blank.rs b/src/test/run-make/issue-26092/blank.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/issue-26092/blank.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/issue-28595/Makefile b/src/test/run-make/issue-28595/Makefile deleted file mode 100644 index 61e9d0c6547..00000000000 --- a/src/test/run-make/issue-28595/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,a) $(call NATIVE_STATICLIB,b) - $(RUSTC) a.rs - $(RUSTC) b.rs - $(call RUN,b) diff --git a/src/test/run-make/issue-28595/a.c b/src/test/run-make/issue-28595/a.c deleted file mode 100644 index feacd7bc313..00000000000 --- a/src/test/run-make/issue-28595/a.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void a(void) {} diff --git a/src/test/run-make/issue-28595/a.rs b/src/test/run-make/issue-28595/a.rs deleted file mode 100644 index 7377a9f3416..00000000000 --- a/src/test/run-make/issue-28595/a.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "a", kind = "static")] -extern { - pub fn a(); -} diff --git a/src/test/run-make/issue-28595/b.c b/src/test/run-make/issue-28595/b.c deleted file mode 100644 index de81fbcaa60..00000000000 --- a/src/test/run-make/issue-28595/b.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void a(void); - -void b(void) { - a(); -} - diff --git a/src/test/run-make/issue-28595/b.rs b/src/test/run-make/issue-28595/b.rs deleted file mode 100644 index 37ff346c3f3..00000000000 --- a/src/test/run-make/issue-28595/b.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate a; - -#[link(name = "b", kind = "static")] -extern { - pub fn b(); -} - - -fn main() { - unsafe { b(); } -} diff --git a/src/test/run-make/issue-28766/Makefile b/src/test/run-make/issue-28766/Makefile deleted file mode 100644 index 1f47ef15b27..00000000000 --- a/src/test/run-make/issue-28766/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -O foo.rs - $(RUSTC) -O -L $(TMPDIR) main.rs diff --git a/src/test/run-make/issue-28766/foo.rs b/src/test/run-make/issue-28766/foo.rs deleted file mode 100644 index 3ed0a6bfc74..00000000000 --- a/src/test/run-make/issue-28766/foo.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] -pub struct Foo(()); - -impl Foo { - pub fn new() -> Foo { - Foo(()) - } -} diff --git a/src/test/run-make/issue-28766/main.rs b/src/test/run-make/issue-28766/main.rs deleted file mode 100644 index d1dadbdc7ad..00000000000 --- a/src/test/run-make/issue-28766/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] -extern crate foo; -use foo::Foo; - -pub fn crash() -> Box { - Box::new(Foo::new()) -} diff --git a/src/test/run-make/issue-30063/Makefile b/src/test/run-make/issue-30063/Makefile deleted file mode 100644 index a76051dc81e..00000000000 --- a/src/test/run-make/issue-30063/Makefile +++ /dev/null @@ -1,35 +0,0 @@ --include ../tools.mk - -all: - rm -f $(TMPDIR)/foo-output - $(RUSTC) -C codegen-units=4 -o $(TMPDIR)/foo-output foo.rs - rm $(TMPDIR)/foo-output - - rm -f $(TMPDIR)/asm-output - $(RUSTC) -C codegen-units=4 --emit=asm -o $(TMPDIR)/asm-output foo.rs - rm $(TMPDIR)/asm-output - - rm -f $(TMPDIR)/bc-output - $(RUSTC) -C codegen-units=4 --emit=llvm-bc -o $(TMPDIR)/bc-output foo.rs - rm $(TMPDIR)/bc-output - - rm -f $(TMPDIR)/ir-output - $(RUSTC) -C codegen-units=4 --emit=llvm-ir -o $(TMPDIR)/ir-output foo.rs - rm $(TMPDIR)/ir-output - - rm -f $(TMPDIR)/link-output - $(RUSTC) -C codegen-units=4 --emit=link -o $(TMPDIR)/link-output foo.rs - rm $(TMPDIR)/link-output - - rm -f $(TMPDIR)/obj-output - $(RUSTC) -C codegen-units=4 --emit=obj -o $(TMPDIR)/obj-output foo.rs - rm $(TMPDIR)/obj-output - - rm -f $(TMPDIR)/dep-output - $(RUSTC) -C codegen-units=4 --emit=dep-info -o $(TMPDIR)/dep-output foo.rs - rm $(TMPDIR)/dep-output - -# # (This case doesn't work yet, and may be fundamentally wrong-headed anyway.) -# rm -f $(TMPDIR)/multi-output -# $(RUSTC) -C codegen-units=4 --emit=asm,obj -o $(TMPDIR)/multi-output foo.rs -# rm $(TMPDIR)/multi-output diff --git a/src/test/run-make/issue-30063/foo.rs b/src/test/run-make/issue-30063/foo.rs deleted file mode 100644 index 45f7a2c2aa6..00000000000 --- a/src/test/run-make/issue-30063/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/issue-33329/Makefile b/src/test/run-make/issue-33329/Makefile deleted file mode 100644 index 591e4e3dda3..00000000000 --- a/src/test/run-make/issue-33329/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) --target x86_64_unknown-linux-musl main.rs 2>&1 | $(CGREP) \ - "error: Error loading target specification: Could not find specification for target" diff --git a/src/test/run-make/issue-33329/main.rs b/src/test/run-make/issue-33329/main.rs deleted file mode 100644 index e06c0a5ec2a..00000000000 --- a/src/test/run-make/issue-33329/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/issue-35164/Makefile b/src/test/run-make/issue-35164/Makefile deleted file mode 100644 index 6a451656dcb..00000000000 --- a/src/test/run-make/issue-35164/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) main.rs --error-format json 2>&1 | $(CGREP) -e '"byte_start":490\b' '"byte_end":496\b' diff --git a/src/test/run-make/issue-35164/main.rs b/src/test/run-make/issue-35164/main.rs deleted file mode 100644 index 24322a2484f..00000000000 --- a/src/test/run-make/issue-35164/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod submodule; - -fn main() { - submodule::foo(); -} diff --git a/src/test/run-make/issue-35164/submodule/mod.rs b/src/test/run-make/issue-35164/submodule/mod.rs deleted file mode 100644 index 7847c13af78..00000000000 --- a/src/test/run-make/issue-35164/submodule/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn foo() { - let _MyFoo = 2; -} diff --git a/src/test/run-make/issue-37839/Makefile b/src/test/run-make/issue-37839/Makefile deleted file mode 100644 index 8b3355b9622..00000000000 --- a/src/test/run-make/issue-37839/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) a.rs && $(RUSTC) b.rs - $(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \ - --out-dir=$(TMPDIR) -endif diff --git a/src/test/run-make/issue-37839/a.rs b/src/test/run-make/issue-37839/a.rs deleted file mode 100644 index 052317438c2..00000000000 --- a/src/test/run-make/issue-37839/a.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] -#![crate_type = "proc-macro"] diff --git a/src/test/run-make/issue-37839/b.rs b/src/test/run-make/issue-37839/b.rs deleted file mode 100644 index 82f48f6d8d6..00000000000 --- a/src/test/run-make/issue-37839/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#[macro_use] extern crate a; diff --git a/src/test/run-make/issue-37839/c.rs b/src/test/run-make/issue-37839/c.rs deleted file mode 100644 index 85bece51427..00000000000 --- a/src/test/run-make/issue-37839/c.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -extern crate b; diff --git a/src/test/run-make/issue-37893/Makefile b/src/test/run-make/issue-37893/Makefile deleted file mode 100644 index c7732cc2682..00000000000 --- a/src/test/run-make/issue-37893/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs -endif diff --git a/src/test/run-make/issue-37893/a.rs b/src/test/run-make/issue-37893/a.rs deleted file mode 100644 index 052317438c2..00000000000 --- a/src/test/run-make/issue-37893/a.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused)] -#![crate_type = "proc-macro"] diff --git a/src/test/run-make/issue-37893/b.rs b/src/test/run-make/issue-37893/b.rs deleted file mode 100644 index 82f48f6d8d6..00000000000 --- a/src/test/run-make/issue-37893/b.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#[macro_use] extern crate a; diff --git a/src/test/run-make/issue-37893/c.rs b/src/test/run-make/issue-37893/c.rs deleted file mode 100644 index eee55cc2369..00000000000 --- a/src/test/run-make/issue-37893/c.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] -extern crate b; -extern crate a; diff --git a/src/test/run-make/issue-38237/Makefile b/src/test/run-make/issue-38237/Makefile deleted file mode 100644 index 855d958b344..00000000000 --- a/src/test/run-make/issue-38237/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) foo.rs; $(RUSTC) bar.rs - $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR) -endif diff --git a/src/test/run-make/issue-38237/bar.rs b/src/test/run-make/issue-38237/bar.rs deleted file mode 100644 index 794e08c2fe3..00000000000 --- a/src/test/run-make/issue-38237/bar.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -#[derive(Debug)] -pub struct S; diff --git a/src/test/run-make/issue-38237/baz.rs b/src/test/run-make/issue-38237/baz.rs deleted file mode 100644 index c2a2c89db01..00000000000 --- a/src/test/run-make/issue-38237/baz.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; -extern crate bar; - -pub struct Bar; -impl ::std::ops::Deref for Bar { - type Target = bar::S; - fn deref(&self) -> &Self::Target { unimplemented!() } -} diff --git a/src/test/run-make/issue-38237/foo.rs b/src/test/run-make/issue-38237/foo.rs deleted file mode 100644 index 6fb315731de..00000000000 --- a/src/test/run-make/issue-38237/foo.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -#[proc_macro_derive(A)] -pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts } - -#[derive(Debug)] -struct S; diff --git a/src/test/run-make/issue-40535/Makefile b/src/test/run-make/issue-40535/Makefile deleted file mode 100644 index 49db1d43e47..00000000000 --- a/src/test/run-make/issue-40535/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# The ICE occurred in the following situation: -# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`) -# * `bar` declares and depends on `extern crate baz` -# * All crates built in metadata-only mode (`cargo check`) -all: - # cc https://github.com/rust-lang/rust/issues/40623 - $(RUSTC) baz.rs --emit=metadata - $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta - $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \ - $(CGREP) -v "unexpectedly panicked" - # ^ Succeeds if it doesn't find the ICE message diff --git a/src/test/run-make/issue-40535/bar.rs b/src/test/run-make/issue-40535/bar.rs deleted file mode 100644 index 4c22f181975..00000000000 --- a/src/test/run-make/issue-40535/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -extern crate baz; diff --git a/src/test/run-make/issue-40535/baz.rs b/src/test/run-make/issue-40535/baz.rs deleted file mode 100644 index 737a918a039..00000000000 --- a/src/test/run-make/issue-40535/baz.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/issue-40535/foo.rs b/src/test/run-make/issue-40535/foo.rs deleted file mode 100644 index 53a8c8636b1..00000000000 --- a/src/test/run-make/issue-40535/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] - -extern crate bar; -extern crate baz; diff --git a/src/test/run-make/issue-46239/Makefile b/src/test/run-make/issue-46239/Makefile deleted file mode 100644 index 698a605f7e9..00000000000 --- a/src/test/run-make/issue-46239/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) main.rs -C opt-level=1 - $(call RUN,main) diff --git a/src/test/run-make/issue-46239/main.rs b/src/test/run-make/issue-46239/main.rs deleted file mode 100644 index 3b3289168ab..00000000000 --- a/src/test/run-make/issue-46239/main.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn project(x: &(T,)) -> &T { &x.0 } - -fn dummy() {} - -fn main() { - let f = (dummy as fn(),); - (*project(&f))(); -} diff --git a/src/test/run-make/issue-7349/Makefile b/src/test/run-make/issue-7349/Makefile deleted file mode 100644 index 50dc63b1deb..00000000000 --- a/src/test/run-make/issue-7349/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Test to make sure that inner functions within a polymorphic outer function -# don't get re-translated when the outer function is monomorphized. The test -# code monomorphizes the outer functions several times, but the magic constants -# used in the inner functions should each appear only once in the generated IR. - -all: - $(RUSTC) foo.rs --emit=llvm-ir - [ "$$(grep -c 'ret i32 8675309' "$(TMPDIR)/foo.ll")" -eq "1" ] - [ "$$(grep -c 'ret i32 11235813' "$(TMPDIR)/foo.ll")" -eq "1" ] diff --git a/src/test/run-make/issue-7349/foo.rs b/src/test/run-make/issue-7349/foo.rs deleted file mode 100644 index b75c82afb53..00000000000 --- a/src/test/run-make/issue-7349/foo.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn outer() { - #[allow(dead_code)] - fn inner() -> u32 { - 8675309 - } - inner(); -} - -extern "C" fn outer_foreign() { - #[allow(dead_code)] - fn inner() -> u32 { - 11235813 - } - inner(); -} - -fn main() { - outer::(); - outer::(); - outer_foreign::(); - outer_foreign::(); -} diff --git a/src/test/run-make/issues-41478-43796/Makefile b/src/test/run-make/issues-41478-43796/Makefile deleted file mode 100644 index f9735253ab6..00000000000 --- a/src/test/run-make/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/src/test/run-make/issues-41478-43796/a.rs b/src/test/run-make/issues-41478-43796/a.rs deleted file mode 100644 index 9d95f8b2585..00000000000 --- a/src/test/run-make/issues-41478-43796/a.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -pub struct V(S); -pub trait An { - type U; -} -pub trait F { -} -impl F for V<::U> { -} diff --git a/src/test/run-make/libs-and-bins/Makefile b/src/test/run-make/libs-and-bins/Makefile deleted file mode 100644 index cc3b257a5c5..00000000000 --- a/src/test/run-make/libs-and-bins/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs - $(call RUN,foo) - rm $(TMPDIR)/$(call DYLIB_GLOB,foo) diff --git a/src/test/run-make/libs-and-bins/foo.rs b/src/test/run-make/libs-and-bins/foo.rs deleted file mode 100644 index 2ebe63928ca..00000000000 --- a/src/test/run-make/libs-and-bins/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -#![crate_type = "bin"] - -fn main() {} diff --git a/src/test/run-make/libs-through-symlinks/Makefile b/src/test/run-make/libs-through-symlinks/Makefile deleted file mode 100644 index 2f425121f66..00000000000 --- a/src/test/run-make/libs-through-symlinks/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -ifdef IS_WINDOWS -all: -else - -NAME := $(shell $(RUSTC) --print file-names foo.rs) - -all: - mkdir -p $(TMPDIR)/outdir - $(RUSTC) foo.rs -o $(TMPDIR)/outdir/$(NAME) - ln -nsf outdir/$(NAME) $(TMPDIR) - RUST_LOG=rustc_metadata::loader $(RUSTC) bar.rs -endif diff --git a/src/test/run-make/libs-through-symlinks/bar.rs b/src/test/run-make/libs-through-symlinks/bar.rs deleted file mode 100644 index 6316cfa3bba..00000000000 --- a/src/test/run-make/libs-through-symlinks/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() {} diff --git a/src/test/run-make/libs-through-symlinks/foo.rs b/src/test/run-make/libs-through-symlinks/foo.rs deleted file mode 100644 index dd818cf8798..00000000000 --- a/src/test/run-make/libs-through-symlinks/foo.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_name = "foo"] diff --git a/src/test/run-make/libtest-json/Makefile b/src/test/run-make/libtest-json/Makefile deleted file mode 100644 index ec91ddfb9f9..00000000000 --- a/src/test/run-make/libtest-json/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# Test expected libtest's JSON output - -OUTPUT_FILE := $(TMPDIR)/libtest-json-output.json - -all: - $(RUSTC) --test f.rs - $(call RUN,f) -Z unstable-options --test-threads=1 --format=json > $(OUTPUT_FILE) || true - - cat $(OUTPUT_FILE) | "$(PYTHON)" validate_json.py - - # Compare to output file - diff output.json $(OUTPUT_FILE) diff --git a/src/test/run-make/libtest-json/f.rs b/src/test/run-make/libtest-json/f.rs deleted file mode 100644 index 5cff1f1a5b1..00000000000 --- a/src/test/run-make/libtest-json/f.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[test] -fn a() { - // Should pass -} - -#[test] -fn b() { - assert!(false) -} - -#[test] -#[should_panic] -fn c() { - assert!(false); -} - -#[test] -#[ignore] -fn d() { - assert!(false); -} - diff --git a/src/test/run-make/libtest-json/output.json b/src/test/run-make/libtest-json/output.json deleted file mode 100644 index 235f8cd7c72..00000000000 --- a/src/test/run-make/libtest-json/output.json +++ /dev/null @@ -1,10 +0,0 @@ -{ "type": "suite", "event": "started", "test_count": "4" } -{ "type": "test", "event": "started", "name": "a" } -{ "type": "test", "name": "a", "event": "ok" } -{ "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:18:5\nnote: Run with `RUST_BACKTRACE=1` for a backtrace.\n" } -{ "type": "test", "event": "started", "name": "c" } -{ "type": "test", "name": "c", "event": "ok" } -{ "type": "test", "event": "started", "name": "d" } -{ "type": "test", "name": "d", "event": "ignored" } -{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "allowed_fail": 0, "ignored": 1, "measured": 0, "filtered_out": "0" } diff --git a/src/test/run-make/libtest-json/validate_json.py b/src/test/run-make/libtest-json/validate_json.py deleted file mode 100755 index 1e97639b524..00000000000 --- a/src/test/run-make/libtest-json/validate_json.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -import sys -import json - -# Try to decode line in order to ensure it is a valid JSON document -for line in sys.stdin: - json.loads(line) diff --git a/src/test/run-make/link-arg/Makefile b/src/test/run-make/link-arg/Makefile deleted file mode 100644 index d7c9fd27112..00000000000 --- a/src/test/run-make/link-arg/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk -RUSTC_FLAGS = -C link-arg="-lfoo" -C link-arg="-lbar" -Z print-link-args - -all: - $(RUSTC) $(RUSTC_FLAGS) empty.rs | $(CGREP) lfoo lbar diff --git a/src/test/run-make/link-arg/empty.rs b/src/test/run-make/link-arg/empty.rs deleted file mode 100644 index 2b76fb24e5f..00000000000 --- a/src/test/run-make/link-arg/empty.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/link-cfg/Makefile b/src/test/run-make/link-cfg/Makefile deleted file mode 100644 index 188cba5fe41..00000000000 --- a/src/test/run-make/link-cfg/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -all: $(call DYLIB,return1) $(call DYLIB,return2) $(call NATIVE_STATICLIB,return3) - ls $(TMPDIR) - $(RUSTC) --print cfg --target x86_64-unknown-linux-musl | $(CGREP) crt-static - - $(RUSTC) no-deps.rs --cfg foo - $(call RUN,no-deps) - $(RUSTC) no-deps.rs --cfg bar - $(call RUN,no-deps) - - $(RUSTC) dep.rs - $(RUSTC) with-deps.rs --cfg foo - $(call RUN,with-deps) - $(RUSTC) with-deps.rs --cfg bar - $(call RUN,with-deps) - - $(RUSTC) dep-with-staticlib.rs - $(RUSTC) with-staticlib-deps.rs --cfg foo - $(call RUN,with-staticlib-deps) - $(RUSTC) with-staticlib-deps.rs --cfg bar - $(call RUN,with-staticlib-deps) diff --git a/src/test/run-make/link-cfg/dep-with-staticlib.rs b/src/test/run-make/link-cfg/dep-with-staticlib.rs deleted file mode 100644 index ecc2365ddb0..00000000000 --- a/src/test/run-make/link-cfg/dep-with-staticlib.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(link_cfg)] -#![crate_type = "rlib"] - -#[link(name = "return1", cfg(foo))] -#[link(name = "return3", kind = "static", cfg(bar))] -extern { - pub fn my_function() -> i32; -} diff --git a/src/test/run-make/link-cfg/dep.rs b/src/test/run-make/link-cfg/dep.rs deleted file mode 100644 index 7da879c2bfa..00000000000 --- a/src/test/run-make/link-cfg/dep.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(link_cfg)] -#![crate_type = "rlib"] - -#[link(name = "return1", cfg(foo))] -#[link(name = "return2", cfg(bar))] -extern { - pub fn my_function() -> i32; -} diff --git a/src/test/run-make/link-cfg/no-deps.rs b/src/test/run-make/link-cfg/no-deps.rs deleted file mode 100644 index 6b114106744..00000000000 --- a/src/test/run-make/link-cfg/no-deps.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(link_cfg)] - -#[link(name = "return1", cfg(foo))] -#[link(name = "return2", cfg(bar))] -extern { - fn my_function() -> i32; -} - -fn main() { - unsafe { - let v = my_function(); - if cfg!(foo) { - assert_eq!(v, 1); - } else if cfg!(bar) { - assert_eq!(v, 2); - } else { - panic!("unknown"); - } - } -} diff --git a/src/test/run-make/link-cfg/return1.c b/src/test/run-make/link-cfg/return1.c deleted file mode 100644 index a2a3d051dd1..00000000000 --- a/src/test/run-make/link-cfg/return1.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int my_function() { - return 1; -} diff --git a/src/test/run-make/link-cfg/return2.c b/src/test/run-make/link-cfg/return2.c deleted file mode 100644 index d6ddcccf2fb..00000000000 --- a/src/test/run-make/link-cfg/return2.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int my_function() { - return 2; -} diff --git a/src/test/run-make/link-cfg/return3.c b/src/test/run-make/link-cfg/return3.c deleted file mode 100644 index 6a3b695f208..00000000000 --- a/src/test/run-make/link-cfg/return3.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifdef _WIN32 -__declspec(dllexport) -#endif -int my_function() { - return 3; -} diff --git a/src/test/run-make/link-cfg/with-deps.rs b/src/test/run-make/link-cfg/with-deps.rs deleted file mode 100644 index 799555c500a..00000000000 --- a/src/test/run-make/link-cfg/with-deps.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dep; - -fn main() { - unsafe { - let v = dep::my_function(); - if cfg!(foo) { - assert_eq!(v, 1); - } else if cfg!(bar) { - assert_eq!(v, 2); - } else { - panic!("unknown"); - } - } -} diff --git a/src/test/run-make/link-cfg/with-staticlib-deps.rs b/src/test/run-make/link-cfg/with-staticlib-deps.rs deleted file mode 100644 index 33a9c7720e2..00000000000 --- a/src/test/run-make/link-cfg/with-staticlib-deps.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dep_with_staticlib; - -fn main() { - unsafe { - let v = dep_with_staticlib::my_function(); - if cfg!(foo) { - assert_eq!(v, 1); - } else if cfg!(bar) { - assert_eq!(v, 3); - } else { - panic!("unknown"); - } - } -} diff --git a/src/test/run-make/link-path-order/Makefile b/src/test/run-make/link-path-order/Makefile deleted file mode 100644 index eeea0e3714e..00000000000 --- a/src/test/run-make/link-path-order/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -# Verifies that the -L arguments given to the linker is in the same order -# as the -L arguments on the rustc command line. - -CORRECT_DIR=$(TMPDIR)/correct -WRONG_DIR=$(TMPDIR)/wrong - -F := $(call NATIVE_STATICLIB_FILE,foo) - -all: $(call NATIVE_STATICLIB,correct) $(call NATIVE_STATICLIB,wrong) - mkdir -p $(CORRECT_DIR) $(WRONG_DIR) - mv $(call NATIVE_STATICLIB,correct) $(CORRECT_DIR)/$(F) - mv $(call NATIVE_STATICLIB,wrong) $(WRONG_DIR)/$(F) - $(RUSTC) main.rs -o $(TMPDIR)/should_succeed -L $(CORRECT_DIR) -L $(WRONG_DIR) - $(call RUN,should_succeed) - $(RUSTC) main.rs -o $(TMPDIR)/should_fail -L $(WRONG_DIR) -L $(CORRECT_DIR) - $(call FAIL,should_fail) diff --git a/src/test/run-make/link-path-order/correct.c b/src/test/run-make/link-path-order/correct.c deleted file mode 100644 index a595939f92e..00000000000 --- a/src/test/run-make/link-path-order/correct.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int should_return_one() { return 1; } diff --git a/src/test/run-make/link-path-order/main.rs b/src/test/run-make/link-path-order/main.rs deleted file mode 100644 index aaac3927f1c..00000000000 --- a/src/test/run-make/link-path-order/main.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(libc, exit_status)] - -extern crate libc; - -#[link(name="foo", kind = "static")] -extern { - fn should_return_one() -> libc::c_int; -} - -fn main() { - let result = unsafe { - should_return_one() - }; - - if result != 1 { - std::process::exit(255); - } -} diff --git a/src/test/run-make/link-path-order/wrong.c b/src/test/run-make/link-path-order/wrong.c deleted file mode 100644 index c53e7e3c48c..00000000000 --- a/src/test/run-make/link-path-order/wrong.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -int should_return_one() { return 0; } diff --git a/src/test/run-make/linkage-attr-on-static/Makefile b/src/test/run-make/linkage-attr-on-static/Makefile deleted file mode 100644 index 4befbe14465..00000000000 --- a/src/test/run-make/linkage-attr-on-static/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) bar.rs - $(call RUN,bar) || exit 1 diff --git a/src/test/run-make/linkage-attr-on-static/bar.rs b/src/test/run-make/linkage-attr-on-static/bar.rs deleted file mode 100644 index 274401c448b..00000000000 --- a/src/test/run-make/linkage-attr-on-static/bar.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(linkage)] - -#[no_mangle] -#[linkage = "external"] -static BAZ: i32 = 21; - -#[link(name = "foo", kind = "static")] -extern { - fn what() -> i32; -} - -fn main() { - unsafe { - assert_eq!(what(), BAZ); - } -} diff --git a/src/test/run-make/linkage-attr-on-static/foo.c b/src/test/run-make/linkage-attr-on-static/foo.c deleted file mode 100644 index d7d33ea12e8..00000000000 --- a/src/test/run-make/linkage-attr-on-static/foo.c +++ /dev/null @@ -1,8 +0,0 @@ -// ignore-license -#include - -extern int32_t BAZ; - -int32_t what() { - return BAZ; -} diff --git a/src/test/run-make/linker-output-non-utf8/Makefile b/src/test/run-make/linker-output-non-utf8/Makefile deleted file mode 100644 index 5f1577ab44d..00000000000 --- a/src/test/run-make/linker-output-non-utf8/Makefile +++ /dev/null @@ -1,32 +0,0 @@ --include ../tools.mk - -# Make sure we don't ICE if the linker prints a non-UTF-8 error message. - -# Ignore Windows and Apple - -# This does not work in its current form on windows, possibly due to -# gcc bugs or something about valid Windows paths. See issue #29151 -# for more information. -ifndef IS_WINDOWS - -# This also does not work on Apple APFS due to the filesystem requiring -# valid UTF-8 paths. -ifneq ($(shell uname),Darwin) - -# The zzz it to allow humans to tab complete or glob this thing. -bad_dir := $(TMPDIR)/zzz$$'\xff' - -all: - $(RUSTC) library.rs - mkdir $(bad_dir) - mv $(TMPDIR)/liblibrary.a $(bad_dir) - LIBRARY_PATH=$(bad_dir) $(RUSTC) exec.rs 2>&1 | $(CGREP) this_symbol_not_defined -else -all: - -endif - -else -all: - -endif diff --git a/src/test/run-make/linker-output-non-utf8/exec.rs b/src/test/run-make/linker-output-non-utf8/exec.rs deleted file mode 100644 index 1c03eb479fd..00000000000 --- a/src/test/run-make/linker-output-non-utf8/exec.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name="library")] -extern "C" { - fn foo(); -} - -fn main() { unsafe { foo(); } } diff --git a/src/test/run-make/linker-output-non-utf8/library.rs b/src/test/run-make/linker-output-non-utf8/library.rs deleted file mode 100644 index 194be26424a..00000000000 --- a/src/test/run-make/linker-output-non-utf8/library.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -extern "C" { - fn this_symbol_not_defined(); -} - -#[no_mangle] -pub extern "C" fn foo() { - unsafe { this_symbol_not_defined(); } -} diff --git a/src/test/run-make/llvm-pass/Makefile b/src/test/run-make/llvm-pass/Makefile deleted file mode 100644 index 8a18aadf36a..00000000000 --- a/src/test/run-make/llvm-pass/Makefile +++ /dev/null @@ -1,28 +0,0 @@ --include ../tools.mk - -ifeq ($(UNAME),Darwin) -PLUGIN_FLAGS := -C link-args=-Wl,-undefined,dynamic_lookup -endif - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -# Windows doesn't correctly handle include statements with escaping paths, -# so this test will not get run on Windows. -ifdef IS_WINDOWS -all: -else -all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass) - $(RUSTC) plugin.rs -C prefer-dynamic $(PLUGIN_FLAGS) - $(RUSTC) main.rs - -$(TMPDIR)/libllvm-function-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o - -$(TMPDIR)/libllvm-module-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o -endif - -endif diff --git a/src/test/run-make/llvm-pass/llvm-function-pass.so.cc b/src/test/run-make/llvm-pass/llvm-function-pass.so.cc deleted file mode 100644 index 880c9bce562..00000000000 --- a/src/test/run-make/llvm-pass/llvm-function-pass.so.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include -#include - -#include "llvm/Pass.h" -#include "llvm/IR/Function.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public FunctionPass { - - public: - - static char ID; - TestLLVMPass() : FunctionPass(ID) { } - - bool runOnFunction(Function &F) override; - -#if LLVM_VERSION_MAJOR >= 4 - StringRef -#else - const char * -#endif - getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnFunction(Function &F) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto N = F.begin(); N != F.end(); ++N) { - /* code */ - } - - LLVMContext &C = F.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-function-pass", "Some LLVM pass"); diff --git a/src/test/run-make/llvm-pass/llvm-module-pass.so.cc b/src/test/run-make/llvm-pass/llvm-module-pass.so.cc deleted file mode 100644 index 280eca7e8f0..00000000000 --- a/src/test/run-make/llvm-pass/llvm-module-pass.so.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include -#include - -#include "llvm/IR/Module.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public ModulePass { - - public: - - static char ID; - TestLLVMPass() : ModulePass(ID) { } - - bool runOnModule(Module &M) override; - -#if LLVM_VERSION_MAJOR >= 4 - StringRef -#else - const char * -#endif - getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnModule(Module &M) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto F = M.begin(); F != M.end(); ++F) { - /* code */ - } - - LLVMContext &C = M.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-module-pass", "Some LLVM pass"); diff --git a/src/test/run-make/llvm-pass/main.rs b/src/test/run-make/llvm-pass/main.rs deleted file mode 100644 index 5b5ab94bcef..00000000000 --- a/src/test/run-make/llvm-pass/main.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(plugin)] -#![plugin(some_plugin)] - -fn main() {} diff --git a/src/test/run-make/llvm-pass/plugin.rs b/src/test/run-make/llvm-pass/plugin.rs deleted file mode 100644 index f77b2fca857..00000000000 --- a/src/test/run-make/llvm-pass/plugin.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(plugin_registrar, rustc_private)] -#![crate_type = "dylib"] -#![crate_name = "some_plugin"] - -extern crate rustc; -extern crate rustc_plugin; - -#[link(name = "llvm-function-pass", kind = "static")] -#[link(name = "llvm-module-pass", kind = "static")] -extern {} - -use rustc_plugin::registry::Registry; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_llvm_pass("some-llvm-function-pass"); - reg.register_llvm_pass("some-llvm-module-pass"); -} diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/Makefile b/src/test/run-make/long-linker-command-lines-cmd-exe/Makefile deleted file mode 100644 index debe9e93824..00000000000 --- a/src/test/run-make/long-linker-command-lines-cmd-exe/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -g - cp foo.bat $(TMPDIR)/ - OUT_DIR="$(TMPDIR)" RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat deleted file mode 100644 index a9350f12bbb..00000000000 --- a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.bat +++ /dev/null @@ -1 +0,0 @@ -%MY_LINKER% %* diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs deleted file mode 100644 index 67d8ad0b672..00000000000 --- a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Like the `long-linker-command-lines` test this test attempts to blow -// a command line limit for running the linker. Unlike that test, however, -// this test is testing `cmd.exe` specifically rather than the OS. -// -// Unfortunately `cmd.exe` has a 8192 limit which is relatively small -// in the grand scheme of things and anyone sripting rustc's linker -// is probably using a `*.bat` script and is likely to hit this limit. -// -// This test uses a `foo.bat` script as the linker which just simply -// delegates back to this program. The compiler should use a lower -// limit for arguments before passing everything via `@`, which -// means that everything should still succeed here. - -use std::env; -use std::fs::{self, File}; -use std::io::{BufWriter, Write, Read}; -use std::path::PathBuf; -use std::process::Command; - -fn main() { - if !cfg!(windows) { - return - } - - let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); - let ok = tmpdir.join("ok"); - let not_ok = tmpdir.join("not_ok"); - if env::var("YOU_ARE_A_LINKER").is_ok() { - match env::args_os().find(|a| a.to_string_lossy().contains("@")) { - Some(file) => { - let file = file.to_str().unwrap(); - fs::copy(&file[1..], &ok).unwrap(); - } - None => { File::create(¬_ok).unwrap(); } - } - return - } - - let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); - let me = env::current_exe().unwrap(); - let bat = me.parent() - .unwrap() - .join("foo.bat"); - let bat_linker = format!("linker={}", bat.display()); - for i in (1..).map(|i| i * 10) { - println!("attempt: {}", i); - - let file = tmpdir.join("bar.rs"); - let mut f = BufWriter::new(File::create(&file).unwrap()); - let mut lib_name = String::new(); - for _ in 0..i { - lib_name.push_str("foo"); - } - for j in 0..i { - writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); - } - writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); - f.into_inner().unwrap(); - - drop(fs::remove_file(&ok)); - drop(fs::remove_file(¬_ok)); - let status = Command::new(&rustc) - .arg(&file) - .arg("-C").arg(&bat_linker) - .arg("--out-dir").arg(&tmpdir) - .env("YOU_ARE_A_LINKER", "1") - .env("MY_LINKER", &me) - .status() - .unwrap(); - - if !status.success() { - panic!("rustc didn't succeed: {}", status); - } - - if !ok.exists() { - assert!(not_ok.exists()); - continue - } - - let mut contents = Vec::new(); - File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); - - for j in 0..i { - let exp = format!("{}{}", lib_name, j); - let exp = if cfg!(target_env = "msvc") { - let mut out = Vec::with_capacity(exp.len() * 2); - for c in exp.encode_utf16() { - // encode in little endian - out.push(c as u8); - out.push((c >> 8) as u8); - } - out - } else { - exp.into_bytes() - }; - assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); - } - - break - } -} diff --git a/src/test/run-make/long-linker-command-lines/Makefile b/src/test/run-make/long-linker-command-lines/Makefile deleted file mode 100644 index 5876fbc94bc..00000000000 --- a/src/test/run-make/long-linker-command-lines/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -g -O - RUSTC="$(RUSTC_ORIGINAL)" $(call RUN,foo) diff --git a/src/test/run-make/long-linker-command-lines/foo.rs b/src/test/run-make/long-linker-command-lines/foo.rs deleted file mode 100644 index 2ac240982af..00000000000 --- a/src/test/run-make/long-linker-command-lines/foo.rs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This is a test which attempts to blow out the system limit with how many -// arguments can be passed to a process. This'll successively call rustc with -// larger and larger argument lists in an attempt to find one that's way too -// big for the system at hand. This file itself is then used as a "linker" to -// detect when the process creation succeeds. -// -// Eventually we should see an argument that looks like `@` as we switch from -// passing literal arguments to passing everything in the file. - -use std::env; -use std::fs::{self, File}; -use std::io::{BufWriter, Write, Read}; -use std::path::PathBuf; -use std::process::Command; - -fn main() { - let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap()); - let ok = tmpdir.join("ok"); - if env::var("YOU_ARE_A_LINKER").is_ok() { - if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) { - let file = file.to_str().expect("non-utf8 file argument"); - fs::copy(&file[1..], &ok).unwrap(); - } - return - } - - let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); - let me_as_linker = format!("linker={}", env::current_exe().unwrap().display()); - for i in (1..).map(|i| i * 100) { - println!("attempt: {}", i); - let file = tmpdir.join("bar.rs"); - let mut f = BufWriter::new(File::create(&file).unwrap()); - let mut lib_name = String::new(); - for _ in 0..i { - lib_name.push_str("foo"); - } - for j in 0..i { - writeln!(f, "#[link(name = \"{}{}\")]", lib_name, j).unwrap(); - } - writeln!(f, "extern {{}}\nfn main() {{}}").unwrap(); - f.into_inner().unwrap(); - - drop(fs::remove_file(&ok)); - let output = Command::new(&rustc) - .arg(&file) - .arg("-C").arg(&me_as_linker) - .arg("--out-dir").arg(&tmpdir) - .env("YOU_ARE_A_LINKER", "1") - .output() - .unwrap(); - - if !output.status.success() { - let stderr = String::from_utf8_lossy(&output.stderr); - panic!("status: {}\nstdout:\n{}\nstderr:\n{}", - output.status, - String::from_utf8_lossy(&output.stdout), - stderr.lines().map(|l| { - if l.len() > 200 { - format!("{}...\n", &l[..200]) - } else { - format!("{}\n", l) - } - }).collect::()); - } - - if !ok.exists() { - continue - } - - let mut contents = Vec::new(); - File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); - - for j in 0..i { - let exp = format!("{}{}", lib_name, j); - let exp = if cfg!(target_env = "msvc") { - let mut out = Vec::with_capacity(exp.len() * 2); - for c in exp.encode_utf16() { - // encode in little endian - out.push(c as u8); - out.push((c >> 8) as u8); - } - out - } else { - exp.into_bytes() - }; - assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); - } - - break - } -} diff --git a/src/test/run-make/longjmp-across-rust/Makefile b/src/test/run-make/longjmp-across-rust/Makefile deleted file mode 100644 index 9d71ed8fcf3..00000000000 --- a/src/test/run-make/longjmp-across-rust/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) - $(RUSTC) main.rs - $(call RUN,main) diff --git a/src/test/run-make/longjmp-across-rust/foo.c b/src/test/run-make/longjmp-across-rust/foo.c deleted file mode 100644 index eb993957674..00000000000 --- a/src/test/run-make/longjmp-across-rust/foo.c +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include - -static jmp_buf ENV; - -extern void test_middle(); - -void test_start(void(*f)()) { - if (setjmp(ENV) != 0) - return; - f(); - assert(0); -} - -void test_end() { - longjmp(ENV, 1); - assert(0); -} diff --git a/src/test/run-make/longjmp-across-rust/main.rs b/src/test/run-make/longjmp-across-rust/main.rs deleted file mode 100644 index c420473a560..00000000000 --- a/src/test/run-make/longjmp-across-rust/main.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "foo", kind = "static")] -extern { - fn test_start(f: extern fn()); - fn test_end(); -} - -fn main() { - unsafe { - test_start(test_middle); - } -} - -struct A; - -impl Drop for A { - fn drop(&mut self) { - } -} - -extern fn test_middle() { - let _a = A; - foo(); -} - -fn foo() { - let _a = A; - unsafe { - test_end(); - } -} diff --git a/src/test/run-make/ls-metadata/Makefile b/src/test/run-make/ls-metadata/Makefile deleted file mode 100644 index fc3f5bce0cd..00000000000 --- a/src/test/run-make/ls-metadata/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs - $(RUSTC) -Z ls $(TMPDIR)/foo - touch $(TMPDIR)/bar - $(RUSTC) -Z ls $(TMPDIR)/bar diff --git a/src/test/run-make/ls-metadata/foo.rs b/src/test/run-make/ls-metadata/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/ls-metadata/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/lto-no-link-whole-rlib/Makefile b/src/test/run-make/lto-no-link-whole-rlib/Makefile deleted file mode 100644 index 1d45cb413c5..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2016 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - --include ../tools.mk - -all: $(call NATIVE_STATICLIB,foo) $(call NATIVE_STATICLIB,bar) - $(RUSTC) lib1.rs - $(RUSTC) lib2.rs - $(RUSTC) main.rs -Clto - $(call RUN,main) - diff --git a/src/test/run-make/lto-no-link-whole-rlib/bar.c b/src/test/run-make/lto-no-link-whole-rlib/bar.c deleted file mode 100644 index 716d1abcf34..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/bar.c +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -int foo() { - return 2; -} diff --git a/src/test/run-make/lto-no-link-whole-rlib/foo.c b/src/test/run-make/lto-no-link-whole-rlib/foo.c deleted file mode 100644 index 1b36874581a..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/foo.c +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -int foo() { - return 1; -} diff --git a/src/test/run-make/lto-no-link-whole-rlib/lib1.rs b/src/test/run-make/lto-no-link-whole-rlib/lib1.rs deleted file mode 100644 index 0a87c8e4725..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/lib1.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[link(name = "foo", kind = "static")] -extern { - fn foo() -> i32; -} - -pub fn foo1() -> i32 { - unsafe { foo() } -} diff --git a/src/test/run-make/lto-no-link-whole-rlib/lib2.rs b/src/test/run-make/lto-no-link-whole-rlib/lib2.rs deleted file mode 100644 index 6e3f382b3fd..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/lib2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern crate lib1; - -#[link(name = "bar", kind = "static")] -extern { - fn foo() -> i32; -} - -pub fn foo2() -> i32 { - unsafe { foo() } -} - diff --git a/src/test/run-make/lto-no-link-whole-rlib/main.rs b/src/test/run-make/lto-no-link-whole-rlib/main.rs deleted file mode 100644 index 8417af63be9..00000000000 --- a/src/test/run-make/lto-no-link-whole-rlib/main.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib1; -extern crate lib2; - -fn main() { - assert_eq!(lib1::foo1(), 2); - assert_eq!(lib2::foo2(), 2); -} diff --git a/src/test/run-make/lto-readonly-lib/Makefile b/src/test/run-make/lto-readonly-lib/Makefile deleted file mode 100644 index 0afbbc3450a..00000000000 --- a/src/test/run-make/lto-readonly-lib/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - - # the compiler needs to copy and modify the rlib file when performing - # LTO, so we should ensure that it can cope with the original rlib - # being read-only. - chmod 444 $(TMPDIR)/*.rlib - - $(RUSTC) main.rs -C lto - $(call RUN,main) diff --git a/src/test/run-make/lto-readonly-lib/lib.rs b/src/test/run-make/lto-readonly-lib/lib.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/lto-readonly-lib/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/lto-readonly-lib/main.rs b/src/test/run-make/lto-readonly-lib/main.rs deleted file mode 100644 index e12ac9e01dc..00000000000 --- a/src/test/run-make/lto-readonly-lib/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib; - -fn main() {} diff --git a/src/test/run-make/lto-smoke-c/Makefile b/src/test/run-make/lto-smoke-c/Makefile deleted file mode 100644 index 0f61f5de938..00000000000 --- a/src/test/run-make/lto-smoke-c/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Apparently older versions of GCC segfault if -g is passed... -CC := $(CC:-g=) - -all: - $(RUSTC) foo.rs -C lto - $(CC) bar.c $(call STATICLIB,foo) \ - $(call OUT_EXE,bar) \ - $(EXTRACFLAGS) $(EXTRACXXFLAGS) - $(call RUN,bar) diff --git a/src/test/run-make/lto-smoke-c/bar.c b/src/test/run-make/lto-smoke-c/bar.c deleted file mode 100644 index 5729d411c5b..00000000000 --- a/src/test/run-make/lto-smoke-c/bar.c +++ /dev/null @@ -1,7 +0,0 @@ -// ignore-license -void foo(); - -int main() { - foo(); - return 0; -} diff --git a/src/test/run-make/lto-smoke-c/foo.rs b/src/test/run-make/lto-smoke-c/foo.rs deleted file mode 100644 index 1bb19016700..00000000000 --- a/src/test/run-make/lto-smoke-c/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -#[no_mangle] -pub extern "C" fn foo() {} diff --git a/src/test/run-make/lto-smoke/Makefile b/src/test/run-make/lto-smoke/Makefile deleted file mode 100644 index 020252e1f8c..00000000000 --- a/src/test/run-make/lto-smoke/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - $(RUSTC) main.rs -C lto - $(call RUN,main) diff --git a/src/test/run-make/lto-smoke/lib.rs b/src/test/run-make/lto-smoke/lib.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/lto-smoke/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/lto-smoke/main.rs b/src/test/run-make/lto-smoke/main.rs deleted file mode 100644 index e12ac9e01dc..00000000000 --- a/src/test/run-make/lto-smoke/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib; - -fn main() {} diff --git a/src/test/run-make/manual-crate-name/Makefile b/src/test/run-make/manual-crate-name/Makefile deleted file mode 100644 index 1d1419997a2..00000000000 --- a/src/test/run-make/manual-crate-name/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) --crate-name foo bar.rs - rm $(TMPDIR)/libfoo.rlib diff --git a/src/test/run-make/manual-crate-name/bar.rs b/src/test/run-make/manual-crate-name/bar.rs deleted file mode 100644 index 04d3ae67207..00000000000 --- a/src/test/run-make/manual-crate-name/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] diff --git a/src/test/run-make/manual-link/Makefile b/src/test/run-make/manual-link/Makefile deleted file mode 100644 index dccf0d99b0f..00000000000 --- a/src/test/run-make/manual-link/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: $(TMPDIR)/libbar.a - $(RUSTC) foo.rs -lstatic=bar - $(RUSTC) main.rs - $(call RUN,main) diff --git a/src/test/run-make/manual-link/bar.c b/src/test/run-make/manual-link/bar.c deleted file mode 100644 index 3c167b45af9..00000000000 --- a/src/test/run-make/manual-link/bar.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -void bar() {} diff --git a/src/test/run-make/manual-link/foo.c b/src/test/run-make/manual-link/foo.c deleted file mode 100644 index 3c167b45af9..00000000000 --- a/src/test/run-make/manual-link/foo.c +++ /dev/null @@ -1,2 +0,0 @@ -// ignore-license -void bar() {} diff --git a/src/test/run-make/manual-link/foo.rs b/src/test/run-make/manual-link/foo.rs deleted file mode 100644 index d67a4057afb..00000000000 --- a/src/test/run-make/manual-link/foo.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern { - fn bar(); -} - -pub fn foo() { - unsafe { bar(); } -} diff --git a/src/test/run-make/manual-link/main.rs b/src/test/run-make/manual-link/main.rs deleted file mode 100644 index 756a47f386a..00000000000 --- a/src/test/run-make/manual-link/main.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::foo(); -} diff --git a/src/test/run-make/many-crates-but-no-match/Makefile b/src/test/run-make/many-crates-but-no-match/Makefile deleted file mode 100644 index 03a797d95f9..00000000000 --- a/src/test/run-make/many-crates-but-no-match/Makefile +++ /dev/null @@ -1,36 +0,0 @@ --include ../tools.mk - -# Modelled after compile-fail/changing-crates test, but this one puts -# more than one (mismatching) candidate crate into the search path, -# which did not appear directly expressible in compile-fail/aux-build -# infrastructure. -# -# Note that we move the built libraries into target direcrtories rather than -# use the `--out-dir` option because the `../tools.mk` file already bakes a -# use of `--out-dir` into the definition of $(RUSTC). - -A1=$(TMPDIR)/a1 -A2=$(TMPDIR)/a2 -A3=$(TMPDIR)/a3 - -# A hack to match distinct lines of output from a single run. -LOG=$(TMPDIR)/log.txt - -all: - mkdir -p $(A1) $(A2) $(A3) - $(RUSTC) --crate-type=rlib crateA1.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A1) - $(RUSTC) --crate-type=rlib -L $(A1) crateB.rs - $(RUSTC) --crate-type=rlib crateA2.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A2) - $(RUSTC) --crate-type=rlib crateA3.rs - mv $(TMPDIR)/$(call RLIB_GLOB,crateA) $(A3) - # Ensure crateC fails to compile since A1 is "missing" and A2/A3 hashes do not match - $(RUSTC) -L $(A2) -L $(A3) crateC.rs >$(LOG) 2>&1 || true - $(CGREP) \ - 'found possibly newer version of crate `crateA` which `crateB` depends on' \ - 'note: perhaps that crate needs to be recompiled?' \ - 'crate `crateA`:' \ - 'crate `crateB`:' \ - < $(LOG) - # the 'crate `crateA`' will match two entries. \ No newline at end of file diff --git a/src/test/run-make/many-crates-but-no-match/crateA1.rs b/src/test/run-make/many-crates-but-no-match/crateA1.rs deleted file mode 100644 index dbfe920c85b..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateA1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="crateA"] - -// Base crate -pub fn func() {} diff --git a/src/test/run-make/many-crates-but-no-match/crateA2.rs b/src/test/run-make/many-crates-but-no-match/crateA2.rs deleted file mode 100644 index 857c36aee60..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateA2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="crateA"] - -// Base crate -pub fn func() { println!("hello"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateA3.rs b/src/test/run-make/many-crates-but-no-match/crateA3.rs deleted file mode 100644 index 8b8dac5e862..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateA3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name="crateA"] - -// Base crate -pub fn foo() { println!("world!"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateB.rs b/src/test/run-make/many-crates-but-no-match/crateB.rs deleted file mode 100644 index bf55017c646..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateB.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateA; diff --git a/src/test/run-make/many-crates-but-no-match/crateC.rs b/src/test/run-make/many-crates-but-no-match/crateC.rs deleted file mode 100644 index 174d9382b76..00000000000 --- a/src/test/run-make/many-crates-but-no-match/crateC.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateB; - -fn main() {} diff --git a/src/test/run-make/metadata-flag-frobs-symbols/Makefile b/src/test/run-make/metadata-flag-frobs-symbols/Makefile deleted file mode 100644 index 09e6ae0bbf7..00000000000 --- a/src/test/run-make/metadata-flag-frobs-symbols/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -C metadata=a -C extra-filename=-a - $(RUSTC) foo.rs -C metadata=b -C extra-filename=-b - $(RUSTC) bar.rs \ - --extern foo1=$(TMPDIR)/libfoo-a.rlib \ - --extern foo2=$(TMPDIR)/libfoo-b.rlib \ - -Z print-link-args - $(call RUN,bar) diff --git a/src/test/run-make/metadata-flag-frobs-symbols/bar.rs b/src/test/run-make/metadata-flag-frobs-symbols/bar.rs deleted file mode 100644 index 44b9e2f874a..00000000000 --- a/src/test/run-make/metadata-flag-frobs-symbols/bar.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo1; -extern crate foo2; - -fn main() { - let a = foo1::foo(); - let b = foo2::foo(); - assert!(a as *const _ != b as *const _); -} diff --git a/src/test/run-make/metadata-flag-frobs-symbols/foo.rs b/src/test/run-make/metadata-flag-frobs-symbols/foo.rs deleted file mode 100644 index baabdc9ad7b..00000000000 --- a/src/test/run-make/metadata-flag-frobs-symbols/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "foo"] -#![crate_type = "rlib"] - -static FOO: usize = 3; - -pub fn foo() -> &'static usize { &FOO } diff --git a/src/test/run-make/min-global-align/Makefile b/src/test/run-make/min-global-align/Makefile deleted file mode 100644 index 2eacc36f380..00000000000 --- a/src/test/run-make/min-global-align/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -# This tests ensure that global variables respect the target minimum alignment. -# The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have -# type-alignment of 1, but some targets require greater global alignment. - -SRC = min_global_align.rs -LL = $(TMPDIR)/min_global_align.ll - -all: -ifeq ($(UNAME),Linux) -# Most targets are happy with default alignment -- take i686 for example. -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) - $(RUSTC) --target=i686-unknown-linux-gnu --emit=llvm-ir $(SRC) - [ "$$(grep -c 'align 1' "$(LL)")" -eq "3" ] -endif -# SystemZ requires even alignment for PC-relative addressing. -ifeq ($(filter systemz,$(LLVM_COMPONENTS)),systemz) - $(RUSTC) --target=s390x-unknown-linux-gnu --emit=llvm-ir $(SRC) - [ "$$(grep -c 'align 2' "$(LL)")" -eq "3" ] -endif -endif diff --git a/src/test/run-make/min-global-align/min_global_align.rs b/src/test/run-make/min-global-align/min_global_align.rs deleted file mode 100644 index 3d4f9001a74..00000000000 --- a/src/test/run-make/min-global-align/min_global_align.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core, lang_items)] -#![crate_type="rlib"] -#![no_core] - -pub static STATIC_BOOL: bool = true; - -pub static mut STATIC_MUT_BOOL: bool = true; - -const CONST_BOOL: bool = true; -pub static CONST_BOOL_REF: &'static bool = &CONST_BOOL; - - -#[lang = "sized"] -trait Sized {} - -#[lang = "copy"] -trait Copy {} - -#[lang = "freeze"] -trait Freeze {} - -#[lang = "sync"] -trait Sync {} -impl Sync for bool {} -impl Sync for &'static bool {} - -#[lang="drop_in_place"] -pub unsafe fn drop_in_place(_: *mut T) { } diff --git a/src/test/run-make/mismatching-target-triples/Makefile b/src/test/run-make/mismatching-target-triples/Makefile deleted file mode 100644 index 1636e41b056..00000000000 --- a/src/test/run-make/mismatching-target-triples/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -# Issue #10814 -# -# these are no_std to avoid having to have the standard library or any -# linkers/assemblers for the relevant platform - -all: - $(RUSTC) foo.rs --target=i686-unknown-linux-gnu - $(RUSTC) bar.rs --target=x86_64-unknown-linux-gnu 2>&1 \ - | $(CGREP) 'couldn'"'"'t find crate `foo` with expected target triple x86_64-unknown-linux-gnu' diff --git a/src/test/run-make/mismatching-target-triples/bar.rs b/src/test/run-make/mismatching-target-triples/bar.rs deleted file mode 100644 index 0dc5c0a3a8e..00000000000 --- a/src/test/run-make/mismatching-target-triples/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -extern crate foo; diff --git a/src/test/run-make/mismatching-target-triples/foo.rs b/src/test/run-make/mismatching-target-triples/foo.rs deleted file mode 100644 index a2169d0c631..00000000000 --- a/src/test/run-make/mismatching-target-triples/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![crate_type = "lib"] diff --git a/src/test/run-make/missing-crate-dependency/Makefile b/src/test/run-make/missing-crate-dependency/Makefile deleted file mode 100644 index b5a5bf492ab..00000000000 --- a/src/test/run-make/missing-crate-dependency/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) --crate-type=rlib crateA.rs - $(RUSTC) --crate-type=rlib crateB.rs - $(call REMOVE_RLIBS,crateA) - # Ensure crateC fails to compile since dependency crateA is missing - $(RUSTC) crateC.rs 2>&1 | \ - $(CGREP) 'can'"'"'t find crate for `crateA` which `crateB` depends on' diff --git a/src/test/run-make/missing-crate-dependency/crateA.rs b/src/test/run-make/missing-crate-dependency/crateA.rs deleted file mode 100644 index 4e111f29e8a..00000000000 --- a/src/test/run-make/missing-crate-dependency/crateA.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Base crate -pub fn func() {} diff --git a/src/test/run-make/missing-crate-dependency/crateB.rs b/src/test/run-make/missing-crate-dependency/crateB.rs deleted file mode 100644 index bf55017c646..00000000000 --- a/src/test/run-make/missing-crate-dependency/crateB.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateA; diff --git a/src/test/run-make/missing-crate-dependency/crateC.rs b/src/test/run-make/missing-crate-dependency/crateC.rs deleted file mode 100644 index 174d9382b76..00000000000 --- a/src/test/run-make/missing-crate-dependency/crateC.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateB; - -fn main() {} diff --git a/src/test/run-make/mixing-deps/Makefile b/src/test/run-make/mixing-deps/Makefile deleted file mode 100644 index 0e52d4a8bef..00000000000 --- a/src/test/run-make/mixing-deps/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) both.rs -C prefer-dynamic - $(RUSTC) dylib.rs -C prefer-dynamic - $(RUSTC) prog.rs - $(call RUN,prog) diff --git a/src/test/run-make/mixing-deps/both.rs b/src/test/run-make/mixing-deps/both.rs deleted file mode 100644 index c44335e2bbc..00000000000 --- a/src/test/run-make/mixing-deps/both.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_type = "dylib"] - -pub static foo: isize = 4; diff --git a/src/test/run-make/mixing-deps/dylib.rs b/src/test/run-make/mixing-deps/dylib.rs deleted file mode 100644 index 78af525f386..00000000000 --- a/src/test/run-make/mixing-deps/dylib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate both; - -use std::mem; - -pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } } diff --git a/src/test/run-make/mixing-deps/prog.rs b/src/test/run-make/mixing-deps/prog.rs deleted file mode 100644 index c3d88016fda..00000000000 --- a/src/test/run-make/mixing-deps/prog.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dylib; -extern crate both; - -use std::mem; - -fn main() { - assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) }, - dylib::addr()); -} diff --git a/src/test/run-make/mixing-formats/Makefile b/src/test/run-make/mixing-formats/Makefile deleted file mode 100644 index 48257669baf..00000000000 --- a/src/test/run-make/mixing-formats/Makefile +++ /dev/null @@ -1,74 +0,0 @@ --include ../tools.mk - -# Testing various mixings of rlibs and dylibs. Makes sure that it's possible to -# link an rlib to a dylib. The dependency tree among the file looks like: -# -# foo -# / \ -# bar1 bar2 -# / \ / -# baz baz2 -# -# This is generally testing the permutations of the foo/bar1/bar2 layer against -# the baz/baz2 layer - -all: - # Building just baz - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib,rlib baz.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz.rs - rm $(TMPDIR)/* - # Building baz2 - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib baz2.rs && exit 1 || exit 0 - $(RUSTC) --crate-type=bin baz2.rs && exit 1 || exit 0 - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=rlib foo.rs - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs -C prefer-dynamic - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar2.rs - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=rlib bar1.rs - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs - rm $(TMPDIR)/* - $(RUSTC) --crate-type=dylib foo.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar1.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib bar2.rs -C prefer-dynamic - $(RUSTC) --crate-type=dylib,rlib baz2.rs - $(RUSTC) --crate-type=bin baz2.rs diff --git a/src/test/run-make/mixing-formats/bar1.rs b/src/test/run-make/mixing-formats/bar1.rs deleted file mode 100644 index 4b4916fe96d..00000000000 --- a/src/test/run-make/mixing-formats/bar1.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; diff --git a/src/test/run-make/mixing-formats/bar2.rs b/src/test/run-make/mixing-formats/bar2.rs deleted file mode 100644 index 4b4916fe96d..00000000000 --- a/src/test/run-make/mixing-formats/bar2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; diff --git a/src/test/run-make/mixing-formats/baz.rs b/src/test/run-make/mixing-formats/baz.rs deleted file mode 100644 index 3fb90f6a854..00000000000 --- a/src/test/run-make/mixing-formats/baz.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar1; - -fn main() {} diff --git a/src/test/run-make/mixing-formats/baz2.rs b/src/test/run-make/mixing-formats/baz2.rs deleted file mode 100644 index c5066ccd656..00000000000 --- a/src/test/run-make/mixing-formats/baz2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar1; -extern crate bar2; - -fn main() {} diff --git a/src/test/run-make/mixing-formats/foo.rs b/src/test/run-make/mixing-formats/foo.rs deleted file mode 100644 index e6c76025738..00000000000 --- a/src/test/run-make/mixing-formats/foo.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/mixing-libs/Makefile b/src/test/run-make/mixing-libs/Makefile deleted file mode 100644 index babeeef164d..00000000000 --- a/src/test/run-make/mixing-libs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) rlib.rs - $(RUSTC) dylib.rs - $(RUSTC) rlib.rs --crate-type=dylib - $(RUSTC) dylib.rs - $(call REMOVE_DYLIBS,rlib) - $(RUSTC) prog.rs && exit 1 || exit 0 diff --git a/src/test/run-make/mixing-libs/dylib.rs b/src/test/run-make/mixing-libs/dylib.rs deleted file mode 100644 index 1a5bd658cd9..00000000000 --- a/src/test/run-make/mixing-libs/dylib.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] -extern crate rlib; - -pub fn dylib() { rlib::rlib() } diff --git a/src/test/run-make/mixing-libs/prog.rs b/src/test/run-make/mixing-libs/prog.rs deleted file mode 100644 index 5e1a4274756..00000000000 --- a/src/test/run-make/mixing-libs/prog.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate dylib; -extern crate rlib; - -fn main() { - dylib::dylib(); - rlib::rlib(); -} diff --git a/src/test/run-make/mixing-libs/rlib.rs b/src/test/run-make/mixing-libs/rlib.rs deleted file mode 100644 index ad0ea67b9ab..00000000000 --- a/src/test/run-make/mixing-libs/rlib.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -pub fn rlib() {} diff --git a/src/test/run-make/msvc-opt-minsize/Makefile b/src/test/run-make/msvc-opt-minsize/Makefile deleted file mode 100644 index 1095a047dd1..00000000000 --- a/src/test/run-make/msvc-opt-minsize/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -Copt-level=z 2>&1 - $(call RUN,foo) diff --git a/src/test/run-make/msvc-opt-minsize/foo.rs b/src/test/run-make/msvc-opt-minsize/foo.rs deleted file mode 100644 index 30b12691afe..00000000000 --- a/src/test/run-make/msvc-opt-minsize/foo.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(test)] -extern crate test; - -fn foo(x: i32, y: i32) -> i64 { - (x + y) as i64 -} - -#[inline(never)] -fn bar() { - let _f = Box::new(0); - // This call used to trigger an LLVM bug in opt-level z where the base - // pointer gets corrupted, see issue #45034 - let y: fn(i32, i32) -> i64 = test::black_box(foo); - test::black_box(y(1, 2)); -} - -fn main() { - bar(); -} diff --git a/src/test/run-make/multiple-emits/Makefile b/src/test/run-make/multiple-emits/Makefile deleted file mode 100644 index e126422835c..00000000000 --- a/src/test/run-make/multiple-emits/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out 2>&1 - rm $(TMPDIR)/out.ll $(TMPDIR)/out.s - $(RUSTC) foo.rs --emit=asm,llvm-ir -o $(TMPDIR)/out2.ext 2>&1 - rm $(TMPDIR)/out2.ll $(TMPDIR)/out2.s diff --git a/src/test/run-make/multiple-emits/foo.rs b/src/test/run-make/multiple-emits/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/multiple-emits/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/no-builtins-lto/Makefile b/src/test/run-make/no-builtins-lto/Makefile deleted file mode 100644 index b9688f16c64..00000000000 --- a/src/test/run-make/no-builtins-lto/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - # Compile a `#![no_builtins]` rlib crate - $(RUSTC) no_builtins.rs - # Build an executable that depends on that crate using LTO. The no_builtins crate doesn't - # participate in LTO, so its rlib must be explicitly linked into the final binary. Verify this by - # grepping the linker arguments. - $(RUSTC) main.rs -C lto -Z print-link-args | $(CGREP) 'libno_builtins.rlib' diff --git a/src/test/run-make/no-builtins-lto/main.rs b/src/test/run-make/no-builtins-lto/main.rs deleted file mode 100644 index e960c726a98..00000000000 --- a/src/test/run-make/no-builtins-lto/main.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate no_builtins; - -fn main() {} diff --git a/src/test/run-make/no-builtins-lto/no_builtins.rs b/src/test/run-make/no-builtins-lto/no_builtins.rs deleted file mode 100644 index be95e7c5521..00000000000 --- a/src/test/run-make/no-builtins-lto/no_builtins.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![no_builtins] diff --git a/src/test/run-make/no-duplicate-libs/Makefile b/src/test/run-make/no-duplicate-libs/Makefile deleted file mode 100644 index 13d8366c60a..00000000000 --- a/src/test/run-make/no-duplicate-libs/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -ifdef IS_MSVC -# FIXME(#27979) -all: -else -all: $(call STATICLIB,foo) $(call STATICLIB,bar) - $(RUSTC) main.rs - $(call RUN,main) -endif diff --git a/src/test/run-make/no-duplicate-libs/bar.c b/src/test/run-make/no-duplicate-libs/bar.c deleted file mode 100644 index b9dcd0f5e5e..00000000000 --- a/src/test/run-make/no-duplicate-libs/bar.c +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void foo(); - -void bar() { - foo(); -} diff --git a/src/test/run-make/no-duplicate-libs/foo.c b/src/test/run-make/no-duplicate-libs/foo.c deleted file mode 100644 index 906cd5682b8..00000000000 --- a/src/test/run-make/no-duplicate-libs/foo.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void foo() {} diff --git a/src/test/run-make/no-duplicate-libs/main.rs b/src/test/run-make/no-duplicate-libs/main.rs deleted file mode 100644 index 824946fe9c2..00000000000 --- a/src/test/run-make/no-duplicate-libs/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[link(name = "foo")] // linker should drop this library, no symbols used -#[link(name = "bar")] // symbol comes from this library -#[link(name = "foo")] // now linker picks up `foo` b/c `bar` library needs it -extern { - fn bar(); -} - -fn main() { - unsafe { bar() } -} diff --git a/src/test/run-make/no-integrated-as/Makefile b/src/test/run-make/no-integrated-as/Makefile deleted file mode 100644 index 78e3025b99a..00000000000 --- a/src/test/run-make/no-integrated-as/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: -ifeq ($(TARGET),x86_64-unknown-linux-gnu) - $(RUSTC) hello.rs -C no_integrated_as - $(call RUN,hello) -endif diff --git a/src/test/run-make/no-integrated-as/hello.rs b/src/test/run-make/no-integrated-as/hello.rs deleted file mode 100644 index 68e7f6d94d1..00000000000 --- a/src/test/run-make/no-integrated-as/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, world!"); -} diff --git a/src/test/run-make/no-intermediate-extras/Makefile b/src/test/run-make/no-intermediate-extras/Makefile deleted file mode 100644 index 258cbf04c61..00000000000 --- a/src/test/run-make/no-intermediate-extras/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# Regression test for issue #10973 - --include ../tools.mk - -all: - $(RUSTC) --crate-type=rlib --test foo.rs - rm $(TMPDIR)/foo.bc && exit 1 || exit 0 diff --git a/src/test/run-make/no-intermediate-extras/foo.rs b/src/test/run-make/no-intermediate-extras/foo.rs deleted file mode 100644 index e6c76025738..00000000000 --- a/src/test/run-make/no-intermediate-extras/foo.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. diff --git a/src/test/run-make/obey-crate-type-flag/Makefile b/src/test/run-make/obey-crate-type-flag/Makefile deleted file mode 100644 index 903349152df..00000000000 --- a/src/test/run-make/obey-crate-type-flag/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# check that rustc builds all crate_type attributes -# delete rlib -# delete whatever dylib is made for this system -# check that rustc only builds --crate-type flags, ignoring attributes -# fail if an rlib was built -all: - $(RUSTC) test.rs - $(call REMOVE_RLIBS,test) - $(call REMOVE_DYLIBS,test) - $(RUSTC) --crate-type dylib test.rs - $(call REMOVE_RLIBS,test) && exit 1 || exit 0 diff --git a/src/test/run-make/obey-crate-type-flag/test.rs b/src/test/run-make/obey-crate-type-flag/test.rs deleted file mode 100644 index e6c8b8eb179..00000000000 --- a/src/test/run-make/obey-crate-type-flag/test.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_type = "dylib"] diff --git a/src/test/run-make/output-filename-conflicts-with-directory/Makefile b/src/test/run-make/output-filename-conflicts-with-directory/Makefile deleted file mode 100644 index 74e5dcfcf36..00000000000 --- a/src/test/run-make/output-filename-conflicts-with-directory/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/foo.rs - mkdir $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \ - | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\"" diff --git a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs deleted file mode 100644 index 3f07b46791d..00000000000 --- a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/output-filename-overwrites-input/Makefile b/src/test/run-make/output-filename-overwrites-input/Makefile deleted file mode 100644 index 6377038b7be..00000000000 --- a/src/test/run-make/output-filename-overwrites-input/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \ - | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable" - cp bar.rs $(TMPDIR)/bar.rlib - $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \ - | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable" - $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1 - cp foo.rs $(TMPDIR)/foo.rs - $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \ - | $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable" diff --git a/src/test/run-make/output-filename-overwrites-input/bar.rs b/src/test/run-make/output-filename-overwrites-input/bar.rs deleted file mode 100644 index 8e4e35fdee6..00000000000 --- a/src/test/run-make/output-filename-overwrites-input/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/output-filename-overwrites-input/foo.rs b/src/test/run-make/output-filename-overwrites-input/foo.rs deleted file mode 100644 index 3f07b46791d..00000000000 --- a/src/test/run-make/output-filename-overwrites-input/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/output-type-permutations/Makefile b/src/test/run-make/output-type-permutations/Makefile deleted file mode 100644 index c2715027bc1..00000000000 --- a/src/test/run-make/output-type-permutations/Makefile +++ /dev/null @@ -1,146 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs --crate-type=rlib,dylib,staticlib - $(call REMOVE_RLIBS,bar) - $(call REMOVE_DYLIBS,bar) - rm $(call STATICLIB,bar) - rm -f $(TMPDIR)/bar.{dll.exp,dll.lib,pdb} - # Check that $(TMPDIR) is empty. - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=bin - rm $(TMPDIR)/$(call BIN,bar) - rm -f $(TMPDIR)/bar.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link - rm $(TMPDIR)/bar.ll - rm $(TMPDIR)/bar.bc - rm $(TMPDIR)/bar.s - rm $(TMPDIR)/bar.o - rm $(TMPDIR)/$(call BIN,bar) - rm -f $(TMPDIR)/bar.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit asm -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit asm=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit llvm-bc -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit llvm-bc=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=llvm-bc=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit llvm-ir -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=llvm-ir=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit obj -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit obj=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --emit=obj=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit link -o $(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --emit link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --emit=link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - rm -f $(TMPDIR)/foo.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=rlib --emit link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=rlib --emit=link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=dylib -o $(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=dylib --emit link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=dylib --emit=link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - rm -f $(TMPDIR)/foo.{dll.exp,dll.lib,pdb} - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=staticlib -o $(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=staticlib --emit link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - $(RUSTC) foo.rs --crate-type=staticlib --emit=link=$(TMPDIR)/foo - rm $(TMPDIR)/foo - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=bin --emit link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - $(RUSTC) foo.rs --crate-type=bin --emit=link=$(TMPDIR)/$(call BIN,foo) - rm $(TMPDIR)/$(call BIN,foo) - rm -f $(TMPDIR)/foo.pdb - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit llvm-ir=$(TMPDIR)/ir \ - --emit link \ - --crate-type=rlib - rm $(TMPDIR)/ir - rm $(TMPDIR)/libbar.rlib - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit asm=$(TMPDIR)/asm \ - --emit llvm-ir=$(TMPDIR)/ir \ - --emit llvm-bc=$(TMPDIR)/bc \ - --emit obj=$(TMPDIR)/obj \ - --emit link=$(TMPDIR)/link \ - --crate-type=staticlib - rm $(TMPDIR)/asm - rm $(TMPDIR)/ir - rm $(TMPDIR)/bc - rm $(TMPDIR)/obj - rm $(TMPDIR)/link - $(RUSTC) foo.rs --emit=asm=$(TMPDIR)/asm \ - --emit llvm-ir=$(TMPDIR)/ir \ - --emit=llvm-bc=$(TMPDIR)/bc \ - --emit obj=$(TMPDIR)/obj \ - --emit=link=$(TMPDIR)/link \ - --crate-type=staticlib - rm $(TMPDIR)/asm - rm $(TMPDIR)/ir - rm $(TMPDIR)/bc - rm $(TMPDIR)/obj - rm $(TMPDIR)/link - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] - - $(RUSTC) foo.rs --emit=asm,llvm-ir,llvm-bc,obj,link --crate-type=staticlib - rm $(TMPDIR)/bar.ll - rm $(TMPDIR)/bar.s - rm $(TMPDIR)/bar.o - rm $(call STATICLIB,bar) - mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc - # Don't check that the $(TMPDIR) is empty - we left `foo.bc` for later - # comparison. - - $(RUSTC) foo.rs --emit=llvm-bc,link --crate-type=rlib - cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc - rm $(TMPDIR)/bar.bc - rm $(TMPDIR)/foo.bc - $(call REMOVE_RLIBS,bar) - [ "$$(ls -1 $(TMPDIR) | wc -l)" -eq "0" ] diff --git a/src/test/run-make/output-type-permutations/foo.rs b/src/test/run-make/output-type-permutations/foo.rs deleted file mode 100644 index bb5796bd873..00000000000 --- a/src/test/run-make/output-type-permutations/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_name = "bar"] - -fn main() {} diff --git a/src/test/run-make/output-with-hyphens/Makefile b/src/test/run-make/output-with-hyphens/Makefile deleted file mode 100644 index 783d826a53d..00000000000 --- a/src/test/run-make/output-with-hyphens/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo-bar.rs - [ -f $(TMPDIR)/$(call BIN,foo-bar) ] - [ -f $(TMPDIR)/libfoo_bar.rlib ] diff --git a/src/test/run-make/output-with-hyphens/foo-bar.rs b/src/test/run-make/output-with-hyphens/foo-bar.rs deleted file mode 100644 index 2f93b2d1ead..00000000000 --- a/src/test/run-make/output-with-hyphens/foo-bar.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![crate_type = "bin"] - -fn main() {} diff --git a/src/test/run-make/prefer-dylib/Makefile b/src/test/run-make/prefer-dylib/Makefile deleted file mode 100644 index bd44feecf2a..00000000000 --- a/src/test/run-make/prefer-dylib/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib -C prefer-dynamic - $(RUSTC) foo.rs -C prefer-dynamic - $(call RUN,foo) - rm $(TMPDIR)/*bar* - $(call FAIL,foo) diff --git a/src/test/run-make/prefer-dylib/bar.rs b/src/test/run-make/prefer-dylib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/prefer-dylib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/prefer-dylib/foo.rs b/src/test/run-make/prefer-dylib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/prefer-dylib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/prefer-rlib/Makefile b/src/test/run-make/prefer-rlib/Makefile deleted file mode 100644 index c6a239eef08..00000000000 --- a/src/test/run-make/prefer-rlib/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) bar.rs --crate-type=dylib --crate-type=rlib - ls $(TMPDIR)/$(call RLIB_GLOB,bar) - $(RUSTC) foo.rs - rm $(TMPDIR)/*bar* - $(call RUN,foo) diff --git a/src/test/run-make/prefer-rlib/bar.rs b/src/test/run-make/prefer-rlib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/prefer-rlib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/prefer-rlib/foo.rs b/src/test/run-make/prefer-rlib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/prefer-rlib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/pretty-expanded-hygiene/Makefile b/src/test/run-make/pretty-expanded-hygiene/Makefile deleted file mode 100644 index 136d7643ade..00000000000 --- a/src/test/run-make/pretty-expanded-hygiene/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -REPLACEMENT := s/[0-9][0-9]*\#[0-9][0-9]*/$(shell date)/g - -all: - $(RUSTC) -o $(TMPDIR)/input.out -Z unstable-options \ - --pretty expanded,hygiene input.rs - - # the name/ctxt numbers are very internals-dependent and thus - # change relatively frequently, and testing for their exact values - # them will fail annoyingly, so we just check their positions - # (using a non-constant replacement like this will make it less - # likely the compiler matches whatever other dummy value we - # choose). - # - # (These need to be out-of-place because OSX/BSD & GNU sed - # differ.) - sed "$(REPLACEMENT)" input.pp.rs > $(TMPDIR)/input.pp.rs - sed "$(REPLACEMENT)" $(TMPDIR)/input.out > $(TMPDIR)/input.out.replaced - - diff -u $(TMPDIR)/input.out.replaced $(TMPDIR)/input.pp.rs diff --git a/src/test/run-make/pretty-expanded-hygiene/input.pp.rs b/src/test/run-make/pretty-expanded-hygiene/input.pp.rs deleted file mode 100644 index 3d2dd380e48..00000000000 --- a/src/test/run-make/pretty-expanded-hygiene/input.pp.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// minimal junk -#![feature(no_core)] -#![no_core] - -macro_rules! foo /* 60#0 */(( $ x : ident ) => { y + $ x }); - -fn bar /* 62#0 */() { let x /* 59#2 */ = 1; y /* 61#4 */ + x /* 59#5 */ } - -fn y /* 61#0 */() { } diff --git a/src/test/run-make/pretty-expanded-hygiene/input.rs b/src/test/run-make/pretty-expanded-hygiene/input.rs deleted file mode 100644 index 422fbdb0884..00000000000 --- a/src/test/run-make/pretty-expanded-hygiene/input.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// minimal junk -#![feature(no_core)] -#![no_core] - -macro_rules! foo { - ($x: ident) => { y + $x } -} - -fn bar() { - let x = 1; - foo!(x) -} - -fn y() {} diff --git a/src/test/run-make/pretty-expanded/Makefile b/src/test/run-make/pretty-expanded/Makefile deleted file mode 100644 index 7a8dc8d871c..00000000000 --- a/src/test/run-make/pretty-expanded/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o $(TMPDIR)/input.expanded.rs -Z unstable-options \ - --pretty=expanded input.rs diff --git a/src/test/run-make/pretty-expanded/input.rs b/src/test/run-make/pretty-expanded/input.rs deleted file mode 100644 index 04bf17dc28a..00000000000 --- a/src/test/run-make/pretty-expanded/input.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[crate_type="lib"] - -// #13544 - -extern crate serialize; - -#[derive(Encodable)] pub struct A; -#[derive(Encodable)] pub struct B(isize); -#[derive(Encodable)] pub struct C { x: isize } -#[derive(Encodable)] pub enum D {} -#[derive(Encodable)] pub enum E { y } -#[derive(Encodable)] pub enum F { z(isize) } diff --git a/src/test/run-make/pretty-print-path-suffix/Makefile b/src/test/run-make/pretty-print-path-suffix/Makefile deleted file mode 100644 index 899457fc748..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o $(TMPDIR)/foo.out -Z unpretty=hir=foo input.rs - $(RUSTC) -o $(TMPDIR)/nest_foo.out -Z unpretty=hir=nest::foo input.rs - $(RUSTC) -o $(TMPDIR)/foo_method.out -Z unpretty=hir=foo_method input.rs - diff -u $(TMPDIR)/foo.out foo.pp - diff -u $(TMPDIR)/nest_foo.out nest_foo.pp - diff -u $(TMPDIR)/foo_method.out foo_method.pp diff --git a/src/test/run-make/pretty-print-path-suffix/foo.pp b/src/test/run-make/pretty-print-path-suffix/foo.pp deleted file mode 100644 index f3130a8044a..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/foo.pp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -pub fn foo() -> i32 { 45 } /* foo */ - - -pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make/pretty-print-path-suffix/foo_method.pp b/src/test/run-make/pretty-print-path-suffix/foo_method.pp deleted file mode 100644 index fae13498687..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/foo_method.pp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - - - -fn foo_method(self: &Self) - -> &'static str { return "i am very similar to foo."; } /* -nest::{{impl}}::foo_method */ diff --git a/src/test/run-make/pretty-print-path-suffix/input.rs b/src/test/run-make/pretty-print-path-suffix/input.rs deleted file mode 100644 index 8ea86a94f93..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/input.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub fn -foo() -> i32 -{ 45 } - -pub fn bar() -> &'static str { "i am not a foo." } - -pub mod nest { - pub fn foo() -> &'static str { "i am a foo." } - - struct S; - impl S { - fn foo_method(&self) -> &'static str { - return "i am very similar to foo."; - } - } -} diff --git a/src/test/run-make/pretty-print-path-suffix/nest_foo.pp b/src/test/run-make/pretty-print-path-suffix/nest_foo.pp deleted file mode 100644 index 88eaa062b03..00000000000 --- a/src/test/run-make/pretty-print-path-suffix/nest_foo.pp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - - -pub fn foo() -> &'static str { "i am a foo." } /* nest::foo */ diff --git a/src/test/run-make/pretty-print-to-file/Makefile b/src/test/run-make/pretty-print-to-file/Makefile deleted file mode 100644 index 8909dee11f0..00000000000 --- a/src/test/run-make/pretty-print-to-file/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -o $(TMPDIR)/input.out --pretty=normal -Z unstable-options input.rs - diff -u $(TMPDIR)/input.out input.pp diff --git a/src/test/run-make/pretty-print-to-file/input.pp b/src/test/run-make/pretty-print-to-file/input.pp deleted file mode 100644 index a6dd6b6778e..00000000000 --- a/src/test/run-make/pretty-print-to-file/input.pp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#[crate_type = "lib"] -pub fn foo() -> i32 { 45 } diff --git a/src/test/run-make/pretty-print-to-file/input.rs b/src/test/run-make/pretty-print-to-file/input.rs deleted file mode 100644 index 8e3ec363187..00000000000 --- a/src/test/run-make/pretty-print-to-file/input.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[crate_type="lib"] - -pub fn -foo() -> i32 -{ 45 } diff --git a/src/test/run-make/print-cfg/Makefile b/src/test/run-make/print-cfg/Makefile deleted file mode 100644 index 08303a46d19..00000000000 --- a/src/test/run-make/print-cfg/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -all: default - $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows - $(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64 - $(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc - $(RUSTC) --target i686-apple-darwin --print cfg | $(CGREP) macos - $(RUSTC) --target i686-unknown-linux-gnu --print cfg | $(CGREP) gnu - -ifdef IS_WINDOWS -default: - $(RUSTC) --print cfg | $(CGREP) windows -else -default: - $(RUSTC) --print cfg | $(CGREP) unix -endif diff --git a/src/test/run-make/print-target-list/Makefile b/src/test/run-make/print-target-list/Makefile deleted file mode 100644 index 144c5ba10cc..00000000000 --- a/src/test/run-make/print-target-list/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# Checks that all the targets returned by `rustc --print target-list` are valid -# target specifications -# TODO remove the '*ios*' case when rust-lang/rust#29812 is fixed -all: - for target in $(shell $(BARE_RUSTC) --print target-list); do \ - case $$target in \ - *ios*) \ - ;; \ - *) \ - $(BARE_RUSTC) --target $$target --print sysroot \ - ;; \ - esac \ - done diff --git a/src/test/run-make/profile/Makefile b/src/test/run-make/profile/Makefile deleted file mode 100644 index 7300bfc9553..00000000000 --- a/src/test/run-make/profile/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: -ifeq ($(PROFILER_SUPPORT),1) - $(RUSTC) -g -Z profile test.rs - $(call RUN,test) || exit 1 - [ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1) - [ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1) -endif diff --git a/src/test/run-make/profile/test.rs b/src/test/run-make/profile/test.rs deleted file mode 100644 index 046d27a9f0f..00000000000 --- a/src/test/run-make/profile/test.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/prune-link-args/Makefile b/src/test/run-make/prune-link-args/Makefile deleted file mode 100644 index a6e219873df..00000000000 --- a/src/test/run-make/prune-link-args/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk -ifdef IS_WINDOWS -# ignore windows -RUSTC_FLAGS = -else -# Notice the space in the end, this emulates the output of pkg-config -RUSTC_FLAGS = -C link-args="-lc " -endif - -all: - $(RUSTC) $(RUSTC_FLAGS) empty.rs diff --git a/src/test/run-make/prune-link-args/empty.rs b/src/test/run-make/prune-link-args/empty.rs deleted file mode 100644 index a9e231b0ea8..00000000000 --- a/src/test/run-make/prune-link-args/empty.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { } diff --git a/src/test/run-make/relocation-model/Makefile b/src/test/run-make/relocation-model/Makefile deleted file mode 100644 index 485ecbb4b5a..00000000000 --- a/src/test/run-make/relocation-model/Makefile +++ /dev/null @@ -1,19 +0,0 @@ --include ../tools.mk - -all: others - $(RUSTC) -C relocation-model=dynamic-no-pic foo.rs - $(call RUN,foo) - - $(RUSTC) -C relocation-model=default foo.rs - $(call RUN,foo) - - $(RUSTC) -C relocation-model=dynamic-no-pic --crate-type=dylib foo.rs --emit=link,obj - -ifdef IS_MSVC -# FIXME(#28026) -others: -else -others: - $(RUSTC) -C relocation-model=static foo.rs - $(call RUN,foo) -endif diff --git a/src/test/run-make/relocation-model/foo.rs b/src/test/run-make/relocation-model/foo.rs deleted file mode 100644 index e06d81cd60b..00000000000 --- a/src/test/run-make/relocation-model/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn main() {} diff --git a/src/test/run-make/relro-levels/Makefile b/src/test/run-make/relro-levels/Makefile deleted file mode 100644 index 673ba9a9a02..00000000000 --- a/src/test/run-make/relro-levels/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -# This tests the different -Zrelro-level values, and makes sure that they they work properly. - -all: -ifeq ($(UNAME),Linux) - # Ensure that binaries built with the full relro level links them with both - # RELRO and BIND_NOW for doing eager symbol resolving. - $(RUSTC) -Zrelro-level=full hello.rs - readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO - readelf -d $(TMPDIR)/hello | grep -q BIND_NOW - - $(RUSTC) -Zrelro-level=partial hello.rs - readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO - - # Ensure that we're *not* built with RELRO when setting it to off. We do - # not want to check for BIND_NOW however, as the linker might have that - # enabled by default. - $(RUSTC) -Zrelro-level=off hello.rs - ! readelf -l $(TMPDIR)/hello | grep -q GNU_RELRO -endif diff --git a/src/test/run-make/relro-levels/hello.rs b/src/test/run-make/relro-levels/hello.rs deleted file mode 100644 index 41782851a1a..00000000000 --- a/src/test/run-make/relro-levels/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, world!"); -} diff --git a/src/test/run-make/reproducible-build/Makefile b/src/test/run-make/reproducible-build/Makefile deleted file mode 100644 index ca76a5e5d77..00000000000 --- a/src/test/run-make/reproducible-build/Makefile +++ /dev/null @@ -1,74 +0,0 @@ --include ../tools.mk -all: \ - smoke \ - debug \ - opt \ - link_paths \ - remap_paths \ - different_source_dirs \ - extern_flags - -smoke: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) linker.rs -O - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) - diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" - -debug: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) linker.rs -O - $(RUSTC) reproducible-build-aux.rs -g - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -g - diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" - -opt: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) linker.rs -O - $(RUSTC) reproducible-build-aux.rs -O - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O - $(RUSTC) reproducible-build.rs -C linker=$(call RUN_BINFILE,linker) -O - diff -u "$(TMPDIR)/linker-arguments1" "$(TMPDIR)/linker-arguments2" - -link_paths: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs --crate-type rlib -L /b - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - $(RUSTC) reproducible-build.rs --crate-type rlib -L /a - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 - -remap_paths: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/a=/c - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=/b=/c - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 - -different_source_dirs: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - mkdir $(TMPDIR)/test - cp reproducible-build.rs $(TMPDIR)/test - $(RUSTC) reproducible-build.rs --crate-type rlib --remap-path-prefix=$$PWD=/b - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - (cd $(TMPDIR)/test && $(RUSTC) reproducible-build.rs \ - --remap-path-prefix=$(TMPDIR)/test=/b \ - --crate-type rlib) - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 - -extern_flags: - rm -rf $(TMPDIR) && mkdir $(TMPDIR) - $(RUSTC) reproducible-build-aux.rs - $(RUSTC) reproducible-build.rs \ - --extern reproducible_build_aux=$(TMPDIR)/libreproducible_build_aux.rlib \ - --crate-type rlib - cp $(TMPDIR)/libreproducible_build_aux.rlib $(TMPDIR)/libbar.rlib - cp $(TMPDIR)/libreproducible_build.rlib $(TMPDIR)/libfoo.rlib - $(RUSTC) reproducible-build.rs \ - --extern reproducible_build_aux=$(TMPDIR)/libbar.rlib \ - --crate-type rlib - cmp "$(TMPDIR)/libreproducible_build.rlib" "$(TMPDIR)/libfoo.rlib" || exit 1 diff --git a/src/test/run-make/reproducible-build/linker.rs b/src/test/run-make/reproducible-build/linker.rs deleted file mode 100644 index fd8946708bf..00000000000 --- a/src/test/run-make/reproducible-build/linker.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::env; -use std::path::Path; -use std::fs::File; -use std::io::{Read, Write}; - -fn main() { - let mut dst = env::current_exe().unwrap(); - dst.pop(); - dst.push("linker-arguments1"); - if dst.exists() { - dst.pop(); - dst.push("linker-arguments2"); - assert!(!dst.exists()); - } - - let mut out = String::new(); - for arg in env::args().skip(1) { - let path = Path::new(&arg); - if !path.is_file() { - out.push_str(&arg); - out.push_str("\n"); - continue - } - - let mut contents = Vec::new(); - File::open(path).unwrap().read_to_end(&mut contents).unwrap(); - - out.push_str(&format!("{}: {}\n", arg, hash(&contents))); - } - - File::create(dst).unwrap().write_all(out.as_bytes()).unwrap(); -} - -// fnv hash for now -fn hash(contents: &[u8]) -> u64 { - let mut hash = 0xcbf29ce484222325; - - for byte in contents { - hash = hash ^ (*byte as u64); - hash = hash.wrapping_mul(0x100000001b3); - } - - hash -} diff --git a/src/test/run-make/reproducible-build/reproducible-build-aux.rs b/src/test/run-make/reproducible-build/reproducible-build-aux.rs deleted file mode 100644 index 9ef853e7996..00000000000 --- a/src/test/run-make/reproducible-build/reproducible-build-aux.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub static STATIC: i32 = 1234; - -pub struct Struct { - _t1: std::marker::PhantomData, - _t2: std::marker::PhantomData, -} - -pub fn regular_fn(_: i32) {} - -pub fn generic_fn() {} - -impl Drop for Struct { - fn drop(&mut self) {} -} - -pub enum Enum { - Variant1, - Variant2(u32), - Variant3 { x: u32 } -} - -pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64); - -pub trait Trait { - fn foo(&self); -} diff --git a/src/test/run-make/reproducible-build/reproducible-build.rs b/src/test/run-make/reproducible-build/reproducible-build.rs deleted file mode 100644 index a040c0f858d..00000000000 --- a/src/test/run-make/reproducible-build/reproducible-build.rs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This test case makes sure that two identical invocations of the compiler -// (i.e. same code base, same compile-flags, same compiler-versions, etc.) -// produce the same output. In the past, symbol names of monomorphized functions -// were not deterministic (which we want to avoid). -// -// The test tries to exercise as many different paths into symbol name -// generation as possible: -// -// - regular functions -// - generic functions -// - methods -// - statics -// - closures -// - enum variant constructors -// - tuple struct constructors -// - drop glue -// - FnOnce adapters -// - Trait object shims -// - Fn Pointer shims - -#![allow(dead_code, warnings)] - -extern crate reproducible_build_aux; - -static STATIC: i32 = 1234; - -pub struct Struct { - x: T1, - y: T2, -} - -fn regular_fn(_: i32) {} - -fn generic_fn() {} - -impl Drop for Struct { - fn drop(&mut self) {} -} - -pub enum Enum { - Variant1, - Variant2(u32), - Variant3 { x: u32 } -} - -struct TupleStruct(i8, i16, i32, i64); - -impl TupleStruct { - pub fn bar(&self) {} -} - -trait Trait { - fn foo(&self); -} - -impl Trait for u64 { - fn foo(&self) {} -} - -impl reproducible_build_aux::Trait for TupleStruct { - fn foo(&self) {} -} - -fn main() { - regular_fn(STATIC); - generic_fn::(); - generic_fn::>(); - generic_fn::, reproducible_build_aux::Struct>(); - - let dropped = Struct { - x: "", - y: 'a', - }; - - let _ = Enum::Variant1; - let _ = Enum::Variant2(0); - let _ = Enum::Variant3 { x: 0 }; - let _ = TupleStruct(1, 2, 3, 4); - - let closure = |x| { - x + 1i32 - }; - - fn inner i32>(f: F) -> i32 { - f(STATIC) - } - - println!("{}", inner(closure)); - - let object_shim: &Trait = &0u64; - object_shim.foo(); - - fn with_fn_once_adapter(f: F) { - f(0); - } - - with_fn_once_adapter(|_:i32| { }); - - reproducible_build_aux::regular_fn(STATIC); - reproducible_build_aux::generic_fn::(); - reproducible_build_aux::generic_fn::>(); - reproducible_build_aux::generic_fn::, - reproducible_build_aux::Struct>(); - - let _ = reproducible_build_aux::Enum::Variant1; - let _ = reproducible_build_aux::Enum::Variant2(0); - let _ = reproducible_build_aux::Enum::Variant3 { x: 0 }; - let _ = reproducible_build_aux::TupleStruct(1, 2, 3, 4); - - let object_shim: &reproducible_build_aux::Trait = &TupleStruct(0, 1, 2, 3); - object_shim.foo(); - - let pointer_shim: &Fn(i32) = ®ular_fn; - - TupleStruct(1, 2, 3, 4).bar(); -} diff --git a/src/test/run-make/rlib-chain/Makefile b/src/test/run-make/rlib-chain/Makefile deleted file mode 100644 index 30b6811a388..00000000000 --- a/src/test/run-make/rlib-chain/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) m1.rs - $(RUSTC) m2.rs - $(RUSTC) m3.rs - $(RUSTC) m4.rs - $(call RUN,m4) - rm $(TMPDIR)/*lib - $(call RUN,m4) diff --git a/src/test/run-make/rlib-chain/m1.rs b/src/test/run-make/rlib-chain/m1.rs deleted file mode 100644 index e3afa352938..00000000000 --- a/src/test/run-make/rlib-chain/m1.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -pub fn m1() {} diff --git a/src/test/run-make/rlib-chain/m2.rs b/src/test/run-make/rlib-chain/m2.rs deleted file mode 100644 index 2b4c181134b..00000000000 --- a/src/test/run-make/rlib-chain/m2.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -extern crate m1; - -pub fn m2() { m1::m1() } diff --git a/src/test/run-make/rlib-chain/m3.rs b/src/test/run-make/rlib-chain/m3.rs deleted file mode 100644 index 6323a9e65aa..00000000000 --- a/src/test/run-make/rlib-chain/m3.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -extern crate m2; - -pub fn m3() { m2::m2() } diff --git a/src/test/run-make/rlib-chain/m4.rs b/src/test/run-make/rlib-chain/m4.rs deleted file mode 100644 index 6c2a6685802..00000000000 --- a/src/test/run-make/rlib-chain/m4.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate m3; - -fn main() { m3::m3() } diff --git a/src/test/run-make/rustc-macro-dep-files/Makefile b/src/test/run-make/rustc-macro-dep-files/Makefile deleted file mode 100644 index d2c8e7fd043..00000000000 --- a/src/test/run-make/rustc-macro-dep-files/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs --emit dep-info - $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d -endif diff --git a/src/test/run-make/rustc-macro-dep-files/bar.rs b/src/test/run-make/rustc-macro-dep-files/bar.rs deleted file mode 100644 index 03330c3d170..00000000000 --- a/src/test/run-make/rustc-macro-dep-files/bar.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate foo; - -#[derive(A)] -struct A; - -fn main() { - let _b = B; -} diff --git a/src/test/run-make/rustc-macro-dep-files/foo.rs b/src/test/run-make/rustc-macro-dep-files/foo.rs deleted file mode 100644 index 2f2524f6ef1..00000000000 --- a/src/test/run-make/rustc-macro-dep-files/foo.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert!(input.contains("struct A;")); - "struct B;".parse().unwrap() -} diff --git a/src/test/run-make/rustdoc-error-lines/Makefile b/src/test/run-make/rustdoc-error-lines/Makefile deleted file mode 100644 index 0019e5ee794..00000000000 --- a/src/test/run-make/rustdoc-error-lines/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -# Test that hir-tree output doens't crash and includes -# the string constant we would expect to see. - -all: - $(RUSTDOC) --test input.rs > $(TMPDIR)/output || true - $(CGREP) 'input.rs:17:15' < $(TMPDIR)/output diff --git a/src/test/run-make/rustdoc-error-lines/input.rs b/src/test/run-make/rustdoc-error-lines/input.rs deleted file mode 100644 index 6dc7060bc48..00000000000 --- a/src/test/run-make/rustdoc-error-lines/input.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test for #45868 - -// random #![feature] to ensure that crate attrs -// do not offset things -/// ```rust -/// #![feature(nll)] -/// let x: char = 1; -/// ``` -pub fn foo() { - -} diff --git a/src/test/run-make/rustdoc-output-path/Makefile b/src/test/run-make/rustdoc-output-path/Makefile deleted file mode 100644 index 8ce1c699526..00000000000 --- a/src/test/run-make/rustdoc-output-path/Makefile +++ /dev/null @@ -1,4 +0,0 @@ --include ../tools.mk - -all: - $(RUSTDOC) -o "$(TMPDIR)/foo/bar/doc" foo.rs diff --git a/src/test/run-make/rustdoc-output-path/foo.rs b/src/test/run-make/rustdoc-output-path/foo.rs deleted file mode 100644 index 11fc2cd2b8d..00000000000 --- a/src/test/run-make/rustdoc-output-path/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Foo; diff --git a/src/test/run-make/sanitizer-address/Makefile b/src/test/run-make/sanitizer-address/Makefile deleted file mode 100644 index 207615bfbd5..00000000000 --- a/src/test/run-make/sanitizer-address/Makefile +++ /dev/null @@ -1,29 +0,0 @@ --include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# NOTE the address sanitizer only supports x86_64 linux and macOS - -ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG=-C rpath -else -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) - -# Apparently there are very specific Linux kernels, notably the one that's -# currently on Travis CI, which contain a buggy commit that triggers failures in -# the ASan implementation, detailed at google/sanitizers#837. As noted in -# google/sanitizers#856 the "fix" is to avoid using PIE binaries, so we pass a -# different relocation model to avoid generating a PIE binary. Once Travis is no -# longer running kernel 4.4.0-93 we can remove this and pass an empty set of -# flags again. -EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic -endif -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan - $(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make/sanitizer-address/overflow.rs b/src/test/run-make/sanitizer-address/overflow.rs deleted file mode 100644 index 1f3c64c8c32..00000000000 --- a/src/test/run-make/sanitizer-address/overflow.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-cdylib-link/Makefile b/src/test/run-make/sanitizer-cdylib-link/Makefile deleted file mode 100644 index bea5519ec5f..00000000000 --- a/src/test/run-make/sanitizer-cdylib-link/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# This test builds a shared object, then an executable that links it as a native -# rust library (constrast to an rlib). The shared library and executable both -# are compiled with address sanitizer, and we assert that a fault in the cdylib -# is correctly detected. - -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) - -# See comment in sanitizer-address/Makefile for why this is here -EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make/sanitizer-cdylib-link/library.rs b/src/test/run-make/sanitizer-cdylib-link/library.rs deleted file mode 100644 index 4ceef5d3f52..00000000000 --- a/src/test/run-make/sanitizer-cdylib-link/library.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn overflow() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-cdylib-link/program.rs b/src/test/run-make/sanitizer-cdylib-link/program.rs deleted file mode 100644 index 9f52817c851..00000000000 --- a/src/test/run-make/sanitizer-cdylib-link/program.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - fn overflow(); -} - -fn main() { - unsafe { overflow() } -} diff --git a/src/test/run-make/sanitizer-dylib-link/Makefile b/src/test/run-make/sanitizer-dylib-link/Makefile deleted file mode 100644 index 0cc8f73da8b..00000000000 --- a/src/test/run-make/sanitizer-dylib-link/Makefile +++ /dev/null @@ -1,22 +0,0 @@ --include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# This test builds a shared object, then an executable that links it as a native -# rust library (constrast to an rlib). The shared library and executable both -# are compiled with address sanitizer, and we assert that a fault in the dylib -# is correctly detected. - -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) - -# See comment in sanitizer-address/Makefile for why this is here -EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif diff --git a/src/test/run-make/sanitizer-dylib-link/library.rs b/src/test/run-make/sanitizer-dylib-link/library.rs deleted file mode 100644 index 4ceef5d3f52..00000000000 --- a/src/test/run-make/sanitizer-dylib-link/library.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn overflow() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-dylib-link/program.rs b/src/test/run-make/sanitizer-dylib-link/program.rs deleted file mode 100644 index 9f52817c851..00000000000 --- a/src/test/run-make/sanitizer-dylib-link/program.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern { - fn overflow(); -} - -fn main() { - unsafe { overflow() } -} diff --git a/src/test/run-make/sanitizer-invalid-cratetype/Makefile b/src/test/run-make/sanitizer-invalid-cratetype/Makefile deleted file mode 100644 index dc37c0d0bc9..00000000000 --- a/src/test/run-make/sanitizer-invalid-cratetype/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -# NOTE the address sanitizer only supports x86_64 linux and macOS - -ifeq ($(TARGET),x86_64-apple-darwin) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG=-C rpath -else -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG= -endif -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | $(CGREP) '-Z sanitizer' -endif diff --git a/src/test/run-make/sanitizer-invalid-cratetype/hello.rs b/src/test/run-make/sanitizer-invalid-cratetype/hello.rs deleted file mode 100644 index 41782851a1a..00000000000 --- a/src/test/run-make/sanitizer-invalid-cratetype/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello, world!"); -} diff --git a/src/test/run-make/sanitizer-invalid-target/Makefile b/src/test/run-make/sanitizer-invalid-target/Makefile deleted file mode 100644 index df8afee15ce..00000000000 --- a/src/test/run-make/sanitizer-invalid-target/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -Z sanitizer=leak --target i686-unknown-linux-gnu hello.rs 2>&1 | \ - $(CGREP) 'LeakSanitizer only works with the `x86_64-unknown-linux-gnu` target' diff --git a/src/test/run-make/sanitizer-invalid-target/hello.rs b/src/test/run-make/sanitizer-invalid-target/hello.rs deleted file mode 100644 index e9e46b7702a..00000000000 --- a/src/test/run-make/sanitizer-invalid-target/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![no_main] diff --git a/src/test/run-make/sanitizer-leak/Makefile b/src/test/run-make/sanitizer-leak/Makefile deleted file mode 100644 index ab43fac2e99..00000000000 --- a/src/test/run-make/sanitizer-leak/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -# FIXME(#46126) ThinLTO for libstd broke this test -ifeq (1,0) -all: -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ifdef SANITIZER_SUPPORT - $(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) librustc_lsan - $(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks' -endif -endif - -else -all: -endif - diff --git a/src/test/run-make/sanitizer-leak/leak.rs b/src/test/run-make/sanitizer-leak/leak.rs deleted file mode 100644 index 279da6aaae7..00000000000 --- a/src/test/run-make/sanitizer-leak/leak.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem; - -fn main() { - let xs = vec![1, 2, 3, 4]; - mem::forget(xs); -} diff --git a/src/test/run-make/sanitizer-memory/Makefile b/src/test/run-make/sanitizer-memory/Makefile deleted file mode 100644 index 3507ca2bef2..00000000000 --- a/src/test/run-make/sanitizer-memory/Makefile +++ /dev/null @@ -1,10 +0,0 @@ --include ../tools.mk - -all: -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ifdef SANITIZER_SUPPORT - $(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | $(CGREP) librustc_msan - $(TMPDIR)/uninit 2>&1 | $(CGREP) use-of-uninitialized-value -endif -endif - diff --git a/src/test/run-make/sanitizer-memory/uninit.rs b/src/test/run-make/sanitizer-memory/uninit.rs deleted file mode 100644 index 8350c7de3ac..00000000000 --- a/src/test/run-make/sanitizer-memory/uninit.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::mem; - -fn main() { - let xs: [u8; 4] = unsafe { mem::uninitialized() }; - let y = xs[0] + xs[1]; -} diff --git a/src/test/run-make/sanitizer-staticlib-link/Makefile b/src/test/run-make/sanitizer-staticlib-link/Makefile deleted file mode 100644 index 2b444d667bf..00000000000 --- a/src/test/run-make/sanitizer-staticlib-link/Makefile +++ /dev/null @@ -1,18 +0,0 @@ --include ../tools.mk - -# This test builds a staticlib, then an executable that links to it. -# The staticlib and executable both are compiled with address sanitizer, -# and we assert that a fault in the staticlib is correctly detected. - -ifeq ($(TARGET),x86_64-unknown-linux-gnu) -ASAN_SUPPORT=$(SANITIZER_SUPPORT) -EXTRA_RUSTFLAG= -endif - -all: -ifeq ($(ASAN_SUPPORT),1) - $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs - $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow -endif - diff --git a/src/test/run-make/sanitizer-staticlib-link/library.rs b/src/test/run-make/sanitizer-staticlib-link/library.rs deleted file mode 100644 index 4ceef5d3f52..00000000000 --- a/src/test/run-make/sanitizer-staticlib-link/library.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[no_mangle] -pub extern fn overflow() { - let xs = [0, 1, 2, 3]; - let _y = unsafe { *xs.as_ptr().offset(4) }; -} diff --git a/src/test/run-make/sanitizer-staticlib-link/program.c b/src/test/run-make/sanitizer-staticlib-link/program.c deleted file mode 100644 index abd5d508e72..00000000000 --- a/src/test/run-make/sanitizer-staticlib-link/program.c +++ /dev/null @@ -1,8 +0,0 @@ -// ignore-license -void overflow(); - -int main() { - overflow(); - return 0; -} - diff --git a/src/test/run-make/save-analysis-fail/Makefile b/src/test/run-make/save-analysis-fail/Makefile deleted file mode 100644 index f29f907cf38..00000000000 --- a/src/test/run-make/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/src/test/run-make/save-analysis-fail/SameDir.rs b/src/test/run-make/save-analysis-fail/SameDir.rs deleted file mode 100644 index fe70ac1edef..00000000000 --- a/src/test/run-make/save-analysis-fail/SameDir.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// sub-module in the same directory as the main crate file - -pub struct SameStruct { - pub name: String -} diff --git a/src/test/run-make/save-analysis-fail/SameDir3.rs b/src/test/run-make/save-analysis-fail/SameDir3.rs deleted file mode 100644 index 315f900868b..00000000000 --- a/src/test/run-make/save-analysis-fail/SameDir3.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn hello(x: isize) { - println!("macro {} :-(", x); -} diff --git a/src/test/run-make/save-analysis-fail/SubDir/mod.rs b/src/test/run-make/save-analysis-fail/SubDir/mod.rs deleted file mode 100644 index fe84db08da9..00000000000 --- a/src/test/run-make/save-analysis-fail/SubDir/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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/src/test/run-make/save-analysis-fail/foo.rs b/src/test/run-make/save-analysis-fail/foo.rs deleted file mode 100644 index b844f2e49e7..00000000000 --- a/src/test/run-make/save-analysis-fail/foo.rs +++ /dev/null @@ -1,468 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ crate_name = "test" ] -#![feature(box_syntax)] -#![feature(rustc_private)] - -extern crate graphviz; -// A simple rust project - -extern crate krate2; -extern crate krate2 as krate3; - -use graphviz::RenderOption; -use std::collections::{HashMap,HashSet}; -use std::cell::RefCell; -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 = None; - -// buglink test - see issue #1337. - -fn test_alias(i: Option<::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); - -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(&mut self) { - - } - - fn test(&mut self) { - self.align_to::(); - } -} - -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, Box) {} - -fn f_with_params(x: &T) { - x.Method(41); -} - -type MyType = Box; - -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((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 = box some_fields {field1: 43}; - let s2: Box = box some_fields {field1: 43}; - let s3 = box 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; - 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 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> = 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 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 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 some_fields{ field1:10 }, - f2: box 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) { - panic!() - } -} - -trait Pattern<'a> { - type Searcher; -} - -struct CharEqPattern; - -impl<'a> Pattern<'a> for CharEqPattern { - type Searcher = CharEqPattern; -} - -struct CharSearcher<'a>(>::Searcher); - -pub trait Error { -} - -impl Error + 'static { - pub fn is(&self) -> bool { - panic!() - } -} - -impl Error + 'static + Send { - pub fn is(&self) -> bool { - ::is::(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 { - 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/src/test/run-make/save-analysis-fail/krate2.rs b/src/test/run-make/save-analysis-fail/krate2.rs deleted file mode 100644 index 2c6f517ff38..00000000000 --- a/src/test/run-make/save-analysis-fail/krate2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ 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/src/test/run-make/save-analysis/Makefile b/src/test/run-make/save-analysis/Makefile deleted file mode 100644 index 7296fb9cc59..00000000000 --- a/src/test/run-make/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/src/test/run-make/save-analysis/SameDir.rs b/src/test/run-make/save-analysis/SameDir.rs deleted file mode 100644 index fe70ac1edef..00000000000 --- a/src/test/run-make/save-analysis/SameDir.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// sub-module in the same directory as the main crate file - -pub struct SameStruct { - pub name: String -} diff --git a/src/test/run-make/save-analysis/SameDir3.rs b/src/test/run-make/save-analysis/SameDir3.rs deleted file mode 100644 index 315f900868b..00000000000 --- a/src/test/run-make/save-analysis/SameDir3.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn hello(x: isize) { - println!("macro {} :-(", x); -} diff --git a/src/test/run-make/save-analysis/SubDir/mod.rs b/src/test/run-make/save-analysis/SubDir/mod.rs deleted file mode 100644 index fe84db08da9..00000000000 --- a/src/test/run-make/save-analysis/SubDir/mod.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// 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/src/test/run-make/save-analysis/extra-docs.md b/src/test/run-make/save-analysis/extra-docs.md deleted file mode 100644 index 0605ca517ff..00000000000 --- a/src/test/run-make/save-analysis/extra-docs.md +++ /dev/null @@ -1 +0,0 @@ -Extra docs for this struct. diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs deleted file mode 100644 index 5b4e4802957..00000000000 --- a/src/test/run-make/save-analysis/foo.rs +++ /dev/null @@ -1,467 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ crate_name = "test" ] -#![feature(box_syntax)] -#![feature(rustc_private)] -#![feature(associated_type_defaults)] -#![feature(external_doc)] - -extern crate graphviz; -// A simple rust project - -extern crate krate2; -extern crate krate2 as krate3; - -use graphviz::RenderOption; -use std::collections::{HashMap,HashSet}; -use std::cell::RefCell; -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 = None; - -// buglink test - see issue #1337. - -fn test_alias(i: Option<::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); - -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(&mut self) { - - } - - fn test(&mut self) { - self.align_to::(); - } -} - -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, Box) {} - -fn f_with_params(x: &T) { - x.Method(41); -} - -type MyType = Box; - -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((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 = box some_fields {field1: 43}; - let s2: Box = box some_fields {field1: 43}; - let s3 = box 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; - 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 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> = 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 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 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 some_fields{ field1:10 }, - f2: box 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) { - panic!() - } -} - -trait Pattern<'a> { - type Searcher; -} - -struct CharEqPattern; - -impl<'a> Pattern<'a> for CharEqPattern { - type Searcher = CharEqPattern; -} - -struct CharSearcher<'a>(>::Searcher); - -pub trait Error { -} - -impl Error + 'static { - pub fn is(&self) -> bool { - panic!() - } -} - -impl Error + 'static + Send { - pub fn is(&self) -> bool { - ::is::(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); -} - - -union TestUnion { - f1: u32 -} - -struct FrameBuffer; - -struct SilenceGenerator; - -impl Iterator for SilenceGenerator { - type Item = FrameBuffer; - - fn next(&mut self) -> Option { - panic!(); - } -} - -trait Foo { - type Bar = FrameBuffer; -} - -#[doc(include="extra-docs.md")] -struct StructWithDocs; diff --git a/src/test/run-make/save-analysis/krate2.rs b/src/test/run-make/save-analysis/krate2.rs deleted file mode 100644 index 2c6f517ff38..00000000000 --- a/src/test/run-make/save-analysis/krate2.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![ 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/src/test/run-make/sepcomp-cci-copies/Makefile b/src/test/run-make/sepcomp-cci-copies/Makefile deleted file mode 100644 index 36f913ff3fa..00000000000 --- a/src/test/run-make/sepcomp-cci-copies/Makefile +++ /dev/null @@ -1,12 +0,0 @@ --include ../tools.mk - -# Check that cross-crate inlined items are inlined in all compilation units -# that refer to them, and not in any other compilation units. -# Note that we have to pass `-C codegen-units=6` because up to two CGUs may be -# created for each source module (see `rustc_mir::monomorphize::partitioning`). - -all: - $(RUSTC) cci_lib.rs - $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=6 \ - -Z inline-in-all-cgus - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*cci_fn)" -eq "2" ] diff --git a/src/test/run-make/sepcomp-cci-copies/cci_lib.rs b/src/test/run-make/sepcomp-cci-copies/cci_lib.rs deleted file mode 100644 index 62bc3294286..00000000000 --- a/src/test/run-make/sepcomp-cci-copies/cci_lib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -#[inline] -pub fn cci_fn() -> usize { - 1234 -} diff --git a/src/test/run-make/sepcomp-cci-copies/foo.rs b/src/test/run-make/sepcomp-cci-copies/foo.rs deleted file mode 100644 index e00cab20f6b..00000000000 --- a/src/test/run-make/sepcomp-cci-copies/foo.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate cci_lib; -use cci_lib::cci_fn; - -fn call1() -> usize { - cci_fn() -} - -mod a { - use cci_lib::cci_fn; - pub fn call2() -> usize { - cci_fn() - } -} - -mod b { - pub fn call3() -> usize { - 0 - } -} - -fn main() { - call1(); - a::call2(); - b::call3(); -} diff --git a/src/test/run-make/sepcomp-inlining/Makefile b/src/test/run-make/sepcomp-inlining/Makefile deleted file mode 100644 index 1d20d940000..00000000000 --- a/src/test/run-make/sepcomp-inlining/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# Test that #[inline] functions still get inlined across compilation unit -# boundaries. Compilation should produce three IR files, but only the two -# compilation units that have a usage of the #[inline] function should -# contain a definition. Also, the non-#[inline] function should be defined -# in only one compilation unit. - -all: - $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 \ - -Z inline-in-all-cgus - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ i32\ .*inlined)" -eq "0" ] - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ internal\ i32\ .*inlined)" -eq "2" ] - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ hidden\ i32\ .*normal)" -eq "1" ] - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c declare\ hidden\ i32\ .*normal)" -eq "2" ] diff --git a/src/test/run-make/sepcomp-inlining/foo.rs b/src/test/run-make/sepcomp-inlining/foo.rs deleted file mode 100644 index 5b62c1b0626..00000000000 --- a/src/test/run-make/sepcomp-inlining/foo.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(start)] - -#[inline] -fn inlined() -> u32 { - 1234 -} - -fn normal() -> u32 { - 2345 -} - -mod a { - pub fn f() -> u32 { - ::inlined() + ::normal() - } -} - -mod b { - pub fn f() -> u32 { - ::inlined() + ::normal() - } -} - -#[start] -fn start(_: isize, _: *const *const u8) -> isize { - a::f(); - b::f(); - - 0 -} diff --git a/src/test/run-make/sepcomp-separate/Makefile b/src/test/run-make/sepcomp-separate/Makefile deleted file mode 100644 index 5b8bdb0fad8..00000000000 --- a/src/test/run-make/sepcomp-separate/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# Test that separate compilation actually puts code into separate compilation -# units. `foo.rs` defines `magic_fn` in three different modules, which should -# wind up in three different compilation units. - -all: - $(RUSTC) foo.rs --emit=llvm-ir -C codegen-units=3 - [ "$$(cat "$(TMPDIR)"/foo.*.ll | grep -c define\ .*magic_fn)" -eq "3" ] diff --git a/src/test/run-make/sepcomp-separate/foo.rs b/src/test/run-make/sepcomp-separate/foo.rs deleted file mode 100644 index 64a76e9e0ed..00000000000 --- a/src/test/run-make/sepcomp-separate/foo.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - - -fn magic_fn() -> usize { - 1234 -} - -mod a { - pub fn magic_fn() -> usize { - 2345 - } -} - -mod b { - pub fn magic_fn() -> usize { - 3456 - } -} - -fn main() { - magic_fn(); - a::magic_fn(); - b::magic_fn(); -} diff --git a/src/test/run-make/simd-ffi/Makefile b/src/test/run-make/simd-ffi/Makefile deleted file mode 100644 index e9c974a0137..00000000000 --- a/src/test/run-make/simd-ffi/Makefile +++ /dev/null @@ -1,47 +0,0 @@ --include ../tools.mk - -TARGETS = -ifeq ($(filter arm,$(LLVM_COMPONENTS)),arm) -# construct a fairly exhaustive list of platforms that we -# support. These ones don't follow a pattern -TARGETS += arm-linux-androideabi arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabi -endif - -ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86) -X86_ARCHS = i686 x86_64 -else -X86_ARCHS = -endif - -# these ones do, each OS lists the architectures it supports -LINUX=$(filter aarch64 mips,$(LLVM_COMPONENTS)) $(X86_ARCHS) -ifeq ($(filter mips,$(LLVM_COMPONENTS)),mips) -LINUX += mipsel -endif - -WINDOWS=$(X86_ARCHS) -# fails with: failed to get iphonesimulator SDK path: no such file or directory -#IOS=i386 aarch64 armv7 -DARWIN=$(X86_ARCHS) - -$(foreach arch,$(LINUX),$(eval TARGETS += $(arch)-unknown-linux-gnu)) -$(foreach arch,$(WINDOWS),$(eval TARGETS += $(arch)-pc-windows-gnu)) -#$(foreach arch,$(IOS),$(eval TARGETS += $(arch)-apple-ios)) -$(foreach arch,$(DARWIN),$(eval TARGETS += $(arch)-apple-darwin)) - -all: $(TARGETS) - -define MK_TARGETS -# compile the rust file to the given target, but only to asm and IR -# form, to avoid having to have an appropriate linker. -# -# we need some features because the integer SIMD instructions are not -# enabled by-default for i686 and ARM; these features will be invalid -# on some platforms, but LLVM just prints a warning so that's fine for -# now. -$(1): simd.rs - $$(RUSTC) --target=$(1) --emit=llvm-ir,asm simd.rs \ - -C target-feature='+neon,+sse2' -C extra-filename=-$(1) -endef - -$(foreach targetxxx,$(TARGETS),$(eval $(call MK_TARGETS,$(targetxxx)))) diff --git a/src/test/run-make/simd-ffi/simd.rs b/src/test/run-make/simd-ffi/simd.rs deleted file mode 100644 index 94b91c711cc..00000000000 --- a/src/test/run-make/simd-ffi/simd.rs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ensures that public symbols are not removed completely -#![crate_type = "lib"] -// we can compile to a variety of platforms, because we don't need -// cross-compiled standard libraries. -#![feature(no_core, optin_builtin_traits)] -#![no_core] - -#![feature(repr_simd, simd_ffi, link_llvm_intrinsics, lang_items)] - - -#[repr(C)] -#[derive(Copy)] -#[repr(simd)] -pub struct f32x4(f32, f32, f32, f32); - - -extern { - #[link_name = "llvm.sqrt.v4f32"] - fn vsqrt(x: f32x4) -> f32x4; -} - -pub fn foo(x: f32x4) -> f32x4 { - unsafe {vsqrt(x)} -} - -#[repr(C)] -#[derive(Copy)] -#[repr(simd)] -pub struct i32x4(i32, i32, i32, i32); - - -extern { - // _mm_sll_epi32 - #[cfg(any(target_arch = "x86", - target_arch = "x86-64"))] - #[link_name = "llvm.x86.sse2.psll.d"] - fn integer(a: i32x4, b: i32x4) -> i32x4; - - // vmaxq_s32 - #[cfg(target_arch = "arm")] - #[link_name = "llvm.arm.neon.vmaxs.v4i32"] - fn integer(a: i32x4, b: i32x4) -> i32x4; - // vmaxq_s32 - #[cfg(target_arch = "aarch64")] - #[link_name = "llvm.aarch64.neon.maxs.v4i32"] - fn integer(a: i32x4, b: i32x4) -> i32x4; - - // just some substitute foreign symbol, not an LLVM intrinsic; so - // we still get type checking, but not as detailed as (ab)using - // LLVM. - #[cfg(not(any(target_arch = "x86", - target_arch = "x86-64", - target_arch = "arm", - target_arch = "aarch64")))] - fn integer(a: i32x4, b: i32x4) -> i32x4; -} - -pub fn bar(a: i32x4, b: i32x4) -> i32x4 { - unsafe {integer(a, b)} -} - -#[lang = "sized"] -pub trait Sized { } - -#[lang = "copy"] -pub trait Copy { } - -pub mod marker { - pub use Copy; -} - -#[lang = "freeze"] -auto trait Freeze {} diff --git a/src/test/run-make/simple-dylib/Makefile b/src/test/run-make/simple-dylib/Makefile deleted file mode 100644 index 26730820fea..00000000000 --- a/src/test/run-make/simple-dylib/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk -all: - $(RUSTC) bar.rs --crate-type=dylib -C prefer-dynamic - $(RUSTC) foo.rs - $(call RUN,foo) diff --git a/src/test/run-make/simple-dylib/bar.rs b/src/test/run-make/simple-dylib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/simple-dylib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/simple-dylib/foo.rs b/src/test/run-make/simple-dylib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/simple-dylib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/simple-rlib/Makefile b/src/test/run-make/simple-rlib/Makefile deleted file mode 100644 index 7b156cb8748..00000000000 --- a/src/test/run-make/simple-rlib/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk -all: - $(RUSTC) bar.rs --crate-type=rlib - $(RUSTC) foo.rs - $(call RUN,foo) diff --git a/src/test/run-make/simple-rlib/bar.rs b/src/test/run-make/simple-rlib/bar.rs deleted file mode 100644 index 4c79f7e2855..00000000000 --- a/src/test/run-make/simple-rlib/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/simple-rlib/foo.rs b/src/test/run-make/simple-rlib/foo.rs deleted file mode 100644 index 858ef492ace..00000000000 --- a/src/test/run-make/simple-rlib/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; - -fn main() { - bar::bar(); -} diff --git a/src/test/run-make/stable-symbol-names/Makefile b/src/test/run-make/stable-symbol-names/Makefile deleted file mode 100644 index 3cbc5593ac0..00000000000 --- a/src/test/run-make/stable-symbol-names/Makefile +++ /dev/null @@ -1,40 +0,0 @@ --include ../tools.mk - -# The following command will: -# 1. dump the symbols of a library using `nm` -# 2. extract only those lines that we are interested in via `grep` -# 3. from those lines, extract just the symbol name via `sed` -# (symbol names always start with "_ZN" and end with "E") -# 4. sort those symbol names for deterministic comparison -# 5. write the result into a file - -dump-symbols = nm "$(TMPDIR)/lib$(1).rlib" \ - | grep -E "$(2)" \ - | sed "s/.*\(_ZN.*E\).*/\1/" \ - | sort \ - > "$(TMPDIR)/$(1)$(3).nm" - -# This test -# - compiles each of the two crates 2 times and makes sure each time we get -# exactly the same symbol names -# - makes sure that both crates agree on the same symbol names for monomorphic -# functions - -all: - $(RUSTC) stable-symbol-names1.rs - $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v1) - rm $(TMPDIR)/libstable_symbol_names1.rlib - $(RUSTC) stable-symbol-names1.rs - $(call dump-symbols,stable_symbol_names1,generic_|mono_,_v2) - cmp "$(TMPDIR)/stable_symbol_names1_v1.nm" "$(TMPDIR)/stable_symbol_names1_v2.nm" - - $(RUSTC) stable-symbol-names2.rs - $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v1) - rm $(TMPDIR)/libstable_symbol_names2.rlib - $(RUSTC) stable-symbol-names2.rs - $(call dump-symbols,stable_symbol_names2,generic_|mono_,_v2) - cmp "$(TMPDIR)/stable_symbol_names2_v1.nm" "$(TMPDIR)/stable_symbol_names2_v2.nm" - - $(call dump-symbols,stable_symbol_names1,mono_,_cross) - $(call dump-symbols,stable_symbol_names2,mono_,_cross) - cmp "$(TMPDIR)/stable_symbol_names1_cross.nm" "$(TMPDIR)/stable_symbol_names2_cross.nm" diff --git a/src/test/run-make/stable-symbol-names/stable-symbol-names1.rs b/src/test/run-make/stable-symbol-names/stable-symbol-names1.rs deleted file mode 100644 index 7344bdf49f6..00000000000 --- a/src/test/run-make/stable-symbol-names/stable-symbol-names1.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -pub trait Foo { - fn generic_method(); -} - -pub struct Bar; - -impl Foo for Bar { - fn generic_method() {} -} - -pub fn mono_function() { - Bar::generic_method::(); -} - -pub fn mono_function_lifetime<'a>(x: &'a u64) -> u64 { - *x -} - -pub fn generic_function(t: T) -> T { - t -} - -pub fn user() { - generic_function(0u32); - generic_function("abc"); - let x = 2u64; - generic_function(&x); - let _ = mono_function_lifetime(&x); -} diff --git a/src/test/run-make/stable-symbol-names/stable-symbol-names2.rs b/src/test/run-make/stable-symbol-names/stable-symbol-names2.rs deleted file mode 100644 index eacba4ddb25..00000000000 --- a/src/test/run-make/stable-symbol-names/stable-symbol-names2.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -extern crate stable_symbol_names1; - -pub fn user() { - stable_symbol_names1::generic_function(1u32); - stable_symbol_names1::generic_function("def"); - let x = 2u64; - stable_symbol_names1::generic_function(&x); - stable_symbol_names1::mono_function(); - stable_symbol_names1::mono_function_lifetime(&0); -} - -pub fn trait_impl_test_function() { - use stable_symbol_names1::*; - Bar::generic_method::(); -} - diff --git a/src/test/run-make/static-dylib-by-default/Makefile b/src/test/run-make/static-dylib-by-default/Makefile deleted file mode 100644 index 6409aa66ae0..00000000000 --- a/src/test/run-make/static-dylib-by-default/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -TO_LINK := $(call DYLIB,bar) -ifdef IS_MSVC -LINK_ARG = $(TO_LINK:dll=dll.lib) -else -LINK_ARG = $(TO_LINK) -endif - -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS) - rm $(TMPDIR)/*.rlib - rm $(call DYLIB,foo) - $(call RUN,main) diff --git a/src/test/run-make/static-dylib-by-default/bar.rs b/src/test/run-make/static-dylib-by-default/bar.rs deleted file mode 100644 index 63da277dece..00000000000 --- a/src/test/run-make/static-dylib-by-default/bar.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -extern crate foo; - -#[no_mangle] -pub extern fn bar() { - foo::foo(); -} diff --git a/src/test/run-make/static-dylib-by-default/foo.rs b/src/test/run-make/static-dylib-by-default/foo.rs deleted file mode 100644 index 341040e653c..00000000000 --- a/src/test/run-make/static-dylib-by-default/foo.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![crate_type = "dylib"] - -pub fn foo() {} diff --git a/src/test/run-make/static-dylib-by-default/main.c b/src/test/run-make/static-dylib-by-default/main.c deleted file mode 100644 index 30bb0783edf..00000000000 --- a/src/test/run-make/static-dylib-by-default/main.c +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern void bar(); - -int main() { - bar(); - return 0; -} diff --git a/src/test/run-make/static-nobundle/Makefile b/src/test/run-make/static-nobundle/Makefile deleted file mode 100644 index abc32d4423b..00000000000 --- a/src/test/run-make/static-nobundle/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -# aaa is a native static library -# bbb is a rlib -# ccc is a dylib -# ddd is an executable - -all: $(call NATIVE_STATICLIB,aaa) - $(RUSTC) bbb.rs --crate-type=rlib - - # Check that bbb does NOT contain the definition of `native_func` - nm $(TMPDIR)/libbbb.rlib | $(CGREP) -ve "T _*native_func" - nm $(TMPDIR)/libbbb.rlib | $(CGREP) -e "U _*native_func" - - # Check that aaa gets linked (either as `-l aaa` or `aaa.lib`) when building ccc. - $(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib -Z print-link-args | $(CGREP) -e '-l[" ]*aaa|aaa\.lib' - - # Check that aaa does NOT get linked when building ddd. - $(RUSTC) ddd.rs -Z print-link-args | $(CGREP) -ve '-l[" ]*aaa|aaa\.lib' - - $(call RUN,ddd) diff --git a/src/test/run-make/static-nobundle/aaa.c b/src/test/run-make/static-nobundle/aaa.c deleted file mode 100644 index 806ef878c70..00000000000 --- a/src/test/run-make/static-nobundle/aaa.c +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -void native_func() {} diff --git a/src/test/run-make/static-nobundle/bbb.rs b/src/test/run-make/static-nobundle/bbb.rs deleted file mode 100644 index 2bd69c99327..00000000000 --- a/src/test/run-make/static-nobundle/bbb.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(static_nobundle)] - -#[link(name = "aaa", kind = "static-nobundle")] -extern { - pub fn native_func(); -} - -pub fn wrapped_func() { - unsafe { - native_func(); - } -} diff --git a/src/test/run-make/static-nobundle/ccc.rs b/src/test/run-make/static-nobundle/ccc.rs deleted file mode 100644 index bd34753a00d..00000000000 --- a/src/test/run-make/static-nobundle/ccc.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -extern crate bbb; - -pub fn do_work() { - unsafe { bbb::native_func(); } - bbb::wrapped_func(); -} - -pub fn do_work_generic() { - unsafe { bbb::native_func(); } - bbb::wrapped_func(); -} diff --git a/src/test/run-make/static-nobundle/ddd.rs b/src/test/run-make/static-nobundle/ddd.rs deleted file mode 100644 index f7d23a899f7..00000000000 --- a/src/test/run-make/static-nobundle/ddd.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate ccc; - -fn main() { - ccc::do_work(); - ccc::do_work_generic::(); - ccc::do_work_generic::(); -} diff --git a/src/test/run-make/static-unwinding/Makefile b/src/test/run-make/static-unwinding/Makefile deleted file mode 100644 index cb039744265..00000000000 --- a/src/test/run-make/static-unwinding/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) lib.rs - $(RUSTC) main.rs - $(call RUN,main) diff --git a/src/test/run-make/static-unwinding/lib.rs b/src/test/run-make/static-unwinding/lib.rs deleted file mode 100644 index 12c72d54c09..00000000000 --- a/src/test/run-make/static-unwinding/lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub static mut statik: isize = 0; - -struct A; -impl Drop for A { - fn drop(&mut self) { - unsafe { statik = 1; } - } -} - -pub fn callback(f: F) where F: FnOnce() { - let _a = A; - f(); -} diff --git a/src/test/run-make/static-unwinding/main.rs b/src/test/run-make/static-unwinding/main.rs deleted file mode 100644 index 1cd785334f6..00000000000 --- a/src/test/run-make/static-unwinding/main.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate lib; - -use std::thread; - -static mut statik: isize = 0; - -struct A; -impl Drop for A { - fn drop(&mut self) { - unsafe { statik = 1; } - } -} - -fn main() { - thread::spawn(move|| { - let _a = A; - lib::callback(|| panic!()); - }).join().unwrap_err(); - - unsafe { - assert_eq!(lib::statik, 1); - assert_eq!(statik, 1); - } -} diff --git a/src/test/run-make/staticlib-blank-lib/Makefile b/src/test/run-make/staticlib-blank-lib/Makefile deleted file mode 100644 index 92a278825c2..00000000000 --- a/src/test/run-make/staticlib-blank-lib/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(AR) crus $(TMPDIR)/libfoo.a foo.rs - $(AR) d $(TMPDIR)/libfoo.a foo.rs - $(RUSTC) foo.rs diff --git a/src/test/run-make/staticlib-blank-lib/foo.rs b/src/test/run-make/staticlib-blank-lib/foo.rs deleted file mode 100644 index 6010e60e95c..00000000000 --- a/src/test/run-make/staticlib-blank-lib/foo.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "staticlib"] - -#[link(name = "foo", kind = "static")] -extern {} - -fn main() {} diff --git a/src/test/run-make/stdin-non-utf8/Makefile b/src/test/run-make/stdin-non-utf8/Makefile deleted file mode 100644 index 7948c442616..00000000000 --- a/src/test/run-make/stdin-non-utf8/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - cp non-utf8 $(TMPDIR)/non-utf.rs - cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \ - | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8" diff --git a/src/test/run-make/stdin-non-utf8/non-utf8 b/src/test/run-make/stdin-non-utf8/non-utf8 deleted file mode 100644 index bc87051a852..00000000000 --- a/src/test/run-make/stdin-non-utf8/non-utf8 +++ /dev/null @@ -1 +0,0 @@ -Ò diff --git a/src/test/run-make/suspicious-library/Makefile b/src/test/run-make/suspicious-library/Makefile deleted file mode 100644 index 12f437075fb..00000000000 --- a/src/test/run-make/suspicious-library/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -C prefer-dynamic - touch $(call DYLIB,foo-something-special) - touch $(call DYLIB,foo-something-special2) - $(RUSTC) bar.rs diff --git a/src/test/run-make/suspicious-library/bar.rs b/src/test/run-make/suspicious-library/bar.rs deleted file mode 100644 index ed0e8a7e23e..00000000000 --- a/src/test/run-make/suspicious-library/bar.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { foo::foo() } diff --git a/src/test/run-make/suspicious-library/foo.rs b/src/test/run-make/suspicious-library/foo.rs deleted file mode 100644 index 2ec6e3834a1..00000000000 --- a/src/test/run-make/suspicious-library/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -pub fn foo() {} diff --git a/src/test/run-make/symbol-visibility/Makefile b/src/test/run-make/symbol-visibility/Makefile deleted file mode 100644 index f1ada814bdb..00000000000 --- a/src/test/run-make/symbol-visibility/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -include ../tools.mk - -ifdef IS_WINDOWS -# Do nothing on MSVC. -# On MINGW the --version-script, --dynamic-list, and --retain-symbol args don't -# seem to work reliably. -all: - exit 0 -else - -NM=nm -D -CDYLIB_NAME=liba_cdylib.so -RDYLIB_NAME=liba_rust_dylib.so -EXE_NAME=an_executable -COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.so - -ifeq ($(UNAME),Darwin) -NM=nm -gU -CDYLIB_NAME=liba_cdylib.dylib -RDYLIB_NAME=liba_rust_dylib.dylib -EXE_NAME=an_executable -COMBINED_CDYLIB_NAME=libcombined_rlib_dylib.dylib -endif - -all: - $(RUSTC) an_rlib.rs - $(RUSTC) a_cdylib.rs - $(RUSTC) a_rust_dylib.rs - $(RUSTC) an_executable.rs - $(RUSTC) a_cdylib.rs --crate-name combined_rlib_dylib --crate-type=rlib,cdylib - - # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] - - # Check that a Rust dylib exports its monomorphic functions - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rust_dylib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ] - - # Check that a Rust dylib exports the monomorphic functions from its dependencies - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - [ "$$($(NM) $(TMPDIR)/$(RDYLIB_NAME) | grep -c public_rust_function_from_rlib)" -eq "1" ] - - # Check that an executable does not export any dynamic symbols - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_c_function_from_rlib)" -eq "0" ] - [ "$$($(NM) $(TMPDIR)/$(EXE_NAME) | grep -c public_rust_function_from_exe)" -eq "0" ] - - - # Check the combined case, where we generate a cdylib and an rlib in the same - # compilation session: - # Check that a cdylib exports its public #[no_mangle] functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_cdylib)" -eq "1" ] - # Check that a cdylib exports the public #[no_mangle] functions of dependencies - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c public_c_function_from_rlib)" -eq "1" ] - # Check that a cdylib DOES NOT export any public Rust functions - [ "$$($(NM) $(TMPDIR)/$(COMBINED_CDYLIB_NAME) | grep -c _ZN.*h.*E)" -eq "0" ] -endif diff --git a/src/test/run-make/symbol-visibility/a_cdylib.rs b/src/test/run-make/symbol-visibility/a_cdylib.rs deleted file mode 100644 index 9a70542c06c..00000000000 --- a/src/test/run-make/symbol-visibility/a_cdylib.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="cdylib"] - -extern crate an_rlib; - -// This should not be exported -pub fn public_rust_function_from_cdylib() {} - -// This should be exported -#[no_mangle] -pub extern "C" fn public_c_function_from_cdylib() { - an_rlib::public_c_function_from_rlib(); -} diff --git a/src/test/run-make/symbol-visibility/a_rust_dylib.rs b/src/test/run-make/symbol-visibility/a_rust_dylib.rs deleted file mode 100644 index b826211c9a4..00000000000 --- a/src/test/run-make/symbol-visibility/a_rust_dylib.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="dylib"] - -extern crate an_rlib; - -// This should be exported -pub fn public_rust_function_from_rust_dylib() {} - -// This should be exported -#[no_mangle] -pub extern "C" fn public_c_function_from_rust_dylib() {} diff --git a/src/test/run-make/symbol-visibility/an_executable.rs b/src/test/run-make/symbol-visibility/an_executable.rs deleted file mode 100644 index 73059c5e374..00000000000 --- a/src/test/run-make/symbol-visibility/an_executable.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="bin"] - -extern crate an_rlib; - -pub fn public_rust_function_from_exe() {} - -fn main() {} diff --git a/src/test/run-make/symbol-visibility/an_rlib.rs b/src/test/run-make/symbol-visibility/an_rlib.rs deleted file mode 100644 index cd19500d140..00000000000 --- a/src/test/run-make/symbol-visibility/an_rlib.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -pub fn public_rust_function_from_rlib() {} - -#[no_mangle] -pub extern "C" fn public_c_function_from_rlib() {} diff --git a/src/test/run-make/symbols-are-reasonable/Makefile b/src/test/run-make/symbols-are-reasonable/Makefile deleted file mode 100644 index a6d294d2a1c..00000000000 --- a/src/test/run-make/symbols-are-reasonable/Makefile +++ /dev/null @@ -1,13 +0,0 @@ --include ../tools.mk - -# check that the compile generated symbols for strings, binaries, -# vtables, etc. have semisane names (e.g. `str.1234`); it's relatively -# easy to accidentally modify the compiler internals to make them -# become things like `str"str"(1234)`. - -OUT=$(TMPDIR)/lib.s - -all: - $(RUSTC) lib.rs --emit=asm --crate-type=staticlib - # just check for symbol declarations with the names we're expecting. - $(CGREP) -e 'str\.[0-9]+:' 'byte_str\.[0-9]+:' 'vtable\.[0-9]+' < $(OUT) diff --git a/src/test/run-make/symbols-are-reasonable/lib.rs b/src/test/run-make/symbols-are-reasonable/lib.rs deleted file mode 100644 index b9285b24cd6..00000000000 --- a/src/test/run-make/symbols-are-reasonable/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub static X: &'static str = "foobarbaz"; -pub static Y: &'static [u8] = include_bytes!("lib.rs"); - -trait Foo { fn dummy(&self) { } } -impl Foo for usize {} - -#[no_mangle] -pub extern "C" fn dummy() { - // force the vtable to be created - let _x = &1usize as &Foo; -} diff --git a/src/test/run-make/symbols-include-type-name/Makefile b/src/test/run-make/symbols-include-type-name/Makefile deleted file mode 100644 index 0850a2633e5..00000000000 --- a/src/test/run-make/symbols-include-type-name/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -# Check that symbol names for methods include type names, instead of . - -OUT=$(TMPDIR)/lib.s - -all: - $(RUSTC) --crate-type staticlib --emit asm lib.rs - $(CGREP) Def < $(OUT) diff --git a/src/test/run-make/symbols-include-type-name/lib.rs b/src/test/run-make/symbols-include-type-name/lib.rs deleted file mode 100644 index d84f1617db5..00000000000 --- a/src/test/run-make/symbols-include-type-name/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct Def { - pub id: i32, -} - -impl Def { - pub fn new(id: i32) -> Def { - Def { id: id } - } -} - -#[no_mangle] -pub fn user() { - let _ = Def::new(0); -} diff --git a/src/test/run-make/symlinked-extern/Makefile b/src/test/run-make/symlinked-extern/Makefile deleted file mode 100644 index 88dbad51e48..00000000000 --- a/src/test/run-make/symlinked-extern/Makefile +++ /dev/null @@ -1,16 +0,0 @@ --include ../tools.mk - -# ignore windows: `ln` is actually `cp` on msys. -ifndef IS_WINDOWS - -all: - $(RUSTC) foo.rs - mkdir -p $(TMPDIR)/other - ln -nsf $(TMPDIR)/libfoo.rlib $(TMPDIR)/other - $(RUSTC) bar.rs -L $(TMPDIR) - $(RUSTC) baz.rs --extern foo=$(TMPDIR)/other/libfoo.rlib -L $(TMPDIR) - -else -all: - -endif diff --git a/src/test/run-make/symlinked-extern/bar.rs b/src/test/run-make/symlinked-extern/bar.rs deleted file mode 100644 index 79103f24017..00000000000 --- a/src/test/run-make/symlinked-extern/bar.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -extern crate foo; - -pub fn bar(_s: foo::S) { -} diff --git a/src/test/run-make/symlinked-extern/baz.rs b/src/test/run-make/symlinked-extern/baz.rs deleted file mode 100644 index 0f6ba254368..00000000000 --- a/src/test/run-make/symlinked-extern/baz.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate bar; -extern crate foo; - -fn main() { - bar::bar(foo::foo()); -} diff --git a/src/test/run-make/symlinked-extern/foo.rs b/src/test/run-make/symlinked-extern/foo.rs deleted file mode 100644 index 0b8bb64d375..00000000000 --- a/src/test/run-make/symlinked-extern/foo.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] - -pub struct S; - -pub fn foo() -> S { S } diff --git a/src/test/run-make/symlinked-libraries/Makefile b/src/test/run-make/symlinked-libraries/Makefile deleted file mode 100644 index ac595546aa7..00000000000 --- a/src/test/run-make/symlinked-libraries/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -# ignore windows: `ln` is actually `cp` on msys. -ifndef IS_WINDOWS - -all: - $(RUSTC) foo.rs -C prefer-dynamic - mkdir -p $(TMPDIR)/other - ln -nsf $(TMPDIR)/$(call DYLIB_GLOB,foo) $(TMPDIR)/other - $(RUSTC) bar.rs -L $(TMPDIR)/other - -else -all: - -endif diff --git a/src/test/run-make/symlinked-libraries/bar.rs b/src/test/run-make/symlinked-libraries/bar.rs deleted file mode 100644 index 73596f93f56..00000000000 --- a/src/test/run-make/symlinked-libraries/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::bar(); -} diff --git a/src/test/run-make/symlinked-libraries/foo.rs b/src/test/run-make/symlinked-libraries/foo.rs deleted file mode 100644 index fdb29974cd8..00000000000 --- a/src/test/run-make/symlinked-libraries/foo.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "dylib"] - -pub fn bar() {} diff --git a/src/test/run-make/symlinked-rlib/Makefile b/src/test/run-make/symlinked-rlib/Makefile deleted file mode 100644 index 2709f786e0a..00000000000 --- a/src/test/run-make/symlinked-rlib/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -# ignore windows: `ln` is actually `cp` on msys. -ifndef IS_WINDOWS - -all: - $(RUSTC) foo.rs --crate-type=rlib -o $(TMPDIR)/foo.xxx - ln -nsf $(TMPDIR)/foo.xxx $(TMPDIR)/libfoo.rlib - $(RUSTC) bar.rs -L $(TMPDIR) - -else -all: - -endif diff --git a/src/test/run-make/symlinked-rlib/bar.rs b/src/test/run-make/symlinked-rlib/bar.rs deleted file mode 100644 index e8f06680862..00000000000 --- a/src/test/run-make/symlinked-rlib/bar.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate foo; - -fn main() { - foo::bar(); -} diff --git a/src/test/run-make/symlinked-rlib/foo.rs b/src/test/run-make/symlinked-rlib/foo.rs deleted file mode 100644 index 5abbb1dcbce..00000000000 --- a/src/test/run-make/symlinked-rlib/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn bar() {} diff --git a/src/test/run-make/sysroot-crates-are-unstable/Makefile b/src/test/run-make/sysroot-crates-are-unstable/Makefile deleted file mode 100644 index a35174b3c2a..00000000000 --- a/src/test/run-make/sysroot-crates-are-unstable/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -all: - python2.7 test.py diff --git a/src/test/run-make/sysroot-crates-are-unstable/test.py b/src/test/run-make/sysroot-crates-are-unstable/test.py deleted file mode 100644 index 210059e1010..00000000000 --- a/src/test/run-make/sysroot-crates-are-unstable/test.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2015 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -import sys -import os -from os import listdir -from os.path import isfile, join -from subprocess import PIPE, Popen - - -# This is a whitelist of files which are stable crates or simply are not crates, -# we don't check for the instability of these crates as they're all stable! -STABLE_CRATES = ['std', 'core', 'proc_macro', 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', - 'clang_rt'] - - -def convert_to_string(s): - if s.__class__.__name__ == 'bytes': - return s.decode('utf-8') - return s - - -def exec_command(command, to_input=None): - child = None - if to_input is None: - child = Popen(command, stdout=PIPE, stderr=PIPE) - else: - child = Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE) - stdout, stderr = child.communicate(input=to_input) - return (convert_to_string(stdout), convert_to_string(stderr)) - - -def check_lib(lib): - if lib['name'] in STABLE_CRATES: - return True - print('verifying if {} is an unstable crate'.format(lib['name'])) - stdout, stderr = exec_command([os.environ['RUSTC'], '-', '--crate-type', 'rlib', - '--extern', '{}={}'.format(lib['name'], lib['path'])], - to_input='extern crate {};'.format(lib['name'])) - if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr): - print('crate {} "{}" is not unstable'.format(lib['name'], lib['path'])) - print('{}{}'.format(stdout, stderr)) - print('') - return False - return True - -# Generate a list of all crates in the sysroot. To do this we list all files in -# rustc's sysroot, look at the filename, strip everything after the `-`, and -# strip the leading `lib` (if present) -def get_all_libs(dir_path): - return [{ 'path': join(dir_path, f), 'name': f[3:].split('-')[0] } - for f in listdir(dir_path) - if isfile(join(dir_path, f)) and f.endswith('.rlib') and f not in STABLE_CRATES] - - -sysroot = exec_command([os.environ['RUSTC'], '--print', 'sysroot'])[0].replace('\n', '') -libs = get_all_libs(join(sysroot, 'lib/rustlib/{}/lib'.format(os.environ['TARGET']))) - -ret = 0 -for lib in libs: - if not check_lib(lib): - # We continue so users can see all the not unstable crates. - ret = 1 -sys.exit(ret) diff --git a/src/test/run-make/target-cpu-native/Makefile b/src/test/run-make/target-cpu-native/Makefile deleted file mode 100644 index 0c9d93ecb2a..00000000000 --- a/src/test/run-make/target-cpu-native/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs -C target-cpu=native - $(call RUN,foo) diff --git a/src/test/run-make/target-cpu-native/foo.rs b/src/test/run-make/target-cpu-native/foo.rs deleted file mode 100644 index f7a9f969060..00000000000 --- a/src/test/run-make/target-cpu-native/foo.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { -} diff --git a/src/test/run-make/target-specs/Makefile b/src/test/run-make/target-specs/Makefile deleted file mode 100644 index aff15ce38b4..00000000000 --- a/src/test/run-make/target-specs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk -all: - $(RUSTC) foo.rs --target=my-awesome-platform.json --crate-type=lib --emit=asm - $(CGREP) -v morestack < $(TMPDIR)/foo.s - $(RUSTC) foo.rs --target=my-invalid-platform.json 2>&1 | $(CGREP) "Error loading target specification" - $(RUSTC) foo.rs --target=my-incomplete-platform.json 2>&1 | $(CGREP) 'Field llvm-target' - RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm - RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm - $(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json - diff --git a/src/test/run-make/target-specs/foo.rs b/src/test/run-make/target-specs/foo.rs deleted file mode 100644 index bbd1c5d900f..00000000000 --- a/src/test/run-make/target-specs/foo.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(lang_items, no_core, optin_builtin_traits)] -#![no_core] - -#[lang="copy"] -trait Copy { } - -#[lang="sized"] -trait Sized { } - -#[lang = "freeze"] -auto trait Freeze {} - -#[lang="start"] -fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize { 0 } - -extern { - fn _foo() -> [u8; 16]; -} - -fn _main() { - let _a = unsafe { _foo() }; -} diff --git a/src/test/run-make/target-specs/my-awesome-platform.json b/src/test/run-make/target-specs/my-awesome-platform.json deleted file mode 100644 index 8d028280a8d..00000000000 --- a/src/test/run-make/target-specs/my-awesome-platform.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", - "linker-flavor": "gcc", - "llvm-target": "i686-unknown-linux-gnu", - "target-endian": "little", - "target-pointer-width": "32", - "target-c-int-width": "32", - "arch": "x86", - "os": "linux", - "morestack": false -} diff --git a/src/test/run-make/target-specs/my-incomplete-platform.json b/src/test/run-make/target-specs/my-incomplete-platform.json deleted file mode 100644 index ceaa25cdf2f..00000000000 --- a/src/test/run-make/target-specs/my-incomplete-platform.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32", - "linker-flavor": "gcc", - "target-endian": "little", - "target-pointer-width": "32", - "target-c-int-width": "32", - "arch": "x86", - "os": "foo", - "morestack": false -} diff --git a/src/test/run-make/target-specs/my-invalid-platform.json b/src/test/run-make/target-specs/my-invalid-platform.json deleted file mode 100644 index 3feac45b7d6..00000000000 --- a/src/test/run-make/target-specs/my-invalid-platform.json +++ /dev/null @@ -1 +0,0 @@ -wow this json is really broke! diff --git a/src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json deleted file mode 100644 index 3ae01d72fcc..00000000000 --- a/src/test/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "pre-link-args": ["-m64"], - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", - "linker-flavor": "gcc", - "llvm-target": "x86_64-unknown-linux-gnu", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "arch": "x86_64", - "os": "linux", - "morestack": false -} diff --git a/src/test/run-make/target-without-atomics/Makefile b/src/test/run-make/target-without-atomics/Makefile deleted file mode 100644 index c5f575ddf84..00000000000 --- a/src/test/run-make/target-without-atomics/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -# The target used below doesn't support atomic operations. Verify that's the case -all: - $(RUSTC) --print cfg --target thumbv6m-none-eabi | $(CGREP) -v target_has_atomic diff --git a/src/test/run-make/test-harness/Makefile b/src/test/run-make/test-harness/Makefile deleted file mode 100644 index 39477c07ced..00000000000 --- a/src/test/run-make/test-harness/Makefile +++ /dev/null @@ -1,8 +0,0 @@ --include ../tools.mk - -all: - # check that #[cfg_attr(..., ignore)] does the right thing. - $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg - $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored' - $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$" - $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should' diff --git a/src/test/run-make/test-harness/test-ignore-cfg.rs b/src/test/run-make/test-harness/test-ignore-cfg.rs deleted file mode 100644 index 990d3d10485..00000000000 --- a/src/test/run-make/test-harness/test-ignore-cfg.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[test] -#[cfg_attr(ignorecfg, ignore)] -fn shouldignore() { -} - -#[test] -#[cfg_attr(noignorecfg, ignore)] -fn shouldnotignore() { -} diff --git a/src/test/run-make/tools.mk b/src/test/run-make/tools.mk deleted file mode 100644 index af1707de6c0..00000000000 --- a/src/test/run-make/tools.mk +++ /dev/null @@ -1,134 +0,0 @@ -# These deliberately use `=` and not `:=` so that client makefiles can -# augment HOST_RPATH_DIR / TARGET_RPATH_DIR. -HOST_RPATH_ENV = \ - $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(HOST_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" -TARGET_RPATH_ENV = \ - $(LD_LIB_PATH_ENVVAR)="$(TMPDIR):$(TARGET_RPATH_DIR):$($(LD_LIB_PATH_ENVVAR))" - -RUSTC_ORIGINAL := $(RUSTC) -BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)' -BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)' -RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS) -RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR) -ifdef RUSTC_LINKER -RUSTC := $(RUSTC) -Clinker=$(RUSTC_LINKER) -RUSTDOC := $(RUSTDOC) --linker $(RUSTC_LINKER) -Z unstable-options -endif -#CC := $(CC) -L $(TMPDIR) -HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py -CGREP := "$(S)/src/etc/cat-and-grep.sh" - -# This is the name of the binary we will generate and run; use this -# e.g. for `$(CC) -o $(RUN_BINFILE)`. -RUN_BINFILE = $(TMPDIR)/$(1) - -# RUN and FAIL are basic way we will invoke the generated binary. On -# non-windows platforms, they set the LD_LIBRARY_PATH environment -# variable before running the binary. - -RLIB_GLOB = lib$(1)*.rlib -BIN = $(1) - -UNAME = $(shell uname) - -ifeq ($(UNAME),Darwin) -RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) -FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 -DYLIB_GLOB = lib$(1)*.dylib -DYLIB = $(TMPDIR)/lib$(1).dylib -STATICLIB = $(TMPDIR)/lib$(1).a -STATICLIB_GLOB = lib$(1)*.a -else -ifdef IS_WINDOWS -RUN = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) -FAIL = PATH="$(PATH):$(TARGET_RPATH_DIR)" $(RUN_BINFILE) && exit 1 || exit 0 -DYLIB_GLOB = $(1)*.dll -DYLIB = $(TMPDIR)/$(1).dll -STATICLIB = $(TMPDIR)/$(1).lib -STATICLIB_GLOB = $(1)*.lib -BIN = $(1).exe -else -RUN = $(TARGET_RPATH_ENV) $(RUN_BINFILE) -FAIL = $(TARGET_RPATH_ENV) $(RUN_BINFILE) && exit 1 || exit 0 -DYLIB_GLOB = lib$(1)*.so -DYLIB = $(TMPDIR)/lib$(1).so -STATICLIB = $(TMPDIR)/lib$(1).a -STATICLIB_GLOB = lib$(1)*.a -endif -endif - -ifdef IS_MSVC -COMPILE_OBJ = $(CC) -c -Fo:`cygpath -w $(1)` $(2) -NATIVE_STATICLIB_FILE = $(1).lib -NATIVE_STATICLIB = $(TMPDIR)/$(call NATIVE_STATICLIB_FILE,$(1)) -OUT_EXE=-Fe:`cygpath -w $(TMPDIR)/$(call BIN,$(1))` \ - -Fo:`cygpath -w $(TMPDIR)/$(1).obj` -else -COMPILE_OBJ = $(CC) -c -o $(1) $(2) -NATIVE_STATICLIB_FILE = lib$(1).a -NATIVE_STATICLIB = $(call STATICLIB,$(1)) -OUT_EXE=-o $(TMPDIR)/$(1) -endif - - -# Extra flags needed to compile a working executable with the standard library -ifdef IS_WINDOWS -ifdef IS_MSVC - EXTRACFLAGS := ws2_32.lib userenv.lib shell32.lib advapi32.lib -else - EXTRACFLAGS := -lws2_32 -luserenv -endif -else -ifeq ($(UNAME),Darwin) - EXTRACFLAGS := -lresolv -else -ifeq ($(UNAME),FreeBSD) - EXTRACFLAGS := -lm -lpthread -lgcc_s -else -ifeq ($(UNAME),Bitrig) - EXTRACFLAGS := -lm -lpthread - EXTRACXXFLAGS := -lc++ -lc++abi -else -ifeq ($(UNAME),SunOS) - EXTRACFLAGS := -lm -lpthread -lposix4 -lsocket -lresolv -else -ifeq ($(UNAME),OpenBSD) - EXTRACFLAGS := -lm -lpthread -lc++abi - RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))" -else - EXTRACFLAGS := -lm -lrt -ldl -lpthread - EXTRACXXFLAGS := -lstdc++ -endif -endif -endif -endif -endif -endif - -REMOVE_DYLIBS = rm $(TMPDIR)/$(call DYLIB_GLOB,$(1)) -REMOVE_RLIBS = rm $(TMPDIR)/$(call RLIB_GLOB,$(1)) - -%.a: %.o - $(AR) crus $@ $< -ifdef IS_MSVC -%.lib: lib%.o - $(MSVC_LIB) -out:`cygpath -w $@` $< -else -%.lib: lib%.o - $(AR) crus $@ $< -endif -%.dylib: %.o - $(CC) -dynamiclib -Wl,-dylib -o $@ $< -%.so: %.o - $(CC) -o $@ $< -shared - -ifdef IS_MSVC -%.dll: lib%.o - $(CC) $< -link -dll -out:`cygpath -w $@` -else -%.dll: lib%.o - $(CC) -o $@ $< -shared -endif - -$(TMPDIR)/lib%.o: %.c - $(call COMPILE_OBJ,$@,$<) diff --git a/src/test/run-make/treat-err-as-bug/Makefile b/src/test/run-make/treat-err-as-bug/Makefile deleted file mode 100644 index f99e4611174..00000000000 --- a/src/test/run-make/treat-err-as-bug/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \ - | $(CGREP) "panicked at 'encountered error with \`-Z treat_err_as_bug'" diff --git a/src/test/run-make/treat-err-as-bug/err.rs b/src/test/run-make/treat-err-as-bug/err.rs deleted file mode 100644 index 078495663ac..00000000000 --- a/src/test/run-make/treat-err-as-bug/err.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="rlib"] - -pub static C: u32 = 0-1; diff --git a/src/test/run-make/type-mismatch-same-crate-name/Makefile b/src/test/run-make/type-mismatch-same-crate-name/Makefile deleted file mode 100644 index 9fd1377322b..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/Makefile +++ /dev/null @@ -1,19 +0,0 @@ --include ../tools.mk - -all: - # compile two different versions of crateA - $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-1 -C extra-filename=-1 - $(RUSTC) --crate-type=rlib crateA.rs -C metadata=-2 -C extra-filename=-2 - # make crateB depend on version 1 of crateA - $(RUSTC) --crate-type=rlib crateB.rs --extern crateA=$(TMPDIR)/libcrateA-1.rlib - # make crateC depend on version 2 of crateA - $(RUSTC) crateC.rs --extern crateA=$(TMPDIR)/libcrateA-2.rlib 2>&1 | \ - tr -d '\r\n' | $(CGREP) -e \ - "mismatched types.*\ - crateB::try_foo\(foo2\);.*\ - expected struct \`crateA::foo::Foo\`, found struct \`crateA::Foo\`.*\ - different versions of crate \`crateA\`.*\ - mismatched types.*\ - crateB::try_bar\(bar2\);.*\ - expected trait \`crateA::bar::Bar\`, found trait \`crateA::Bar\`.*\ - different versions of crate \`crateA\`" diff --git a/src/test/run-make/type-mismatch-same-crate-name/crateA.rs b/src/test/run-make/type-mismatch-same-crate-name/crateA.rs deleted file mode 100644 index e40266bb4cd..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/crateA.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod foo { - pub struct Foo; -} - -mod bar { - pub trait Bar{} - - pub fn bar() -> Box { - unimplemented!() - } -} - -// This makes the publicly accessible path -// differ from the internal one. -pub use foo::Foo; -pub use bar::{Bar, bar}; diff --git a/src/test/run-make/type-mismatch-same-crate-name/crateB.rs b/src/test/run-make/type-mismatch-same-crate-name/crateB.rs deleted file mode 100644 index da4ea1c9387..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/crateB.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate crateA; - -pub fn try_foo(x: crateA::Foo){} -pub fn try_bar(x: Box){} diff --git a/src/test/run-make/type-mismatch-same-crate-name/crateC.rs b/src/test/run-make/type-mismatch-same-crate-name/crateC.rs deleted file mode 100644 index 210bc4c8320..00000000000 --- a/src/test/run-make/type-mismatch-same-crate-name/crateC.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This tests the extra note reported when a type error deals with -// seemingly identical types. -// The main use case of this error is when there are two crates -// (generally different versions of the same crate) with the same name -// causing a type mismatch. - -// The test is nearly the same as the one in -// compile-fail/type-mismatch-same-crate-name.rs -// but deals with the case where one of the crates -// is only introduced as an indirect dependency. -// and the type is accessed via a re-export. -// This is similar to how the error can be introduced -// when using cargo's automatic dependency resolution. - -extern crate crateA; - -fn main() { - let foo2 = crateA::Foo; - let bar2 = crateA::bar(); - { - extern crate crateB; - crateB::try_foo(foo2); - crateB::try_bar(bar2); - } -} diff --git a/src/test/run-make/use-extern-for-plugins/Makefile b/src/test/run-make/use-extern-for-plugins/Makefile deleted file mode 100644 index cc7bc176f49..00000000000 --- a/src/test/run-make/use-extern-for-plugins/Makefile +++ /dev/null @@ -1,21 +0,0 @@ --include ../tools.mk - -SKIP_OS := 'FreeBSD OpenBSD Bitrig SunOS' - -ifneq ($(UNAME),$(findstring $(UNAME),$(SKIP_OS))) - -HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //') -ifeq ($(findstring i686,$(HOST)),i686) -TARGET := $(subst i686,x86_64,$(HOST)) -else -TARGET := $(subst x86_64,i686,$(HOST)) -endif - -all: - $(RUSTC) foo.rs -C extra-filename=-host - $(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET) - $(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET) -else -# FreeBSD, OpenBSD, and Bitrig support only x86_64 architecture for now -all: -endif diff --git a/src/test/run-make/use-extern-for-plugins/bar.rs b/src/test/run-make/use-extern-for-plugins/bar.rs deleted file mode 100644 index 3e99ed60c62..00000000000 --- a/src/test/run-make/use-extern-for-plugins/bar.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![crate_type = "lib"] -#![crate_name = "a"] - -#[macro_export] -macro_rules! bar { - () => () -} diff --git a/src/test/run-make/use-extern-for-plugins/baz.rs b/src/test/run-make/use-extern-for-plugins/baz.rs deleted file mode 100644 index 3f15d0e6e05..00000000000 --- a/src/test/run-make/use-extern-for-plugins/baz.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(no_core)] -#![no_core] -#![crate_type = "lib"] - -#[macro_use] -extern crate a; - -bar!(); diff --git a/src/test/run-make/use-extern-for-plugins/foo.rs b/src/test/run-make/use-extern-for-plugins/foo.rs deleted file mode 100644 index 0afd3be466d..00000000000 --- a/src/test/run-make/use-extern-for-plugins/foo.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![no_std] -#![crate_type = "lib"] -#![crate_name = "a"] - -#[macro_export] -macro_rules! foo { - () => () -} diff --git a/src/test/run-make/used/Makefile b/src/test/run-make/used/Makefile deleted file mode 100644 index 47edcbb5d0a..00000000000 --- a/src/test/run-make/used/Makefile +++ /dev/null @@ -1,11 +0,0 @@ --include ../tools.mk - -ifdef IS_WINDOWS -# Do nothing on MSVC. -all: - exit 0 -else -all: - $(RUSTC) -C opt-level=3 --emit=obj used.rs - nm $(TMPDIR)/used.o | $(CGREP) FOO -endif diff --git a/src/test/run-make/used/used.rs b/src/test/run-make/used/used.rs deleted file mode 100644 index 186cd0fdf5e..00000000000 --- a/src/test/run-make/used/used.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] -#![feature(used)] - -#[used] -static FOO: u32 = 0; - -static BAR: u32 = 0; diff --git a/src/test/run-make/version/Makefile b/src/test/run-make/version/Makefile deleted file mode 100644 index 23e14a9cb93..00000000000 --- a/src/test/run-make/version/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) -V - $(RUSTC) -vV - $(RUSTC) --version --verbose diff --git a/src/test/run-make/volatile-intrinsics/Makefile b/src/test/run-make/volatile-intrinsics/Makefile deleted file mode 100644 index acbadbef9fb..00000000000 --- a/src/test/run-make/volatile-intrinsics/Makefile +++ /dev/null @@ -1,9 +0,0 @@ --include ../tools.mk - -all: - # The tests must pass... - $(RUSTC) main.rs - $(call RUN,main) - # ... and the loads/stores must not be optimized out. - $(RUSTC) main.rs --emit=llvm-ir - $(CGREP) "load volatile" "store volatile" < $(TMPDIR)/main.ll diff --git a/src/test/run-make/volatile-intrinsics/main.rs b/src/test/run-make/volatile-intrinsics/main.rs deleted file mode 100644 index 4d0d7672101..00000000000 --- a/src/test/run-make/volatile-intrinsics/main.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(core_intrinsics, volatile)] - -use std::intrinsics::{volatile_load, volatile_store}; -use std::ptr::{read_volatile, write_volatile}; - -pub fn main() { - unsafe { - let mut i : isize = 1; - volatile_store(&mut i, 2); - assert_eq!(volatile_load(&i), 2); - } - unsafe { - let mut i : isize = 1; - write_volatile(&mut i, 2); - assert_eq!(read_volatile(&i), 2); - } -} diff --git a/src/test/run-make/wasm-custom-section/Makefile b/src/test/run-make/wasm-custom-section/Makefile new file mode 100644 index 00000000000..399951e5163 --- /dev/null +++ b/src/test/run-make/wasm-custom-section/Makefile @@ -0,0 +1,10 @@ +-include ../../run-make-fulldeps/tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) foo.rs --target wasm32-unknown-unknown + $(RUSTC) bar.rs -C lto -O --target wasm32-unknown-unknown + $(NODE) foo.js $(TMPDIR)/bar.wasm +else +all: +endif diff --git a/src/test/run-make/wasm-custom-section/bar.rs b/src/test/run-make/wasm-custom-section/bar.rs new file mode 100644 index 00000000000..e3db36d6dbd --- /dev/null +++ b/src/test/run-make/wasm-custom-section/bar.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] +#![feature(wasm_custom_section)] +#![deny(warnings)] + +extern crate foo; + +#[wasm_custom_section = "foo"] +const A: [u8; 2] = [5, 6]; + +#[wasm_custom_section = "baz"] +const B: [u8; 2] = [7, 8]; + +#[no_mangle] +pub extern fn foo() {} diff --git a/src/test/run-make/wasm-custom-section/foo.js b/src/test/run-make/wasm-custom-section/foo.js new file mode 100644 index 00000000000..df69354f3a4 --- /dev/null +++ b/src/test/run-make/wasm-custom-section/foo.js @@ -0,0 +1,46 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const fs = require('fs'); +const process = require('process'); +const assert = require('assert'); +const buffer = fs.readFileSync(process.argv[2]); + +let m = new WebAssembly.Module(buffer); +let sections = WebAssembly.Module.customSections(m, "baz"); +console.log('section baz', sections); +assert.strictEqual(sections.length, 1); +let section = new Uint8Array(sections[0]); +console.log('contents', section); +assert.strictEqual(section.length, 2); +assert.strictEqual(section[0], 7); +assert.strictEqual(section[1], 8); + +sections = WebAssembly.Module.customSections(m, "bar"); +console.log('section bar', sections); +assert.strictEqual(sections.length, 1, "didn't pick up `bar` section from dependency"); +section = new Uint8Array(sections[0]); +console.log('contents', section); +assert.strictEqual(section.length, 2); +assert.strictEqual(section[0], 3); +assert.strictEqual(section[1], 4); + +sections = WebAssembly.Module.customSections(m, "foo"); +console.log('section foo', sections); +assert.strictEqual(sections.length, 1, "didn't create `foo` section"); +section = new Uint8Array(sections[0]); +console.log('contents', section); +assert.strictEqual(section.length, 4, "didn't concatenate `foo` sections"); +assert.strictEqual(section[0], 5); +assert.strictEqual(section[1], 6); +assert.strictEqual(section[2], 1); +assert.strictEqual(section[3], 2); + +process.exit(1); diff --git a/src/test/run-make/wasm-custom-section/foo.rs b/src/test/run-make/wasm-custom-section/foo.rs new file mode 100644 index 00000000000..44d1efd7c2d --- /dev/null +++ b/src/test/run-make/wasm-custom-section/foo.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(wasm_custom_section)] +#![deny(warnings)] + +#[wasm_custom_section = "foo"] +const A: [u8; 2] = [1, 2]; + +#[wasm_custom_section = "bar"] +const B: [u8; 2] = [3, 4]; diff --git a/src/test/run-make/weird-output-filenames/Makefile b/src/test/run-make/weird-output-filenames/Makefile deleted file mode 100644 index f161fe9f8e8..00000000000 --- a/src/test/run-make/weird-output-filenames/Makefile +++ /dev/null @@ -1,15 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/.foo.rs - $(RUSTC) $(TMPDIR)/.foo.rs 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/.foo.bar - $(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/+foo+bar.rs - $(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \ - | $(CGREP) -e "invalid character.*in crate name:" - cp foo.rs $(TMPDIR)/-foo.rs - $(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \ - | $(CGREP) 'crate names cannot start with a `-`' diff --git a/src/test/run-make/weird-output-filenames/foo.rs b/src/test/run-make/weird-output-filenames/foo.rs deleted file mode 100644 index 8ae3d072362..00000000000 --- a/src/test/run-make/weird-output-filenames/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/windows-spawn/Makefile b/src/test/run-make/windows-spawn/Makefile deleted file mode 100644 index f0d4242260f..00000000000 --- a/src/test/run-make/windows-spawn/Makefile +++ /dev/null @@ -1,14 +0,0 @@ --include ../tools.mk - -ifdef IS_WINDOWS - -all: - $(RUSTC) -o "$(TMPDIR)/hopefullydoesntexist bar.exe" hello.rs - $(RUSTC) spawn.rs - $(TMPDIR)/spawn.exe - -else - -all: - -endif diff --git a/src/test/run-make/windows-spawn/hello.rs b/src/test/run-make/windows-spawn/hello.rs deleted file mode 100644 index b177f41941d..00000000000 --- a/src/test/run-make/windows-spawn/hello.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - println!("Hello World!"); -} diff --git a/src/test/run-make/windows-spawn/spawn.rs b/src/test/run-make/windows-spawn/spawn.rs deleted file mode 100644 index 2913cbe2260..00000000000 --- a/src/test/run-make/windows-spawn/spawn.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::io::ErrorKind; -use std::process::Command; - -fn main() { - // Make sure it doesn't try to run "hopefullydoesntexist bar.exe". - assert_eq!(Command::new("hopefullydoesntexist") - .arg("bar") - .spawn() - .unwrap_err() - .kind(), - ErrorKind::NotFound); -} diff --git a/src/test/run-make/windows-subsystem/Makefile b/src/test/run-make/windows-subsystem/Makefile deleted file mode 100644 index 34fb5db32f9..00000000000 --- a/src/test/run-make/windows-subsystem/Makefile +++ /dev/null @@ -1,5 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) windows.rs - $(RUSTC) console.rs diff --git a/src/test/run-make/windows-subsystem/console.rs b/src/test/run-make/windows-subsystem/console.rs deleted file mode 100644 index ffad1e35ee6..00000000000 --- a/src/test/run-make/windows-subsystem/console.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![windows_subsystem = "console"] - -fn main() {} - diff --git a/src/test/run-make/windows-subsystem/windows.rs b/src/test/run-make/windows-subsystem/windows.rs deleted file mode 100644 index 33cbe320591..00000000000 --- a/src/test/run-make/windows-subsystem/windows.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![windows_subsystem = "windows"] - -fn main() {} diff --git a/src/test/ui/feature-gate-wasm_custom_section.rs b/src/test/ui/feature-gate-wasm_custom_section.rs new file mode 100644 index 00000000000..c695ef4ff06 --- /dev/null +++ b/src/test/ui/feature-gate-wasm_custom_section.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[wasm_custom_section = "foo"] //~ ERROR: attribute is currently unstable +const A: [u8; 2] = [1, 2]; + +fn main() {} diff --git a/src/test/ui/feature-gate-wasm_custom_section.stderr b/src/test/ui/feature-gate-wasm_custom_section.stderr new file mode 100644 index 00000000000..5977ec9edad --- /dev/null +++ b/src/test/ui/feature-gate-wasm_custom_section.stderr @@ -0,0 +1,11 @@ +error[E0658]: attribute is currently unstable + --> $DIR/feature-gate-wasm_custom_section.rs:11:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: attribute is currently unstable + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(wasm_custom_section)] to the crate attributes to enable + +error: aborting due to previous error + +If you want more information on this error, try using "rustc --explain E0658" diff --git a/src/test/ui/wasm-custom-section/malformed.rs b/src/test/ui/wasm-custom-section/malformed.rs new file mode 100644 index 00000000000..13b1685a480 --- /dev/null +++ b/src/test/ui/wasm-custom-section/malformed.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_custom_section)] + +#[wasm_custom_section] //~ ERROR: must be of the form +const A: [u8; 1] = [0]; + +#[wasm_custom_section(foo)] //~ ERROR: must be of the form +const B: [u8; 1] = [0]; + +fn main() {} diff --git a/src/test/ui/wasm-custom-section/malformed.stderr b/src/test/ui/wasm-custom-section/malformed.stderr new file mode 100644 index 00000000000..c716c824aeb --- /dev/null +++ b/src/test/ui/wasm-custom-section/malformed.stderr @@ -0,0 +1,14 @@ +error: must be of the form #[wasm_custom_section = "foo"] + --> $DIR/malformed.rs:13:1 + | +LL | #[wasm_custom_section] //~ ERROR: must be of the form + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: must be of the form #[wasm_custom_section = "foo"] + --> $DIR/malformed.rs:16:1 + | +LL | #[wasm_custom_section(foo)] //~ ERROR: must be of the form + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/wasm-custom-section/not-const.rs b/src/test/ui/wasm-custom-section/not-const.rs new file mode 100644 index 00000000000..68077fb2fe4 --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-const.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_custom_section)] + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +static A: [u8; 2] = [1, 2]; + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +struct B {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +enum C {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +impl B {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +mod d {} + +#[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts +fn main() {} diff --git a/src/test/ui/wasm-custom-section/not-const.stderr b/src/test/ui/wasm-custom-section/not-const.stderr new file mode 100644 index 00000000000..17c85b3e848 --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-const.stderr @@ -0,0 +1,38 @@ +error: only allowed on consts + --> $DIR/not-const.rs:13:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:16:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:19:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:22:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:25:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: only allowed on consts + --> $DIR/not-const.rs:28:1 + | +LL | #[wasm_custom_section = "foo"] //~ ERROR: only allowed on consts + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/wasm-custom-section/not-slice.rs b/src/test/ui/wasm-custom-section/not-slice.rs new file mode 100644 index 00000000000..2d91641a5f7 --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-slice.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_custom_section)] + +#[wasm_custom_section = "foo"] +const A: u8 = 0; //~ ERROR: must be an array of bytes + +#[wasm_custom_section = "foo"] +const B: &[u8] = &[0]; //~ ERROR: must be an array of bytes + +#[wasm_custom_section = "foo"] +const C: &[u8; 1] = &[0]; //~ ERROR: must be an array of bytes + +fn main() {} diff --git a/src/test/ui/wasm-custom-section/not-slice.stderr b/src/test/ui/wasm-custom-section/not-slice.stderr new file mode 100644 index 00000000000..f2563ce0ddd --- /dev/null +++ b/src/test/ui/wasm-custom-section/not-slice.stderr @@ -0,0 +1,20 @@ +error: must be an array of bytes like `[u8; N]` + --> $DIR/not-slice.rs:14:1 + | +LL | const A: u8 = 0; //~ ERROR: must be an array of bytes + | ^^^^^^^^^^^^^^^^ + +error: must be an array of bytes like `[u8; N]` + --> $DIR/not-slice.rs:17:1 + | +LL | const B: &[u8] = &[0]; //~ ERROR: must be an array of bytes + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: must be an array of bytes like `[u8; N]` + --> $DIR/not-slice.rs:20:1 + | +LL | const C: &[u8; 1] = &[0]; //~ ERROR: must be an array of bytes + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 43220af4893..93b1b1f08e6 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2396,13 +2396,6 @@ impl<'test> TestCx<'test> { .env("S", src_root) .env("RUST_BUILD_STAGE", &self.config.stage_id) .env("RUSTC", cwd.join(&self.config.rustc_path)) - .env( - "RUSTDOC", - cwd.join(&self.config - .rustdoc_path - .as_ref() - .expect("--rustdoc-path passed")), - ) .env("TMPDIR", &tmpdir) .env("LD_LIB_PATH_ENVVAR", dylib_env_var()) .env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path)) @@ -2417,6 +2410,14 @@ impl<'test> TestCx<'test> { .env_remove("MFLAGS") .env_remove("CARGO_MAKEFLAGS"); + if let Some(ref rustdoc) = self.config.rustdoc_path { + cmd.env("RUSTDOC", cwd.join(rustdoc)); + } + + if let Some(ref node) = self.config.nodejs { + cmd.env("NODE", node); + } + if let Some(ref linker) = self.config.linker { cmd.env("RUSTC_LINKER", linker); } -- cgit 1.4.1-3-g733a5 From d889957dab5ee0778f9dd64faeafc8872645efed Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 10 Feb 2018 14:28:17 -0800 Subject: rustc: Add a `#[wasm_import_module]` attribute This commit adds a new attribute to the Rust compiler specific to the wasm target (and no other targets). The `#[wasm_import_module]` attribute is used to specify the module that a name is imported from, and is used like so: #[wasm_import_module = "./foo.js"] extern { fn some_js_function(); } Here the import of the symbol `some_js_function` is tagged with the `./foo.js` module in the wasm output file. Wasm-the-format includes two fields on all imports, a module and a field. The field is the symbol name (`some_js_function` above) and the module has historically unconditionally been `"env"`. I'm not sure if this `"env"` convention has asm.js or LLVM roots, but regardless we'd like the ability to configure it! The proposed ES module integration with wasm (aka a wasm module is "just another ES module") requires that the import module of wasm imports is interpreted as an ES module import, meaning that you'll need to encode paths, NPM packages, etc. As a result, we'll need this to be something other than `"env"`! Unfortunately neither our version of LLVM nor LLD supports custom import modules (aka anything not `"env"`). My hope is that by the time LLVM 7 is released both will have support, but in the meantime this commit adds some primitive encoding/decoding of wasm files to the compiler. This way rustc postprocesses the wasm module that LLVM emits to ensure it's got all the imports we'd like to have in it. Eventually I'd ideally like to unconditionally require this attribute to be placed on all `extern { ... }` blocks. For now though it seemed prudent to add it as an unstable attribute, so for now it's not required (as that'd force usage of a feature gate). Hopefully it doesn't take too long to "stabilize" this! cc rust-lang-nursery/rust-wasm#29 --- src/ci/docker/wasm32-unknown/Dockerfile | 1 + src/librustc/dep_graph/dep_node.rs | 3 + src/librustc/hir/check_attr.rs | 43 +++- src/librustc/ich/impls_cstore.rs | 7 +- src/librustc/middle/cstore.rs | 6 + src/librustc/ty/maps/config.rs | 18 ++ src/librustc/ty/maps/mod.rs | 9 +- src/librustc/ty/maps/plumbing.rs | 5 + src/librustc_metadata/creader.rs | 20 +- src/librustc_metadata/cstore.rs | 6 +- src/librustc_metadata/cstore_impl.rs | 22 +- src/librustc_metadata/decoder.rs | 10 +- src/librustc_metadata/encoder.rs | 12 +- src/librustc_metadata/foreign_modules.rs | 48 ++++ src/librustc_metadata/lib.rs | 1 + src/librustc_metadata/native_libs.rs | 7 +- src/librustc_metadata/schema.rs | 3 +- src/librustc_trans/attributes.rs | 46 ++++ src/librustc_trans/back/link.rs | 1 + src/librustc_trans/back/wasm.rs | 249 +++++++++++++++++++-- src/librustc_trans/base.rs | 52 ++++- src/librustc_trans/lib.rs | 3 + src/libsyntax/feature_gate.rs | 7 + src/test/run-make/wasm-custom-section/foo.js | 2 +- src/test/run-make/wasm-import-module/Makefile | 10 + src/test/run-make/wasm-import-module/bar.rs | 29 +++ src/test/run-make/wasm-import-module/foo.js | 28 +++ src/test/run-make/wasm-import-module/foo.rs | 18 ++ .../ui/feature-gate-wasm_custom_section.stderr | 2 +- src/test/ui/feature-gate-wasm_import_module.rs | 15 ++ src/test/ui/feature-gate-wasm_import_module.stderr | 11 + src/test/ui/wasm-import-module.rs | 20 ++ src/test/ui/wasm-import-module.stderr | 14 ++ 33 files changed, 653 insertions(+), 75 deletions(-) create mode 100644 src/librustc_metadata/foreign_modules.rs create mode 100644 src/test/run-make/wasm-import-module/Makefile create mode 100644 src/test/run-make/wasm-import-module/bar.rs create mode 100644 src/test/run-make/wasm-import-module/foo.js create mode 100644 src/test/run-make/wasm-import-module/foo.rs create mode 100644 src/test/ui/feature-gate-wasm_import_module.rs create mode 100644 src/test/ui/feature-gate-wasm_import_module.stderr create mode 100644 src/test/ui/wasm-import-module.rs create mode 100644 src/test/ui/wasm-import-module.stderr diff --git a/src/ci/docker/wasm32-unknown/Dockerfile b/src/ci/docker/wasm32-unknown/Dockerfile index 0972eb85191..6c0ec1ad9d4 100644 --- a/src/ci/docker/wasm32-unknown/Dockerfile +++ b/src/ci/docker/wasm32-unknown/Dockerfile @@ -26,6 +26,7 @@ ENV RUST_CONFIGURE_ARGS \ --set rust.lld ENV SCRIPT python2.7 /checkout/x.py test --target $TARGETS \ + src/test/run-make \ src/test/ui \ src/test/run-pass \ src/test/compile-fail \ diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 09d7ce599ab..8bcec79d99f 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -593,6 +593,7 @@ define_dep_nodes!( <'tcx> [] ImplementationsOfTrait { krate: CrateNum, trait_id: DefId }, [] AllTraitImplementations(CrateNum), + [] DllimportForeignItems(CrateNum), [] IsDllimportForeignItem(DefId), [] IsStaticallyIncludedForeignItem(DefId), [] NativeLibraryKind(DefId), @@ -655,6 +656,8 @@ define_dep_nodes!( <'tcx> [input] Features, [] ProgramClausesFor(DefId), + [] WasmImportModuleMap(CrateNum), + [] ForeignModules(CrateNum), ); trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index f141cac1614..9b2647ad4db 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -26,6 +26,7 @@ enum Target { Union, Enum, Const, + ForeignMod, Other, } @@ -37,6 +38,7 @@ impl Target { hir::ItemUnion(..) => Target::Union, hir::ItemEnum(..) => Target::Enum, hir::ItemConst(..) => Target::Const, + hir::ItemForeignMod(..) => Target::ForeignMod, _ => Target::Other, } } @@ -57,25 +59,42 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> { .emit(); } + let mut has_wasm_import_module = false; for attr in &item.attrs { - if let Some(name) = attr.name() { - if name == "inline" { - self.check_inline(attr, item, target) + if attr.check_name("inline") { + self.check_inline(attr, item, target) + } else if attr.check_name("wasm_import_module") { + has_wasm_import_module = true; + if attr.value_str().is_none() { + self.tcx.sess.span_err(attr.span, "\ + must be of the form #[wasm_import_module = \"...\"]"); + } + if target != Target::ForeignMod { + self.tcx.sess.span_err(attr.span, "\ + must only be attached to foreign modules"); + } + } else if attr.check_name("wasm_custom_section") { + if target != Target::Const { + self.tcx.sess.span_err(attr.span, "only allowed on consts"); } - if name == "wasm_custom_section" { - if target != Target::Const { - self.tcx.sess.span_err(attr.span, "only allowed on consts"); - } - - if attr.value_str().is_none() { - self.tcx.sess.span_err(attr.span, "must be of the form \ - #[wasm_custom_section = \"foo\"]"); - } + if attr.value_str().is_none() { + self.tcx.sess.span_err(attr.span, "must be of the form \ + #[wasm_custom_section = \"foo\"]"); } } } + if target == Target::ForeignMod && + !has_wasm_import_module && + self.tcx.sess.target.target.arch == "wasm32" && + false // FIXME: eventually enable this warning when stable + { + self.tcx.sess.span_warn(item.span, "\ + must have a #[wasm_import_module = \"...\"] attribute, this \ + will become a hard error before too long"); + } + self.check_repr(item, target); } diff --git a/src/librustc/ich/impls_cstore.rs b/src/librustc/ich/impls_cstore.rs index 18a02ff5c58..0071850e105 100644 --- a/src/librustc/ich/impls_cstore.rs +++ b/src/librustc/ich/impls_cstore.rs @@ -33,7 +33,12 @@ impl_stable_hash_for!(struct middle::cstore::NativeLibrary { kind, name, cfg, - foreign_items + foreign_module +}); + +impl_stable_hash_for!(struct middle::cstore::ForeignModule { + foreign_items, + def_id }); impl_stable_hash_for!(enum middle::cstore::LinkagePreference { diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 3c451d7ae46..add9b621596 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -132,7 +132,13 @@ pub struct NativeLibrary { pub kind: NativeLibraryKind, pub name: Symbol, pub cfg: Option, + pub foreign_module: Option, +} + +#[derive(Clone, Hash, RustcEncodable, RustcDecodable)] +pub struct ForeignModule { pub foreign_items: Vec, + pub def_id: DefId, } pub enum LoadedMacro { diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 0b41c3ab2fa..7565e90df98 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -430,6 +430,12 @@ impl<'tcx> QueryDescription<'tcx> for queries::native_libraries<'tcx> { } } +impl<'tcx> QueryDescription<'tcx> for queries::foreign_modules<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("looking up the foreign modules of a linked crate") + } +} + impl<'tcx> QueryDescription<'tcx> for queries::plugin_registrar_fn<'tcx> { fn describe(_tcx: TyCtxt, _: CrateNum) -> String { format!("looking up the plugin registrar for a crate") @@ -705,6 +711,18 @@ impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for<'tcx> { } } +impl<'tcx> QueryDescription<'tcx> for queries::wasm_import_module_map<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("wasm import module map") + } +} + +impl<'tcx> QueryDescription<'tcx> for queries::dllimport_foreign_items<'tcx> { + fn describe(_tcx: TyCtxt, _: CrateNum) -> String { + format!("wasm import module map") + } +} + macro_rules! impl_disk_cacheable_query( ($query_name:ident, |$key:tt| $cond:expr) => { impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> { diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 2b4c1992762..c16ad0d8ca1 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -18,7 +18,7 @@ use infer::canonical::{Canonical, QueryResult}; use lint; use middle::borrowck::BorrowCheckResult; use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, - ExternBodyNestedBodies}; + ExternBodyNestedBodies, ForeignModule}; use middle::cstore::{NativeLibraryKind, DepKind, CrateSource, ExternConstBody}; use middle::privacy::AccessLevels; use middle::reachable::ReachableSet; @@ -320,6 +320,9 @@ define_maps! { <'tcx> [] fn native_libraries: NativeLibraries(CrateNum) -> Lrc>, + + [] fn foreign_modules: ForeignModules(CrateNum) -> Lrc>, + [] fn plugin_registrar_fn: PluginRegistrarFn(CrateNum) -> Option, [] fn derive_registrar_fn: DeriveRegistrarFn(CrateNum) -> Option, [] fn crate_disambiguator: CrateDisambiguator(CrateNum) -> CrateDisambiguator, @@ -331,6 +334,8 @@ define_maps! { <'tcx> [] fn all_trait_implementations: AllTraitImplementations(CrateNum) -> Lrc>, + [] fn dllimport_foreign_items: DllimportForeignItems(CrateNum) + -> Lrc>, [] fn is_dllimport_foreign_item: IsDllimportForeignItem(DefId) -> bool, [] fn is_statically_included_foreign_item: IsStaticallyIncludedForeignItem(DefId) -> bool, [] fn native_library_kind: NativeLibraryKind(DefId) @@ -426,6 +431,8 @@ define_maps! { <'tcx> [] fn program_clauses_for: ProgramClausesFor(DefId) -> Lrc>>, [] fn wasm_custom_sections: WasmCustomSections(CrateNum) -> Lrc>, + [] fn wasm_import_module_map: WasmImportModuleMap(CrateNum) + -> Lrc>, } ////////////////////////////////////////////////////////////////////// diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 910c00b832e..46106d8ec0e 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -886,6 +886,9 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, force!(all_trait_implementations, krate!()); } + DepKind::DllimportForeignItems => { + force!(dllimport_foreign_items, krate!()); + } DepKind::IsDllimportForeignItem => { force!(is_dllimport_foreign_item, def_id!()); } @@ -941,6 +944,8 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::ProgramClausesFor => { force!(program_clauses_for, def_id!()); } DepKind::WasmCustomSections => { force!(wasm_custom_sections, krate!()); } + DepKind::WasmImportModuleMap => { force!(wasm_import_module_map, krate!()); } + DepKind::ForeignModules => { force!(foreign_modules, krate!()); } } true diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index a0546b369a8..baaf57c8908 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -12,7 +12,6 @@ use cstore::{self, CStore, CrateSource, MetadataBlob}; use locator::{self, CratePaths}; -use native_libs::relevant_lib; use schema::CrateRoot; use rustc_data_structures::sync::{Lrc, RwLock, Lock}; @@ -230,7 +229,7 @@ impl<'a> CrateLoader<'a> { .map(|trait_impls| (trait_impls.trait_id, trait_impls.impls)) .collect(); - let mut cmeta = cstore::CrateMetadata { + let cmeta = cstore::CrateMetadata { name, extern_crate: Lock::new(None), def_path_table: Lrc::new(def_path_table), @@ -250,25 +249,8 @@ impl<'a> CrateLoader<'a> { rlib, rmeta, }, - // Initialize this with an empty set. The field is populated below - // after we were able to deserialize its contents. - dllimport_foreign_items: FxHashSet(), }; - let dllimports: FxHashSet<_> = cmeta - .root - .native_libraries - .decode((&cmeta, self.sess)) - .filter(|lib| relevant_lib(self.sess, lib) && - lib.kind == cstore::NativeLibraryKind::NativeUnknown) - .flat_map(|lib| { - assert!(lib.foreign_items.iter().all(|def_id| def_id.krate == cnum)); - lib.foreign_items.into_iter().map(|def_id| def_id.index) - }) - .collect(); - - cmeta.dllimport_foreign_items = dllimports; - let cmeta = Lrc::new(cmeta); self.cstore.set_crate_data(cnum, cmeta.clone()); (cnum, cmeta) diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index bd5ad93946e..53986f07410 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -20,7 +20,7 @@ use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader}; use rustc::session::{Session, CrateDisambiguator}; use rustc_back::PanicStrategy; use rustc_data_structures::indexed_vec::IndexVec; -use rustc::util::nodemap::{FxHashMap, FxHashSet, NodeMap}; +use rustc::util::nodemap::{FxHashMap, NodeMap}; use rustc_data_structures::sync::{Lrc, RwLock, Lock}; use syntax::{ast, attr}; @@ -30,7 +30,7 @@ use syntax_pos; pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePreference}; pub use rustc::middle::cstore::NativeLibraryKind::*; -pub use rustc::middle::cstore::{CrateSource, LibSource}; +pub use rustc::middle::cstore::{CrateSource, LibSource, ForeignModule}; pub use cstore_impl::{provide, provide_extern}; @@ -84,8 +84,6 @@ pub struct CrateMetadata { pub source: CrateSource, pub proc_macros: Option)>>, - // Foreign items imported from a dylib (Windows only) - pub dllimport_foreign_items: FxHashSet, } pub struct CStore { diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 3c2f984ef8b..e911a03bbe2 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -12,6 +12,7 @@ use cstore; use encoder; use link_args; use native_libs; +use foreign_modules; use schema; use rustc::ty::maps::QueryConfig; @@ -197,6 +198,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, Lrc::new(reachable_non_generics) } native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) } + foreign_modules => { Lrc::new(cdata.get_foreign_modules(tcx.sess)) } plugin_registrar_fn => { cdata.root.plugin_registrar_fn.map(|index| { DefId { krate: def_id.krate, index } @@ -224,9 +226,6 @@ provide! { <'tcx> tcx, def_id, other, cdata, Lrc::new(result) } - is_dllimport_foreign_item => { - cdata.is_dllimport_foreign_item(def_id.index) - } visibility => { cdata.get_visibility(def_id.index) } dep_kind => { let r = *cdata.dep_kind.lock(); @@ -306,13 +305,28 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) { tcx.native_libraries(id.krate) .iter() .filter(|lib| native_libs::relevant_lib(&tcx.sess, lib)) - .find(|l| l.foreign_items.contains(&id)) + .find(|lib| { + let fm_id = match lib.foreign_module { + Some(id) => id, + None => return false, + }; + tcx.foreign_modules(id.krate) + .iter() + .find(|m| m.def_id == fm_id) + .expect("failed to find foreign module") + .foreign_items + .contains(&id) + }) .map(|l| l.kind) }, native_libraries: |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); Lrc::new(native_libs::collect(tcx)) }, + foreign_modules: |tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + Lrc::new(foreign_modules::collect(tcx)) + }, link_args: |tcx, cnum| { assert_eq!(cnum, LOCAL_CRATE); Lrc::new(link_args::collect(tcx)) diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 0e5df3142af..e72f9ddd82a 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -10,7 +10,7 @@ // Decoding metadata from a single crate's metadata -use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary}; +use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule}; use schema::*; use rustc_data_structures::sync::{Lrc, ReadGuard}; @@ -1031,6 +1031,10 @@ impl<'a, 'tcx> CrateMetadata { self.root.native_libraries.decode((self, sess)).collect() } + pub fn get_foreign_modules(&self, sess: &Session) -> Vec { + self.root.foreign_modules.decode((self, sess)).collect() + } + pub fn get_dylib_dependency_formats(&self) -> Vec<(CrateNum, LinkagePreference)> { self.root .dylib_dependency_formats @@ -1103,10 +1107,6 @@ impl<'a, 'tcx> CrateMetadata { } } - pub fn is_dllimport_foreign_item(&self, id: DefIndex) -> bool { - self.dllimport_foreign_items.contains(&id) - } - pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'a, 'tcx, 'tcx>) diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 56981b8f4a1..39de1ec852e 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -14,7 +14,7 @@ use isolated_encoder::IsolatedEncoder; use schema::*; use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary, - EncodedMetadata}; + EncodedMetadata, ForeignModule}; use rustc::hir::def::CtorKind; use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LocalDefId, LOCAL_CRATE}; use rustc::hir::map::definitions::DefPathTable; @@ -412,6 +412,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { ()); let native_lib_bytes = self.position() - i; + let foreign_modules = self.tracked( + IsolatedEncoder::encode_foreign_modules, + ()); + // Encode codemap i = self.position(); let codemap = self.encode_codemap(); @@ -480,6 +484,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { lang_items, lang_items_missing, native_libraries, + foreign_modules, codemap, def_path_table, impls, @@ -1337,6 +1342,11 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { self.lazy_seq(used_libraries.iter().cloned()) } + fn encode_foreign_modules(&mut self, _: ()) -> LazySeq { + let foreign_modules = self.tcx.foreign_modules(LOCAL_CRATE); + self.lazy_seq(foreign_modules.iter().cloned()) + } + fn encode_crate_deps(&mut self, _: ()) -> LazySeq { let crates = self.tcx.crates(); diff --git a/src/librustc_metadata/foreign_modules.rs b/src/librustc_metadata/foreign_modules.rs new file mode 100644 index 00000000000..c44d891b7f3 --- /dev/null +++ b/src/librustc_metadata/foreign_modules.rs @@ -0,0 +1,48 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use rustc::hir::itemlikevisit::ItemLikeVisitor; +use rustc::hir; +use rustc::middle::cstore::ForeignModule; +use rustc::ty::TyCtxt; + +pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec { + let mut collector = Collector { + tcx, + modules: Vec::new(), + }; + tcx.hir.krate().visit_all_item_likes(&mut collector); + return collector.modules +} + +struct Collector<'a, 'tcx: 'a> { + tcx: TyCtxt<'a, 'tcx, 'tcx>, + modules: Vec, +} + +impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { + fn visit_item(&mut self, it: &'tcx hir::Item) { + let fm = match it.node { + hir::ItemForeignMod(ref fm) => fm, + _ => return, + }; + + let foreign_items = fm.items.iter() + .map(|it| self.tcx.hir.local_def_id(it.id)) + .collect(); + self.modules.push(ForeignModule { + foreign_items, + def_id: self.tcx.hir.local_def_id(it.id), + }); + } + + fn visit_trait_item(&mut self, _it: &'tcx hir::TraitItem) {} + fn visit_impl_item(&mut self, _it: &'tcx hir::ImplItem) {} +} diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index f77c22bd895..85099667449 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -56,6 +56,7 @@ mod isolated_encoder; mod schema; mod native_libs; mod link_args; +mod foreign_modules; pub mod creader; pub mod cstore; diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 2504f8dc251..4bb6d8fb87c 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -105,14 +105,11 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { } else { None }; - let foreign_items = fm.items.iter() - .map(|it| self.tcx.hir.local_def_id(it.id)) - .collect(); let lib = NativeLibrary { name: n, kind, cfg, - foreign_items, + foreign_module: Some(self.tcx.hir.local_def_id(it.id)), }; self.register_native_lib(Some(m.span), lib); } @@ -218,7 +215,7 @@ impl<'a, 'tcx> Collector<'a, 'tcx> { name: Symbol::intern(new_name.unwrap_or(name)), kind: if let Some(k) = kind { k } else { cstore::NativeUnknown }, cfg: None, - foreign_items: Vec::new(), + foreign_module: None, }; self.register_native_lib(None, lib); } diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 001772623e7..98327945297 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -15,8 +15,8 @@ use rustc::hir; use rustc::hir::def::{self, CtorKind}; use rustc::hir::def_id::{DefIndex, DefId, CrateNum}; use rustc::ich::StableHashingContext; -use rustc::middle::cstore::{DepKind, LinkagePreference, NativeLibrary}; use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel}; +use rustc::middle::cstore::{DepKind, LinkagePreference, NativeLibrary, ForeignModule}; use rustc::middle::lang_items; use rustc::mir; use rustc::session::CrateDisambiguator; @@ -200,6 +200,7 @@ pub struct CrateRoot { pub lang_items: LazySeq<(DefIndex, usize)>, pub lang_items_missing: LazySeq, pub native_libraries: LazySeq, + pub foreign_modules: LazySeq, pub codemap: LazySeq, pub def_path_table: Lazy, pub impls: LazySeq, diff --git a/src/librustc_trans/attributes.rs b/src/librustc_trans/attributes.rs index 16253aa92ac..df78ccdd229 100644 --- a/src/librustc_trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -18,6 +18,7 @@ use rustc::session::config::Sanitizer; use rustc::ty::TyCtxt; use rustc::ty::maps::Providers; use rustc_data_structures::sync::Lrc; +use rustc_data_structures::fx::FxHashMap; use llvm::{self, Attribute, ValueRef}; use llvm::AttributePlace::Function; @@ -141,6 +142,20 @@ pub fn from_fn_attrs(cx: &CodegenCx, llfn: ValueRef, id: DefId) { llfn, llvm::AttributePlace::Function, cstr("target-features\0"), &val); } + + // Note that currently the `wasm-import-module` doesn't do anything, but + // eventually LLVM 7 should read this and ferry the appropriate import + // module to the output file. + if cx.tcx.sess.target.target.arch == "wasm32" { + if let Some(module) = wasm_import_module(cx.tcx, id) { + llvm::AddFunctionAttrStringValue( + llfn, + llvm::AttributePlace::Function, + cstr("wasm-import-module\0"), + &module, + ); + } + } } fn cstr(s: &'static str) -> &CStr { @@ -170,6 +185,8 @@ pub fn provide(providers: &mut Providers) { tcx.hir.krate().visit_all_item_likes(&mut finder); Lrc::new(finder.list) }; + + provide_extern(providers); } struct WasmSectionFinder<'a, 'tcx: 'a> { @@ -192,3 +209,32 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for WasmSectionFinder<'a, 'tcx> { fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) {} } + +pub fn provide_extern(providers: &mut Providers) { + providers.wasm_import_module_map = |tcx, cnum| { + let mut ret = FxHashMap(); + for lib in tcx.foreign_modules(cnum).iter() { + let attrs = tcx.get_attrs(lib.def_id); + let mut module = None; + for attr in attrs.iter().filter(|a| a.check_name("wasm_import_module")) { + module = attr.value_str(); + } + let module = match module { + Some(s) => s, + None => continue, + }; + for id in lib.foreign_items.iter() { + assert_eq!(id.krate, cnum); + ret.insert(*id, module.to_string()); + } + } + + Lrc::new(ret) + } +} + +fn wasm_import_module(tcx: TyCtxt, id: DefId) -> Option { + tcx.wasm_import_module_map(id.krate) + .get(&id) + .map(|s| CString::new(&s[..]).unwrap()) +} diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 8e8ba823b6f..542cdc5baad 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -813,6 +813,7 @@ fn link_natively(sess: &Session, } if sess.opts.target_triple == "wasm32-unknown-unknown" { + wasm::rewrite_imports(&out_filename, &trans.crate_info.wasm_imports); wasm::add_custom_sections(&out_filename, &trans.crate_info.wasm_custom_sections); } diff --git a/src/librustc_trans/back/wasm.rs b/src/librustc_trans/back/wasm.rs index 99f1e4b7e78..d6d386c9fbe 100644 --- a/src/librustc_trans/back/wasm.rs +++ b/src/librustc_trans/back/wasm.rs @@ -8,37 +8,254 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::collections::BTreeMap; use std::fs; use std::path::Path; -use std::collections::BTreeMap; +use std::str; +use rustc_data_structures::fx::FxHashMap; use serialize::leb128; +// https://webassembly.github.io/spec/core/binary/modules.html#binary-importsec +const WASM_IMPORT_SECTION_ID: u8 = 2; + +const WASM_EXTERNAL_KIND_FUNCTION: u8 = 0; +const WASM_EXTERNAL_KIND_TABLE: u8 = 1; +const WASM_EXTERNAL_KIND_MEMORY: u8 = 2; +const WASM_EXTERNAL_KIND_GLOBAL: u8 = 3; + +/// Append all the custom sections listed in `sections` to the wasm binary +/// specified at `path`. +/// +/// LLVM 6 which we're using right now doesn't have the ability to create custom +/// sections in wasm files nor does LLD have the ability to merge these sections +/// into one larger section when linking. It's expected that this will +/// eventually get implemented, however! +/// +/// Until that time though this is a custom implementation in rustc to append +/// all sections to a wasm file to the finished product that LLD produces. +/// +/// Support for this is landing in LLVM in https://reviews.llvm.org/D43097, +/// although after that support will need to be in LLD as well. pub fn add_custom_sections(path: &Path, sections: &BTreeMap>) { - let mut wasm = fs::read(path).expect("failed to read wasm output"); + if sections.len() == 0 { + return + } + + let wasm = fs::read(path).expect("failed to read wasm output"); // see https://webassembly.github.io/spec/core/binary/modules.html#custom-section + let mut wasm = WasmEncoder { data: wasm }; for (section, bytes) in sections { // write the `id` identifier, 0 for a custom section - let len = wasm.len(); - leb128::write_u32_leb128(&mut wasm, len, 0); + wasm.byte(0); // figure out how long our name descriptor will be - let mut name = Vec::new(); - leb128::write_u32_leb128(&mut name, 0, section.len() as u32); - name.extend_from_slice(section.as_bytes()); + let mut name = WasmEncoder::new(); + name.str(section); + + // write the length of the payload followed by all its contents + wasm.u32((bytes.len() + name.data.len()) as u32); + wasm.data.extend_from_slice(&name.data); + wasm.data.extend_from_slice(bytes); + } + + fs::write(path, &wasm.data).expect("failed to write wasm output"); +} + +/// Rewrite the module imports are listed from in a wasm module given the field +/// name to module name mapping in `import_map`. +/// +/// LLVM 6 which we're using right now doesn't have the ability to configure the +/// module a wasm symbol is import from. Rather all imported symbols come from +/// the bland `"env"` module unconditionally. Furthermore we'd *also* need +/// support in LLD for preserving these import modules, which it unfortunately +/// currently does not. +/// +/// This function is intended as a hack for now where we manually rewrite the +/// wasm output by LLVM to have the correct import modules listed. The +/// `#[wasm_import_module]` attribute in Rust translates to the module that each +/// symbol is imported from, so here we manually go through the wasm file, +/// decode it, rewrite imports, and then rewrite the wasm module. +/// +/// Support for this was added to LLVM in +/// https://github.com/llvm-mirror/llvm/commit/0f32e1365, although support still +/// needs to be added (AFAIK at the time of this writing) to LLD +pub fn rewrite_imports(path: &Path, import_map: &FxHashMap) { + if import_map.len() == 0 { + return + } + + let wasm = fs::read(path).expect("failed to read wasm output"); + let mut ret = WasmEncoder::new(); + ret.data.extend(&wasm[..8]); + + // skip the 8 byte wasm/version header + for (id, raw) in WasmSections(WasmDecoder::new(&wasm[8..])) { + ret.byte(id); + if id == WASM_IMPORT_SECTION_ID { + info!("rewriting import section"); + let data = rewrite_import_section( + &mut WasmDecoder::new(raw), + import_map, + ); + ret.bytes(&data); + } else { + info!("carry forward section {}, {} bytes long", id, raw.len()); + ret.bytes(raw); + } + } + + fs::write(path, &ret.data).expect("failed to write wasm output"); + + fn rewrite_import_section( + wasm: &mut WasmDecoder, + import_map: &FxHashMap, + ) + -> Vec + { + let mut dst = WasmEncoder::new(); + let n = wasm.u32(); + dst.u32(n); + info!("rewriting {} imports", n); + for _ in 0..n { + rewrite_import_entry(wasm, &mut dst, import_map); + } + return dst.data + } + + fn rewrite_import_entry(wasm: &mut WasmDecoder, + dst: &mut WasmEncoder, + import_map: &FxHashMap) { + // More info about the binary format here is available at: + // https://webassembly.github.io/spec/core/binary/modules.html#import-section + // + // Note that you can also find the whole point of existence of this + // function here, where we map the `module` name to a different one if + // we've got one listed. + let module = wasm.str(); + let field = wasm.str(); + let new_module = if module == "env" { + import_map.get(field).map(|s| &**s).unwrap_or(module) + } else { + module + }; + info!("import rewrite ({} => {}) / {}", module, new_module, field); + dst.str(new_module); + dst.str(field); + let kind = wasm.byte(); + dst.byte(kind); + match kind { + WASM_EXTERNAL_KIND_FUNCTION => dst.u32(wasm.u32()), + WASM_EXTERNAL_KIND_TABLE => { + dst.byte(wasm.byte()); // element_type + dst.limits(wasm.limits()); + } + WASM_EXTERNAL_KIND_MEMORY => dst.limits(wasm.limits()), + WASM_EXTERNAL_KIND_GLOBAL => { + dst.byte(wasm.byte()); // content_type + dst.bool(wasm.bool()); // mutable + } + b => panic!("unknown kind: {}", b), + } + } +} - // write the length of the payload - let len = wasm.len(); - let total_len = bytes.len() + name.len(); - leb128::write_u32_leb128(&mut wasm, len, total_len as u32); +struct WasmSections<'a>(WasmDecoder<'a>); - // write out the name section - wasm.extend(name); +impl<'a> Iterator for WasmSections<'a> { + type Item = (u8, &'a [u8]); - // and now the payload itself - wasm.extend_from_slice(bytes); + fn next(&mut self) -> Option<(u8, &'a [u8])> { + if self.0.data.len() == 0 { + return None + } + + // see https://webassembly.github.io/spec/core/binary/modules.html#sections + let id = self.0.byte(); + let section_len = self.0.u32(); + info!("new section {} / {} bytes", id, section_len); + let section = self.0.skip(section_len as usize); + Some((id, section)) } +} + +struct WasmDecoder<'a> { + data: &'a [u8], +} - fs::write(path, &wasm).expect("failed to write wasm output"); +impl<'a> WasmDecoder<'a> { + fn new(data: &'a [u8]) -> WasmDecoder<'a> { + WasmDecoder { data } + } + + fn byte(&mut self) -> u8 { + self.skip(1)[0] + } + + fn u32(&mut self) -> u32 { + let (n, l1) = leb128::read_u32_leb128(self.data); + self.data = &self.data[l1..]; + return n + } + + fn skip(&mut self, amt: usize) -> &'a [u8] { + let (data, rest) = self.data.split_at(amt); + self.data = rest; + data + } + + fn str(&mut self) -> &'a str { + let len = self.u32(); + str::from_utf8(self.skip(len as usize)).unwrap() + } + + fn bool(&mut self) -> bool { + self.byte() == 1 + } + + fn limits(&mut self) -> (u32, Option) { + let has_max = self.bool(); + (self.u32(), if has_max { Some(self.u32()) } else { None }) + } +} + +struct WasmEncoder { + data: Vec, +} + +impl WasmEncoder { + fn new() -> WasmEncoder { + WasmEncoder { data: Vec::new() } + } + + fn u32(&mut self, val: u32) { + let at = self.data.len(); + leb128::write_u32_leb128(&mut self.data, at, val); + } + + fn byte(&mut self, val: u8) { + self.data.push(val); + } + + fn bytes(&mut self, val: &[u8]) { + self.u32(val.len() as u32); + self.data.extend_from_slice(val); + } + + fn str(&mut self, val: &str) { + self.bytes(val.as_bytes()) + } + + fn bool(&mut self, b: bool) { + self.byte(b as u8); + } + + fn limits(&mut self, limits: (u32, Option)) { + self.bool(limits.1.is_some()); + self.u32(limits.0); + if let Some(c) = limits.1 { + self.u32(c); + } + } } diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 11f952bc5bc..56eece9f31e 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -72,6 +72,7 @@ use type_::Type; use type_of::LayoutLlvmExt; use rustc::util::nodemap::{FxHashMap, FxHashSet, DefIdSet}; use CrateInfo; +use rustc_data_structures::sync::Lrc; use std::any::Any; use std::collections::BTreeMap; @@ -1072,14 +1073,15 @@ impl CrateInfo { used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic), used_crate_source: FxHashMap(), wasm_custom_sections: BTreeMap::new(), + wasm_imports: FxHashMap(), }; - let load_wasm_sections = tcx.sess.crate_types.borrow() + let load_wasm_items = tcx.sess.crate_types.borrow() .iter() .any(|c| *c != config::CrateTypeRlib) && tcx.sess.opts.target_triple == "wasm32-unknown-unknown"; - if load_wasm_sections { + if load_wasm_items { info!("attempting to load all wasm sections"); for &id in tcx.wasm_custom_sections(LOCAL_CRATE).iter() { let (name, contents) = fetch_wasm_section(tcx, id); @@ -1087,6 +1089,7 @@ impl CrateInfo { .or_insert(Vec::new()) .extend(contents); } + info.load_wasm_imports(tcx, LOCAL_CRATE); } for &cnum in tcx.crates().iter() { @@ -1108,19 +1111,27 @@ impl CrateInfo { if tcx.is_no_builtins(cnum) { info.is_no_builtins.insert(cnum); } - if load_wasm_sections { + if load_wasm_items { for &id in tcx.wasm_custom_sections(cnum).iter() { let (name, contents) = fetch_wasm_section(tcx, id); info.wasm_custom_sections.entry(name) .or_insert(Vec::new()) .extend(contents); } + info.load_wasm_imports(tcx, cnum); } } - return info } + + fn load_wasm_imports(&mut self, tcx: TyCtxt, cnum: CrateNum) { + for (&id, module) in tcx.wasm_import_module_map(cnum).iter() { + let instance = Instance::mono(tcx, id); + let import_name = tcx.symbol_name(instance); + self.wasm_imports.insert(import_name.to_string(), module.clone()); + } + } } fn is_translated_item(tcx: TyCtxt, id: DefId) -> bool { @@ -1248,6 +1259,39 @@ pub fn provide(providers: &mut Providers) { .expect(&format!("failed to find cgu with name {:?}", name)) }; providers.compile_codegen_unit = compile_codegen_unit; + + provide_extern(providers); +} + +pub fn provide_extern(providers: &mut Providers) { + providers.dllimport_foreign_items = |tcx, krate| { + let module_map = tcx.foreign_modules(krate); + let module_map = module_map.iter() + .map(|lib| (lib.def_id, lib)) + .collect::>(); + + let dllimports = tcx.native_libraries(krate) + .iter() + .filter(|lib| { + if lib.kind != cstore::NativeLibraryKind::NativeUnknown { + return false + } + let cfg = match lib.cfg { + Some(ref cfg) => cfg, + None => return true, + }; + attr::cfg_matches(cfg, &tcx.sess.parse_sess, None) + }) + .filter_map(|lib| lib.foreign_module) + .map(|id| &module_map[&id]) + .flat_map(|module| module.foreign_items.iter().cloned()) + .collect(); + Lrc::new(dllimports) + }; + + providers.is_dllimport_foreign_item = |tcx, def_id| { + tcx.dllimport_foreign_items(def_id.krate).contains(&def_id) + }; } pub fn linkage_to_llvm(linkage: Linkage) -> llvm::Linkage { diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index bb2aeca3748..9f654c8ab29 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -216,6 +216,8 @@ impl TransCrate for LlvmTransCrate { fn provide_extern(&self, providers: &mut ty::maps::Providers) { back::symbol_export::provide_extern(providers); + base::provide_extern(providers); + attributes::provide_extern(providers); } fn trans_crate<'a, 'tcx>( @@ -403,6 +405,7 @@ struct CrateInfo { used_crates_static: Vec<(CrateNum, LibSource)>, used_crates_dynamic: Vec<(CrateNum, LibSource)>, wasm_custom_sections: BTreeMap>, + wasm_imports: FxHashMap, } __build_diagnostic_array! { librustc_trans, DIAGNOSTICS } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index dbcfee208ca..270cee26948 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -454,6 +454,9 @@ declare_features! ( // The #[wasm_custom_section] attribute (active, wasm_custom_section, "1.26.0", None, None), + + // The #![wasm_import_module] attribute + (active, wasm_import_module, "1.26.0", None, None), ); declare_features! ( @@ -920,6 +923,10 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "the `#[no_debug]` attribute was an experimental feature that has been \ deprecated due to lack of demand", cfg_fn!(no_debug))), + ("wasm_import_module", Normal, Gated(Stability::Unstable, + "wasm_import_module", + "experimental attribute", + cfg_fn!(wasm_import_module))), ("omit_gdb_pretty_printer_section", Whitelisted, Gated(Stability::Unstable, "omit_gdb_pretty_printer_section", "the `#[omit_gdb_pretty_printer_section]` \ diff --git a/src/test/run-make/wasm-custom-section/foo.js b/src/test/run-make/wasm-custom-section/foo.js index df69354f3a4..e7a4cfc344e 100644 --- a/src/test/run-make/wasm-custom-section/foo.js +++ b/src/test/run-make/wasm-custom-section/foo.js @@ -43,4 +43,4 @@ assert.strictEqual(section[1], 6); assert.strictEqual(section[2], 1); assert.strictEqual(section[3], 2); -process.exit(1); +process.exit(0); diff --git a/src/test/run-make/wasm-import-module/Makefile b/src/test/run-make/wasm-import-module/Makefile new file mode 100644 index 00000000000..399951e5163 --- /dev/null +++ b/src/test/run-make/wasm-import-module/Makefile @@ -0,0 +1,10 @@ +-include ../../run-make-fulldeps/tools.mk + +ifeq ($(TARGET),wasm32-unknown-unknown) +all: + $(RUSTC) foo.rs --target wasm32-unknown-unknown + $(RUSTC) bar.rs -C lto -O --target wasm32-unknown-unknown + $(NODE) foo.js $(TMPDIR)/bar.wasm +else +all: +endif diff --git a/src/test/run-make/wasm-import-module/bar.rs b/src/test/run-make/wasm-import-module/bar.rs new file mode 100644 index 00000000000..9e659223c65 --- /dev/null +++ b/src/test/run-make/wasm-import-module/bar.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "cdylib"] +#![feature(wasm_import_module)] +#![deny(warnings)] + +extern crate foo; + +#[wasm_import_module = "./me"] +extern { + #[link_name = "me_in_dep"] + fn dep(); +} + +#[no_mangle] +pub extern fn foo() { + unsafe { + foo::dep(); + dep(); + } +} diff --git a/src/test/run-make/wasm-import-module/foo.js b/src/test/run-make/wasm-import-module/foo.js new file mode 100644 index 00000000000..369962e55b1 --- /dev/null +++ b/src/test/run-make/wasm-import-module/foo.js @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +const fs = require('fs'); +const process = require('process'); +const assert = require('assert'); +const buffer = fs.readFileSync(process.argv[2]); + +let m = new WebAssembly.Module(buffer); +let imports = WebAssembly.Module.imports(m); +console.log('imports', imports); +assert.strictEqual(imports.length, 2); + +assert.strictEqual(imports[0].kind, 'function'); +assert.strictEqual(imports[1].kind, 'function'); + +let modules = [imports[0].module, imports[1].module]; +modules.sort(); + +assert.strictEqual(modules[0], './dep'); +assert.strictEqual(modules[1], './me'); diff --git a/src/test/run-make/wasm-import-module/foo.rs b/src/test/run-make/wasm-import-module/foo.rs new file mode 100644 index 00000000000..bcd2ca70bef --- /dev/null +++ b/src/test/run-make/wasm-import-module/foo.rs @@ -0,0 +1,18 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(wasm_import_module)] +#![deny(warnings)] + +#[wasm_import_module = "./dep"] +extern { + pub fn dep(); +} diff --git a/src/test/ui/feature-gate-wasm_custom_section.stderr b/src/test/ui/feature-gate-wasm_custom_section.stderr index 5977ec9edad..1b4415539f4 100644 --- a/src/test/ui/feature-gate-wasm_custom_section.stderr +++ b/src/test/ui/feature-gate-wasm_custom_section.stderr @@ -8,4 +8,4 @@ LL | #[wasm_custom_section = "foo"] //~ ERROR: attribute is currently unstable error: aborting due to previous error -If you want more information on this error, try using "rustc --explain E0658" +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gate-wasm_import_module.rs b/src/test/ui/feature-gate-wasm_import_module.rs new file mode 100644 index 00000000000..c5898a9c126 --- /dev/null +++ b/src/test/ui/feature-gate-wasm_import_module.rs @@ -0,0 +1,15 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[wasm_import_module = "test"] //~ ERROR: experimental +extern { +} + +fn main() {} diff --git a/src/test/ui/feature-gate-wasm_import_module.stderr b/src/test/ui/feature-gate-wasm_import_module.stderr new file mode 100644 index 00000000000..bae5fa9d595 --- /dev/null +++ b/src/test/ui/feature-gate-wasm_import_module.stderr @@ -0,0 +1,11 @@ +error[E0658]: experimental attribute + --> $DIR/feature-gate-wasm_import_module.rs:11:1 + | +LL | #[wasm_import_module = "test"] //~ ERROR: experimental + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(wasm_import_module)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/wasm-import-module.rs b/src/test/ui/wasm-import-module.rs new file mode 100644 index 00000000000..0b743d9e486 --- /dev/null +++ b/src/test/ui/wasm-import-module.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(wasm_import_module)] + +#[wasm_import_module] //~ ERROR: must be of the form +extern {} + +#[wasm_import_module = "foo"] //~ ERROR: must only be attached to +fn foo() {} + +fn main() {} + diff --git a/src/test/ui/wasm-import-module.stderr b/src/test/ui/wasm-import-module.stderr new file mode 100644 index 00000000000..bf301ce5269 --- /dev/null +++ b/src/test/ui/wasm-import-module.stderr @@ -0,0 +1,14 @@ +error: must be of the form #[wasm_import_module = "..."] + --> $DIR/wasm-import-module.rs:13:1 + | +LL | #[wasm_import_module] //~ ERROR: must be of the form + | ^^^^^^^^^^^^^^^^^^^^^ + +error: must only be attached to foreign modules + --> $DIR/wasm-import-module.rs:16:1 + | +LL | #[wasm_import_module = "foo"] //~ ERROR: must only be attached to + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + -- cgit 1.4.1-3-g733a5 From ced7687c069051e973a78c54e72271ef9e86fa28 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Fri, 23 Mar 2018 14:40:56 +0800 Subject: add test for issue-48238 --- src/test/ui/nll/issue-48238.rs | 22 ++++++++++++++++++++++ src/test/ui/nll/issue-48238.stderr | 8 ++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/test/ui/nll/issue-48238.rs create mode 100644 src/test/ui/nll/issue-48238.stderr diff --git a/src/test/ui/nll/issue-48238.rs b/src/test/ui/nll/issue-48238.rs new file mode 100644 index 00000000000..6f7644da3d3 --- /dev/null +++ b/src/test/ui/nll/issue-48238.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for issue #48238 + +#![feature(nll)] + +fn use_val<'a>(val: &'a u8) -> &'a u8 { + val +} + +fn main() { + let orig: u8 = 5; + move || use_val(&orig); //~ ERROR free region `` does not outlive free region `'_#1r` +} diff --git a/src/test/ui/nll/issue-48238.stderr b/src/test/ui/nll/issue-48238.stderr new file mode 100644 index 00000000000..29385d9b243 --- /dev/null +++ b/src/test/ui/nll/issue-48238.stderr @@ -0,0 +1,8 @@ +error: free region `` does not outlive free region `'_#1r` + --> $DIR/issue-48238.rs:21:21 + | +LL | move || use_val(&orig); //~ ERROR free region `` does not outlive free region `'_#1r` + | ^^^^^ + +error: aborting due to previous error + -- cgit 1.4.1-3-g733a5 From 0e6cd8b61a392cd80d575eaef86d12d9c3f9e2dc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 23 Mar 2018 07:46:20 -0700 Subject: Test fixes --- src/test/run-pass/rfc-2151-raw-identifiers/attr.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/basic.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/items.rs | 2 ++ src/test/run-pass/rfc-2151-raw-identifiers/macros.rs | 2 ++ src/tools/compiletest/src/runtest.rs | 2 +- 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs index 6cea75cf1d1..3566babaf4c 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/attr.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-pretty + #![feature(raw_identifiers)] use std::mem; diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs index 5d495c4e9e5..bd1f52a9b24 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/basic.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-pretty + #![feature(raw_identifiers)] fn r#fn(r#match: u32) -> u32 { diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs index 256bd263d38..5fdc13df8dc 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/items.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/items.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-pretty + #![feature(raw_identifiers)] #[derive(Debug, PartialEq, Eq)] diff --git a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs index 4bd16ded52f..82d44c57e18 100644 --- a/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs +++ b/src/test/run-pass/rfc-2151-raw-identifiers/macros.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-pretty + #![feature(decl_macro)] #![feature(raw_identifiers)] diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 93b1b1f08e6..e826c5366a8 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2426,7 +2426,7 @@ impl<'test> TestCx<'test> { // compiler flags set in the test cases: cmd.env_remove("RUSTFLAGS"); - if self.config.target.contains("msvc") { + if self.config.target.contains("msvc") && self.config.cc != "" { // We need to pass a path to `lib.exe`, so assume that `cc` is `cl.exe` // and that `lib.exe` lives next to it. let lib = Path::new(&self.config.cc).parent().unwrap().join("lib.exe"); -- cgit 1.4.1-3-g733a5