From ef519c1de54e6d833d05bac7c4ce290ae54e82dc Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Thu, 9 Aug 2018 11:02:08 +0200 Subject: [PATCH 01/23] Add a implementation of `From` for converting `&'a Option` into `Option<&'a T>` --- src/libcore/option.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 2b6c376f8a71c..ad69d13768568 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1064,6 +1064,12 @@ impl From for Option { } } +impl<'a, T> From<&'a Option> for Option<&'a T> { + fn from(o: &'a Option) -> Option<&'a T> { + o.as_ref() + } +} + ///////////////////////////////////////////////////////////////////////////// // The Option Iterators ///////////////////////////////////////////////////////////////////////////// From 0cde1cbb10b044c17e1569ab0306db11735ca798 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Thu, 9 Aug 2018 12:48:55 +0200 Subject: [PATCH 02/23] Add stability attribute --- src/libcore/option.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index ad69d13768568..883e01ff2a81b 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1064,6 +1064,7 @@ impl From for Option { } } +#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] impl<'a, T> From<&'a Option> for Option<&'a T> { fn from(o: &'a Option) -> Option<&'a T> { o.as_ref() From a7a0225a281bbb9306862e647aee2f51aa595086 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 10 Aug 2018 14:21:17 +0200 Subject: [PATCH 03/23] Also add a `From` implementation for `&mut Option` -> `Option<&mut T>' --- src/libcore/option.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 883e01ff2a81b..32a0a8b3c5106 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1071,6 +1071,13 @@ impl<'a, T> From<&'a Option> for Option<&'a T> { } } +#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")] +impl<'a, T> From<&'a mut Option> for Option<&'a mut T> { + fn from(o: &'a mut Option) -> Option<&'a mut T> { + o.as_mut() + } +} + ///////////////////////////////////////////////////////////////////////////// // The Option Iterators ///////////////////////////////////////////////////////////////////////////// From 0c89243fd33a7f9f0ef4ddc9796047c646e9a688 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Sep 2018 00:27:20 -0700 Subject: [PATCH 04/23] Fix compiling some rustc crates to wasm I was dabbling recently seeing what it would take to compile `rustfmt` to the `wasm32-unknown-unknown` target and it turns out not much effort is needed! Currently `rustfmt` depends on a few rustc crates published to crates.io, so this commit touches up those crates to compile for wasm themselves. Notably: * The `rustc_data_structures` crate's `flock` implementation is stubbed out to unconditionally return errors on unsupported platforms. * The `rustc_errors` crate is extended to not do any locking for all non-windows platforms. In both of these cases if we port the compiler to new platforms the functionality isn't critical but will be discovered over time as it comes up, so this hopefully doesn't make it too too hard to compile to new platforms! --- src/librustc_data_structures/flock.rs | 590 +++++++++++++------------- src/librustc_errors/lock.rs | 2 +- 2 files changed, 299 insertions(+), 293 deletions(-) diff --git a/src/librustc_data_structures/flock.rs b/src/librustc_data_structures/flock.rs index f10a9a68bed5b..38ce331051fec 100644 --- a/src/librustc_data_structures/flock.rs +++ b/src/librustc_data_structures/flock.rs @@ -15,345 +15,351 @@ //! librustdoc, it is not production quality at all. #![allow(non_camel_case_types)] -use std::path::Path; - -pub use self::imp::Lock; +#![allow(nonstandard_style)] -#[cfg(unix)] -mod imp { - use std::ffi::{CString, OsStr}; - use std::os::unix::prelude::*; - use std::path::Path; - use std::io; - use libc; +use std::io; +use std::path::Path; - #[cfg(any(target_os = "linux", target_os = "android"))] - mod os { +cfg_if! { + if #[cfg(unix)] { + use std::ffi::{CString, OsStr}; + use std::os::unix::prelude::*; use libc; - #[repr(C)] - pub struct flock { - pub l_type: libc::c_short, - pub l_whence: libc::c_short, - pub l_start: libc::off_t, - pub l_len: libc::off_t, - pub l_pid: libc::pid_t, - - // not actually here, but brings in line with freebsd - pub l_sysid: libc::c_int, - } + #[cfg(any(target_os = "linux", target_os = "android"))] + mod os { + use libc; - pub const F_RDLCK: libc::c_short = 0; - pub const F_WRLCK: libc::c_short = 1; - pub const F_UNLCK: libc::c_short = 2; - pub const F_SETLK: libc::c_int = 6; - pub const F_SETLKW: libc::c_int = 7; - } + #[repr(C)] + pub struct flock { + pub l_type: libc::c_short, + pub l_whence: libc::c_short, + pub l_start: libc::off_t, + pub l_len: libc::off_t, + pub l_pid: libc::pid_t, - #[cfg(target_os = "freebsd")] - mod os { - use libc; + // not actually here, but brings in line with freebsd + pub l_sysid: libc::c_int, + } - #[repr(C)] - pub struct flock { - pub l_start: libc::off_t, - pub l_len: libc::off_t, - pub l_pid: libc::pid_t, - pub l_type: libc::c_short, - pub l_whence: libc::c_short, - pub l_sysid: libc::c_int, + pub const F_RDLCK: libc::c_short = 0; + pub const F_WRLCK: libc::c_short = 1; + pub const F_UNLCK: libc::c_short = 2; + pub const F_SETLK: libc::c_int = 6; + pub const F_SETLKW: libc::c_int = 7; } - pub const F_RDLCK: libc::c_short = 1; - pub const F_UNLCK: libc::c_short = 2; - pub const F_WRLCK: libc::c_short = 3; - pub const F_SETLK: libc::c_int = 12; - pub const F_SETLKW: libc::c_int = 13; - } - - #[cfg(any(target_os = "dragonfly", - target_os = "bitrig", - target_os = "netbsd", - target_os = "openbsd"))] - mod os { - use libc; + #[cfg(target_os = "freebsd")] + mod os { + use libc; + + #[repr(C)] + pub struct flock { + pub l_start: libc::off_t, + pub l_len: libc::off_t, + pub l_pid: libc::pid_t, + pub l_type: libc::c_short, + pub l_whence: libc::c_short, + pub l_sysid: libc::c_int, + } - #[repr(C)] - pub struct flock { - pub l_start: libc::off_t, - pub l_len: libc::off_t, - pub l_pid: libc::pid_t, - pub l_type: libc::c_short, - pub l_whence: libc::c_short, - - // not actually here, but brings in line with freebsd - pub l_sysid: libc::c_int, + pub const F_RDLCK: libc::c_short = 1; + pub const F_UNLCK: libc::c_short = 2; + pub const F_WRLCK: libc::c_short = 3; + pub const F_SETLK: libc::c_int = 12; + pub const F_SETLKW: libc::c_int = 13; } - pub const F_RDLCK: libc::c_short = 1; - pub const F_UNLCK: libc::c_short = 2; - pub const F_WRLCK: libc::c_short = 3; - pub const F_SETLK: libc::c_int = 8; - pub const F_SETLKW: libc::c_int = 9; - } - - #[cfg(target_os = "haiku")] - mod os { - use libc; + #[cfg(any(target_os = "dragonfly", + target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd"))] + mod os { + use libc; + + #[repr(C)] + pub struct flock { + pub l_start: libc::off_t, + pub l_len: libc::off_t, + pub l_pid: libc::pid_t, + pub l_type: libc::c_short, + pub l_whence: libc::c_short, + + // not actually here, but brings in line with freebsd + pub l_sysid: libc::c_int, + } - #[repr(C)] - pub struct flock { - pub l_type: libc::c_short, - pub l_whence: libc::c_short, - pub l_start: libc::off_t, - pub l_len: libc::off_t, - pub l_pid: libc::pid_t, - - // not actually here, but brings in line with freebsd - pub l_sysid: libc::c_int, + pub const F_RDLCK: libc::c_short = 1; + pub const F_UNLCK: libc::c_short = 2; + pub const F_WRLCK: libc::c_short = 3; + pub const F_SETLK: libc::c_int = 8; + pub const F_SETLKW: libc::c_int = 9; } - pub const F_RDLCK: libc::c_short = 0x0040; - pub const F_UNLCK: libc::c_short = 0x0200; - pub const F_WRLCK: libc::c_short = 0x0400; - pub const F_SETLK: libc::c_int = 0x0080; - pub const F_SETLKW: libc::c_int = 0x0100; - } + #[cfg(target_os = "haiku")] + mod os { + use libc; - #[cfg(any(target_os = "macos", target_os = "ios"))] - mod os { - use libc; + #[repr(C)] + pub struct flock { + pub l_type: libc::c_short, + pub l_whence: libc::c_short, + pub l_start: libc::off_t, + pub l_len: libc::off_t, + pub l_pid: libc::pid_t, - #[repr(C)] - pub struct flock { - pub l_start: libc::off_t, - pub l_len: libc::off_t, - pub l_pid: libc::pid_t, - pub l_type: libc::c_short, - pub l_whence: libc::c_short, - - // not actually here, but brings in line with freebsd - pub l_sysid: libc::c_int, + // not actually here, but brings in line with freebsd + pub l_sysid: libc::c_int, + } + + pub const F_RDLCK: libc::c_short = 0x0040; + pub const F_UNLCK: libc::c_short = 0x0200; + pub const F_WRLCK: libc::c_short = 0x0400; + pub const F_SETLK: libc::c_int = 0x0080; + pub const F_SETLKW: libc::c_int = 0x0100; } - pub const F_RDLCK: libc::c_short = 1; - pub const F_UNLCK: libc::c_short = 2; - pub const F_WRLCK: libc::c_short = 3; - pub const F_SETLK: libc::c_int = 8; - pub const F_SETLKW: libc::c_int = 9; - } + #[cfg(any(target_os = "macos", target_os = "ios"))] + mod os { + use libc; - #[cfg(target_os = "solaris")] - mod os { - use libc; + #[repr(C)] + pub struct flock { + pub l_start: libc::off_t, + pub l_len: libc::off_t, + pub l_pid: libc::pid_t, + pub l_type: libc::c_short, + pub l_whence: libc::c_short, - #[repr(C)] - pub struct flock { - pub l_type: libc::c_short, - pub l_whence: libc::c_short, - pub l_start: libc::off_t, - pub l_len: libc::off_t, - pub l_sysid: libc::c_int, - pub l_pid: libc::pid_t, + // not actually here, but brings in line with freebsd + pub l_sysid: libc::c_int, + } + + pub const F_RDLCK: libc::c_short = 1; + pub const F_UNLCK: libc::c_short = 2; + pub const F_WRLCK: libc::c_short = 3; + pub const F_SETLK: libc::c_int = 8; + pub const F_SETLKW: libc::c_int = 9; } - pub const F_RDLCK: libc::c_short = 1; - pub const F_WRLCK: libc::c_short = 2; - pub const F_UNLCK: libc::c_short = 3; - pub const F_SETLK: libc::c_int = 6; - pub const F_SETLKW: libc::c_int = 7; - } + #[cfg(target_os = "solaris")] + mod os { + use libc; + + #[repr(C)] + pub struct flock { + pub l_type: libc::c_short, + pub l_whence: libc::c_short, + pub l_start: libc::off_t, + pub l_len: libc::off_t, + pub l_sysid: libc::c_int, + pub l_pid: libc::pid_t, + } - #[derive(Debug)] - pub struct Lock { - fd: libc::c_int, - } + pub const F_RDLCK: libc::c_short = 1; + pub const F_WRLCK: libc::c_short = 2; + pub const F_UNLCK: libc::c_short = 3; + pub const F_SETLK: libc::c_int = 6; + pub const F_SETLKW: libc::c_int = 7; + } - impl Lock { - pub fn new(p: &Path, - wait: bool, - create: bool, - exclusive: bool) - -> io::Result { - let os: &OsStr = p.as_ref(); - let buf = CString::new(os.as_bytes()).unwrap(); - let open_flags = if create { - libc::O_RDWR | libc::O_CREAT - } else { - libc::O_RDWR - }; - - let fd = unsafe { - libc::open(buf.as_ptr(), open_flags, - libc::S_IRWXU as libc::c_int) - }; - - if fd < 0 { - return Err(io::Error::last_os_error()); - } + #[derive(Debug)] + pub struct Lock { + fd: libc::c_int, + } - let lock_type = if exclusive { - os::F_WRLCK - } else { - os::F_RDLCK - }; - - let flock = os::flock { - l_start: 0, - l_len: 0, - l_pid: 0, - l_whence: libc::SEEK_SET as libc::c_short, - l_type: lock_type, - l_sysid: 0, - }; - let cmd = if wait { os::F_SETLKW } else { os::F_SETLK }; - let ret = unsafe { - libc::fcntl(fd, cmd, &flock) - }; - if ret == -1 { - let err = io::Error::last_os_error(); - unsafe { libc::close(fd); } - Err(err) - } else { - Ok(Lock { fd: fd }) + impl Lock { + pub fn new(p: &Path, + wait: bool, + create: bool, + exclusive: bool) + -> io::Result { + let os: &OsStr = p.as_ref(); + let buf = CString::new(os.as_bytes()).unwrap(); + let open_flags = if create { + libc::O_RDWR | libc::O_CREAT + } else { + libc::O_RDWR + }; + + let fd = unsafe { + libc::open(buf.as_ptr(), open_flags, + libc::S_IRWXU as libc::c_int) + }; + + if fd < 0 { + return Err(io::Error::last_os_error()); + } + + let lock_type = if exclusive { + os::F_WRLCK + } else { + os::F_RDLCK + }; + + let flock = os::flock { + l_start: 0, + l_len: 0, + l_pid: 0, + l_whence: libc::SEEK_SET as libc::c_short, + l_type: lock_type, + l_sysid: 0, + }; + let cmd = if wait { os::F_SETLKW } else { os::F_SETLK }; + let ret = unsafe { + libc::fcntl(fd, cmd, &flock) + }; + if ret == -1 { + let err = io::Error::last_os_error(); + unsafe { libc::close(fd); } + Err(err) + } else { + Ok(Lock { fd: fd }) + } } } - } - impl Drop for Lock { - fn drop(&mut self) { - let flock = os::flock { - l_start: 0, - l_len: 0, - l_pid: 0, - l_whence: libc::SEEK_SET as libc::c_short, - l_type: os::F_UNLCK, - l_sysid: 0, - }; - unsafe { - libc::fcntl(self.fd, os::F_SETLK, &flock); - libc::close(self.fd); + impl Drop for Lock { + fn drop(&mut self) { + let flock = os::flock { + l_start: 0, + l_len: 0, + l_pid: 0, + l_whence: libc::SEEK_SET as libc::c_short, + l_type: os::F_UNLCK, + l_sysid: 0, + }; + unsafe { + libc::fcntl(self.fd, os::F_SETLK, &flock); + libc::close(self.fd); + } } } - } -} + } else if #[cfg(windows)] { + use std::mem; + use std::os::windows::prelude::*; + use std::os::windows::raw::HANDLE; + use std::fs::{File, OpenOptions}; + use std::os::raw::{c_ulong, c_int}; -#[cfg(windows)] -#[allow(nonstandard_style)] -mod imp { - use std::io; - use std::mem; - use std::os::windows::prelude::*; - use std::os::windows::raw::HANDLE; - use std::path::Path; - use std::fs::{File, OpenOptions}; - use std::os::raw::{c_ulong, c_int}; - - type DWORD = c_ulong; - type BOOL = c_int; - type ULONG_PTR = usize; - - type LPOVERLAPPED = *mut OVERLAPPED; - const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x0000_0002; - const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x0000_0001; - - const FILE_SHARE_DELETE: DWORD = 0x4; - const FILE_SHARE_READ: DWORD = 0x1; - const FILE_SHARE_WRITE: DWORD = 0x2; - - #[repr(C)] - struct OVERLAPPED { - Internal: ULONG_PTR, - InternalHigh: ULONG_PTR, - Offset: DWORD, - OffsetHigh: DWORD, - hEvent: HANDLE, - } + type DWORD = c_ulong; + type BOOL = c_int; + type ULONG_PTR = usize; - extern "system" { - fn LockFileEx(hFile: HANDLE, - dwFlags: DWORD, - dwReserved: DWORD, - nNumberOfBytesToLockLow: DWORD, - nNumberOfBytesToLockHigh: DWORD, - lpOverlapped: LPOVERLAPPED) -> BOOL; - } + type LPOVERLAPPED = *mut OVERLAPPED; + const LOCKFILE_EXCLUSIVE_LOCK: DWORD = 0x0000_0002; + const LOCKFILE_FAIL_IMMEDIATELY: DWORD = 0x0000_0001; - #[derive(Debug)] - pub struct Lock { - _file: File, - } + const FILE_SHARE_DELETE: DWORD = 0x4; + const FILE_SHARE_READ: DWORD = 0x1; + const FILE_SHARE_WRITE: DWORD = 0x2; - impl Lock { - pub fn new(p: &Path, - wait: bool, - create: bool, - exclusive: bool) - -> io::Result { - assert!(p.parent().unwrap().exists(), - "Parent directory of lock-file must exist: {}", - p.display()); - - let share_mode = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE; - - let mut open_options = OpenOptions::new(); - open_options.read(true) - .share_mode(share_mode); - - if create { - open_options.create(true) - .write(true); - } + #[repr(C)] + struct OVERLAPPED { + Internal: ULONG_PTR, + InternalHigh: ULONG_PTR, + Offset: DWORD, + OffsetHigh: DWORD, + hEvent: HANDLE, + } - debug!("Attempting to open lock file `{}`", p.display()); - let file = match open_options.open(p) { - Ok(file) => { - debug!("Lock file opened successfully"); - file - } - Err(err) => { - debug!("Error opening lock file: {}", err); - return Err(err) - } - }; + extern "system" { + fn LockFileEx(hFile: HANDLE, + dwFlags: DWORD, + dwReserved: DWORD, + nNumberOfBytesToLockLow: DWORD, + nNumberOfBytesToLockHigh: DWORD, + lpOverlapped: LPOVERLAPPED) -> BOOL; + } - let ret = unsafe { - let mut overlapped: OVERLAPPED = mem::zeroed(); + #[derive(Debug)] + pub struct Lock { + _file: File, + } - let mut dwFlags = 0; - if !wait { - dwFlags |= LOCKFILE_FAIL_IMMEDIATELY; + impl Lock { + pub fn new(p: &Path, + wait: bool, + create: bool, + exclusive: bool) + -> io::Result { + assert!(p.parent().unwrap().exists(), + "Parent directory of lock-file must exist: {}", + p.display()); + + let share_mode = FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE; + + let mut open_options = OpenOptions::new(); + open_options.read(true) + .share_mode(share_mode); + + if create { + open_options.create(true) + .write(true); } - if exclusive { - dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; + debug!("Attempting to open lock file `{}`", p.display()); + let file = match open_options.open(p) { + Ok(file) => { + debug!("Lock file opened successfully"); + file + } + Err(err) => { + debug!("Error opening lock file: {}", err); + return Err(err) + } + }; + + let ret = unsafe { + let mut overlapped: OVERLAPPED = mem::zeroed(); + + let mut dwFlags = 0; + if !wait { + dwFlags |= LOCKFILE_FAIL_IMMEDIATELY; + } + + if exclusive { + dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; + } + + debug!("Attempting to acquire lock on lock file `{}`", + p.display()); + LockFileEx(file.as_raw_handle(), + dwFlags, + 0, + 0xFFFF_FFFF, + 0xFFFF_FFFF, + &mut overlapped) + }; + if ret == 0 { + let err = io::Error::last_os_error(); + debug!("Failed acquiring file lock: {}", err); + Err(err) + } else { + debug!("Successfully acquired lock."); + Ok(Lock { _file: file }) } + } + } - debug!("Attempting to acquire lock on lock file `{}`", - p.display()); - LockFileEx(file.as_raw_handle(), - dwFlags, - 0, - 0xFFFF_FFFF, - 0xFFFF_FFFF, - &mut overlapped) - }; - if ret == 0 { - let err = io::Error::last_os_error(); - debug!("Failed acquiring file lock: {}", err); - Err(err) - } else { - debug!("Successfully acquired lock."); - Ok(Lock { _file: file }) + // Note that we don't need a Drop impl on the Windows: The file is unlocked + // automatically when it's closed. + } else { + #[derive(Debug)] + pub struct Lock(()); + + impl Lock { + pub fn new(_p: &Path, _wait: bool, _create: bool, _exclusive: bool) + -> io::Result + { + let msg = "file locks not supported on this platform"; + Err(io::Error::new(io::ErrorKind::Other, msg)) } } } - - // Note that we don't need a Drop impl on the Windows: The file is unlocked - // automatically when it's closed. } -impl imp::Lock { +impl Lock { pub fn panicking_new(p: &Path, wait: bool, create: bool, diff --git a/src/librustc_errors/lock.rs b/src/librustc_errors/lock.rs index e5baf93b00064..ff323073c6235 100644 --- a/src/librustc_errors/lock.rs +++ b/src/librustc_errors/lock.rs @@ -109,7 +109,7 @@ pub fn acquire_global_lock(name: &str) -> Box { } } -#[cfg(unix)] +#[cfg(not(windows))] pub fn acquire_global_lock(_name: &str) -> Box { Box::new(()) } From d02a5ffaed9c395ae62ee12d0f4e04946c62edb1 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Mon, 10 Sep 2018 10:31:37 +0900 Subject: [PATCH 05/23] renamed emit_nil to emit_unit --- src/doc/book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/libcompiler_builtins | 2 +- src/liblibc | 2 +- src/librustc/ty/query/on_disk_cache.rs | 2 +- src/librustc_metadata/encoder.rs | 2 +- src/libserialize/json.rs | 10 +++++----- src/libserialize/opaque.rs | 2 +- src/libserialize/serialize.rs | 4 ++-- src/llvm | 2 +- src/stdsimd | 2 +- src/tools/cargo | 2 +- src/tools/clippy | 2 +- src/tools/miri | 2 +- src/tools/rls | 2 +- src/tools/rust-installer | 2 +- src/tools/rustfmt | 2 +- 19 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/doc/book b/src/doc/book index cff0930664b68..f51127530d46b 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit cff0930664b688f1dd22aefb3d16944eb4cdbfd5 +Subproject commit f51127530d46b9acbf4747c859da185e771cfcf3 diff --git a/src/doc/nomicon b/src/doc/nomicon index 7fd493465b7dd..748a5e6742db4 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 7fd493465b7dd6cf3476f0b834884059bbdd1d93 +Subproject commit 748a5e6742db4a21c4c630a58087f818828e8a0a diff --git a/src/doc/reference b/src/doc/reference index 821355a6fd642..134f419ee6271 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 821355a6fd642b71988a2f88a3162fb358732012 +Subproject commit 134f419ee62714590b04712fe6072253bc2a7822 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index e459fb3f07f2b..eebda16e4b45f 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit e459fb3f07f2b930ccd25d348671b8eae233fd64 +Subproject commit eebda16e4b45f2eed4310cf7b9872cc752278163 diff --git a/src/libcompiler_builtins b/src/libcompiler_builtins index 0703bfa72524e..2a2f6d96c8dc5 160000 --- a/src/libcompiler_builtins +++ b/src/libcompiler_builtins @@ -1 +1 @@ -Subproject commit 0703bfa72524e01e414477657ca9b64794c5c1c3 +Subproject commit 2a2f6d96c8dc578d2474742f14c9bab0b36b0408 diff --git a/src/liblibc b/src/liblibc index 1844a772b6077..a7e78a78e17c8 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit 1844a772b60771d0124a157019f627d60fea4e73 +Subproject commit a7e78a78e17c8776d7780008ccb3ce541ec64ae9 diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 6e16d92ba0c8d..19e235154cbd0 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -1020,7 +1020,7 @@ impl<'enc, 'a, 'tcx, E> Encoder for CacheEncoder<'enc, 'a, 'tcx, E> { type Error = E::Error; - fn emit_nil(&mut self) -> Result<(), Self::Error> { + fn emit_unit(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index aae45c17c6771..56b38cfbc872a 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -75,7 +75,7 @@ macro_rules! encoder_methods { impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx> { type Error = ::Error; - fn emit_nil(&mut self) -> Result<(), Self::Error> { + fn emit_unit(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 35ef6327de5fd..9439dc78d3ca4 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -490,7 +490,7 @@ macro_rules! emit_enquoted_if_mapkey { impl<'a> ::Encoder for Encoder<'a> { type Error = EncoderError; - fn emit_nil(&mut self) -> EncodeResult { + fn emit_unit(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } write!(self.writer, "null")?; Ok(()) @@ -648,7 +648,7 @@ impl<'a> ::Encoder for Encoder<'a> { } fn emit_option_none(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_nil() + self.emit_unit() } fn emit_option_some(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, @@ -740,7 +740,7 @@ impl<'a> PrettyEncoder<'a> { impl<'a> ::Encoder for PrettyEncoder<'a> { type Error = EncoderError; - fn emit_nil(&mut self) -> EncodeResult { + fn emit_unit(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } write!(self.writer, "null")?; Ok(()) @@ -923,7 +923,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { } fn emit_option_none(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_nil() + self.emit_unit() } fn emit_option_some(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, @@ -1016,7 +1016,7 @@ impl Encodable for Json { Json::Boolean(v) => v.encode(e), Json::Array(ref v) => v.encode(e), Json::Object(ref v) => v.encode(e), - Json::Null => e.emit_nil(), + Json::Null => e.emit_unit(), } } } diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index c71f474891131..4ce80bc36a080 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -55,7 +55,7 @@ impl serialize::Encoder for Encoder { type Error = !; #[inline] - fn emit_nil(&mut self) -> EncodeResult { + fn emit_unit(&mut self) -> EncodeResult { Ok(()) } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 416be50bfe9ea..f0b49c3d9bc8f 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -25,7 +25,7 @@ pub trait Encoder { type Error; // Primitive types: - fn emit_nil(&mut self) -> Result<(), Self::Error>; + fn emit_unit(&mut self) -> Result<(), Self::Error>; fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>; fn emit_u128(&mut self, v: u128) -> Result<(), Self::Error>; fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>; @@ -537,7 +537,7 @@ impl Decodable for char { impl Encodable for () { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_nil() + s.emit_unit() } } diff --git a/src/llvm b/src/llvm index 2a1cdeadd3ea8..7243155b1c3da 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 2a1cdeadd3ea8e1eba9cc681037b83f07332763b +Subproject commit 7243155b1c3da0a980c868a87adebf00e0b33989 diff --git a/src/stdsimd b/src/stdsimd index 05c2f61c384e2..1ea18a5cb431e 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 05c2f61c384e2097a3a4c648344114fc4ac983be +Subproject commit 1ea18a5cb431e24aa838b652ac305acc5e394d6b diff --git a/src/tools/cargo b/src/tools/cargo index 2fb77a49b43bf..af3f1cd29bc87 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 2fb77a49b43bf7266793c07a19a06749e6a8ad5a +Subproject commit af3f1cd29bc872b932a13083e531255aab233a7e diff --git a/src/tools/clippy b/src/tools/clippy index fdd830f52c082..e456241f18227 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit fdd830f52c082b83db0dac3e0066c0cf114050d2 +Subproject commit e456241f18227c7eb8d78a45daa66c756a9b65e7 diff --git a/src/tools/miri b/src/tools/miri index e6f1e15676c26..e0e1bd7ff778e 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit e6f1e15676c26fdc7c4713647fe007b26f361a8e +Subproject commit e0e1bd7ff778e5913b566c9e03224faecc0eb486 diff --git a/src/tools/rls b/src/tools/rls index 5b5cd9d457194..1263f1ff25bb3 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 5b5cd9d45719414196e254ec17baa598acc8cd25 +Subproject commit 1263f1ff25bb329b76f74715ad4a7ec0d1f71430 diff --git a/src/tools/rust-installer b/src/tools/rust-installer index 27dec6cae3a81..118e078c5badd 160000 --- a/src/tools/rust-installer +++ b/src/tools/rust-installer @@ -1 +1 @@ -Subproject commit 27dec6cae3a8132d8a073aad6775425c85095c99 +Subproject commit 118e078c5badd520d18b92813fd88789c8d341ab diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 1c408818c8a75..0f8029f251b56 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 1c408818c8a752dd584e7858b4afd3ceb011a7da +Subproject commit 0f8029f251b569a010cb5cfc5a8bff8bf3c949ac From 37d0600c23ba1890346078bd7f310e15915417b2 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Mon, 10 Sep 2018 10:36:07 +0900 Subject: [PATCH 06/23] renamed read_nil to read_unit --- src/librustc/ty/codec.rs | 2 +- src/libserialize/json.rs | 2 +- src/libserialize/opaque.rs | 2 +- src/libserialize/serialize.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index cc3e8a458a01f..051cca49f7e25 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -298,7 +298,7 @@ macro_rules! implement_ty_decoder { type Error = String; __impl_decoder_methods! { - read_nil -> (); + read_unit -> (); read_u128 -> u128; read_u64 -> u64; diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 9439dc78d3ca4..bbb3b73f2fa1d 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2128,7 +2128,7 @@ macro_rules! read_primitive { impl ::Decoder for Decoder { type Error = DecoderError; - fn read_nil(&mut self) -> DecodeResult<()> { + fn read_unit(&mut self) -> DecodeResult<()> { expect!(self.pop(), Null) } diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index 4ce80bc36a080..fee5e59cc4013 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -228,7 +228,7 @@ impl<'a> serialize::Decoder for Decoder<'a> { type Error = String; #[inline] - fn read_nil(&mut self) -> Result<(), Self::Error> { + fn read_unit(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index f0b49c3d9bc8f..64d6dbecea651 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -167,7 +167,7 @@ pub trait Decoder { type Error; // Primitive types: - fn read_nil(&mut self) -> Result<(), Self::Error>; + fn read_unit(&mut self) -> Result<(), Self::Error>; fn read_usize(&mut self) -> Result; fn read_u128(&mut self) -> Result; fn read_u64(&mut self) -> Result; @@ -543,7 +543,7 @@ impl Encodable for () { impl Decodable for () { fn decode(d: &mut D) -> Result<(), D::Error> { - d.read_nil() + d.read_unit() } } From 6f685ffad42a2d12dd1fad5ccb0471e7fa260826 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Mon, 10 Sep 2018 10:45:16 +0900 Subject: [PATCH 07/23] renamed is_nil to is_unit --- src/librustc/ty/sty.rs | 2 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_codegen_llvm/debuginfo/type_names.rs | 2 +- src/librustc_codegen_llvm/mir/rvalue.rs | 4 ++-- src/librustc_lint/types.rs | 4 ++-- src/librustc_mir/build/block.rs | 2 +- src/librustc_mir/monomorphize/item.rs | 2 +- src/librustc_typeck/check/_match.rs | 4 ++-- src/librustc_typeck/check/coercion.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 10 +++++----- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 962b115f1877a..ea547c592d048 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1458,7 +1458,7 @@ impl RegionKind { /// Type utilities impl<'a, 'gcx, 'tcx> TyS<'tcx> { - pub fn is_nil(&self) -> bool { + pub fn is_unit(&self) -> bool { match self.sty { Tuple(ref tys) => tys.is_empty(), _ => false, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index ddcc0fa9c9280..3d7117dd46a21 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -234,7 +234,7 @@ impl PrintContext { } } write!(f, ")")?; - if !output.is_nil() { + if !output.is_unit() { print!(f, self, write(" -> "), print_display(output))?; } diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index 95a094bf909e1..f9eb80a1988af 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -160,7 +160,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, output.push(')'); - if !sig.output().is_nil() { + if !sig.output().is_unit() { output.push_str(" -> "); push_debuginfo_type_name(cx, sig.output(), true, output); } diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs index e301e5ae70be8..c3ec347f60876 100644 --- a/src/librustc_codegen_llvm/mir/rvalue.rs +++ b/src/librustc_codegen_llvm/mir/rvalue.rs @@ -566,7 +566,7 @@ impl FunctionCx<'a, 'll, 'tcx> { ) -> &'ll Value { let is_float = input_ty.is_fp(); let is_signed = input_ty.is_signed(); - let is_nil = input_ty.is_nil(); + let is_unit = input_ty.is_unit(); match op { mir::BinOp::Add => if is_float { bx.fadd(lhs, rhs) @@ -604,7 +604,7 @@ impl FunctionCx<'a, 'll, 'tcx> { mir::BinOp::Shl => common::build_unchecked_lshift(bx, lhs, rhs), mir::BinOp::Shr => common::build_unchecked_rshift(bx, input_ty, lhs, rhs), mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt | - mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_nil { + mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_unit { C_bool(bx.cx, match op { mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt => false, mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => true, diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 33181bd80e937..2bec9203e9ee5 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -691,7 +691,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } let sig = cx.erase_late_bound_regions(&sig); - if !sig.output().is_nil() { + if !sig.output().is_unit() { let r = self.check_type_for_ffi(cache, sig.output()); match r { FfiSafe => {} @@ -767,7 +767,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { if let hir::Return(ref ret_hir) = decl.output { let ret_ty = sig.output(); - if !ret_ty.is_nil() { + if !ret_ty.is_unit() { self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty); } } diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index c3637a5abebdc..50d4944d7c242 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // the case of `!`, no return value is required, as the block will never return. let tcx = this.hir.tcx(); let ty = destination.ty(&this.local_decls, tcx).to_ty(tcx); - if ty.is_nil() { + if ty.is_unit() { // We only want to assign an implicit `()` as the return value of the block if the // block does not diverge. (Otherwise, we may try to assign a unit to a `!`-type.) this.cfg.push_assign_unit(block, source_info, destination); diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index dc437ee8510d7..3f5a05f9d0ed8 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -368,7 +368,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { output.push(')'); - if !sig.output().is_nil() { + if !sig.output().is_unit() { output.push_str(" -> "); self.push_type_name(sig.output(), output); } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 2a8ee4bd8df0e..a712bce2a4c4b 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -677,14 +677,14 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); // Handle the fallback arm of a desugared if-let like a missing else. let is_if_let_fallback = match match_src { hir::MatchSource::IfLetDesugar { contains_else_clause: false } => { - i == arms.len() - 1 && arm_ty.is_nil() + i == arms.len() - 1 && arm_ty.is_unit() } _ => false }; if is_if_let_fallback { let cause = self.cause(expr.span, ObligationCauseCode::IfExpressionWithNoElse); - assert!(arm_ty.is_nil()); + assert!(arm_ty.is_unit()); coercion.coerce_forced_unit(self, &cause, &mut |_| (), true); } else { let cause = self.cause(expr.span, ObligationCauseCode::MatchExpressionArm { diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 763adb007c3a4..4b09e91bdd75f 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1146,8 +1146,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> // `expression_ty` will be unit). // // Another example is `break` with no argument expression. - assert!(expression_ty.is_nil()); - assert!(expression_ty.is_nil(), "if let hack without unit type"); + assert!(expression_ty.is_unit()); + assert!(expression_ty.is_unit(), "if let hack without unit type"); fcx.at(cause, fcx.param_env) .eq_exp(label_expression_as_expected, expression_ty, self.merged_ty()) .map(|infer_ok| { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9ab269702db1c..9638b6ca6ab2d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2808,9 +2808,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else { // is the missing argument of type `()`? let sugg_unit = if expected_arg_tys.len() == 1 && supplied_arg_count == 0 { - self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_nil() + self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_unit() } else if fn_inputs.len() == 1 && supplied_arg_count == 0 { - self.resolve_type_vars_if_possible(&fn_inputs[0]).is_nil() + self.resolve_type_vars_if_possible(&fn_inputs[0]).is_unit() } else { false }; @@ -3958,7 +3958,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(ref e) = *expr_opt { coerce.coerce(self, &cause, e, e_ty); } else { - assert!(e_ty.is_nil()); + assert!(e_ty.is_unit()); coerce.coerce_forced_unit(self, &cause, &mut |_| (), true); } } else { @@ -4752,7 +4752,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expression: &'gcx hir::Expr, expected: Ty<'tcx>, cause_span: Span) { - if expected.is_nil() { + if expected.is_unit() { // `BlockTailExpression` only relevant if the tail expr would be // useful on its own. match expression.node { @@ -4795,7 +4795,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { can_suggest: bool) { // Only suggest changing the return type for methods that // haven't set a return type at all (and aren't `fn main()` or an impl). - match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_nil()) { + match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_unit()) { (&hir::FunctionRetTy::DefaultReturn(span), true, true, true) => { err.span_suggestion_with_applicability( span, From 5c3ba4aa4f0fdd5ca3897d81a324cd1b4c9415e2 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Mon, 10 Sep 2018 11:07:13 +0900 Subject: [PATCH 08/23] renamed mk_nil to mk_unit --- src/librustc/traits/error_reporting.rs | 2 +- src/librustc/ty/context.rs | 4 ++-- src/librustc/ty/layout.rs | 4 ++-- src/librustc_codegen_llvm/intrinsic.rs | 2 +- src/librustc_driver/test.rs | 2 +- src/librustc_mir/hair/cx/mod.rs | 2 +- src/librustc_mir/interpret/terminator.rs | 2 +- src/librustc_mir/transform/generator.rs | 4 ++-- src/librustc_mir/util/elaborate_drops.rs | 4 ++-- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/coercion.rs | 2 +- src/librustc_typeck/check/intrinsic.rs | 28 ++++++++++++------------ src/librustc_typeck/check/mod.rs | 16 +++++++------- src/librustc_typeck/check/op.rs | 2 +- src/librustc_typeck/lib.rs | 2 +- 16 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index a7c697c1cbafd..466d472cca338 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -661,7 +661,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { { let predicate = trait_predicate.map_bound(|mut trait_pred| { trait_pred.trait_ref.substs = self.tcx.mk_substs_trait( - self.tcx.mk_nil(), + self.tcx.mk_unit(), &trait_pred.trait_ref.substs[1..], ); trait_pred diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index eb6f7140a7db7..ddaa0444cc7f6 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2492,7 +2492,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } pub fn mk_nil_ptr(self) -> Ty<'tcx> { - self.mk_imm_ptr(self.mk_nil()) + self.mk_imm_ptr(self.mk_unit()) } pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> { @@ -2511,7 +2511,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(ts)))) } - pub fn mk_nil(self) -> Ty<'tcx> { + pub fn mk_unit(self) -> Ty<'tcx> { self.intern_tup(&[]) } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 17d613a2b181a..a3316c2b8e2e4 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -132,7 +132,7 @@ impl PrimitiveExt for Primitive { Int(i, signed) => i.to_ty(tcx, signed), Float(FloatTy::F32) => tcx.types.f32, Float(FloatTy::F64) => tcx.types.f64, - Pointer => tcx.mk_mut_ptr(tcx.mk_nil()), + Pointer => tcx.mk_mut_ptr(tcx.mk_unit()), } } } @@ -1606,7 +1606,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> // (which may have no non-DST form), and will work as long // as the `Abi` or `FieldPlacement` is checked by users. if i == 0 { - let nil = tcx.mk_nil(); + let nil = tcx.mk_unit(); let ptr_ty = if this.ty.is_unsafe_ptr() { tcx.mk_mut_ptr(nil) } else { diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 5d00e0807991e..5ec934ebd0667 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -968,7 +968,7 @@ fn get_rust_try_fn<'ll, 'tcx>( let i8p = tcx.mk_mut_ptr(tcx.types.i8); let fn_ty = tcx.mk_fn_ptr(ty::Binder::bind(tcx.mk_fn_sig( iter::once(i8p), - tcx.mk_nil(), + tcx.mk_unit(), false, hir::Unsafety::Unsafe, Abi::Rust diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 57c00f252ef16..ff35371976aa4 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -309,7 +309,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { } pub fn t_nil(&self) -> Ty<'tcx> { - self.infcx.tcx.mk_nil() + self.infcx.tcx.mk_unit() } pub fn t_pair(&self, ty1: Ty<'tcx>, ty2: Ty<'tcx>) -> Ty<'tcx> { diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index b4257a40e38af..4d4a89fca8b83 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -118,7 +118,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { } pub fn unit_ty(&mut self) -> Ty<'tcx> { - self.tcx.mk_nil() + self.tcx.mk_unit() } pub fn true_literal(&mut self) -> &'tcx ty::Const<'tcx> { diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index de86810627409..7ce96b1f62626 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -436,7 +436,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { layout: self.layout_of(self.tcx.mk_mut_ptr(place.layout.ty))?, }; - let ty = self.tcx.mk_nil(); // return type is () + let ty = self.tcx.mk_unit(); // return type is () let dest = PlaceTy::null(&self, self.layout_of(ty)?); self.eval_fn_call( diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index dcbf92b57b13a..1ad713b4b7de6 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -517,7 +517,7 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let upvar_len = mir.upvar_decls.len(); - let dummy_local = LocalDecl::new_internal(tcx.mk_nil(), mir.span); + let dummy_local = LocalDecl::new_internal(tcx.mk_unit(), mir.span); // Gather live locals and their indices replacing values in mir.local_decls with a dummy // to avoid changing local indices @@ -655,7 +655,7 @@ fn create_generator_drop_shim<'a, 'tcx>( // Replace the return variable mir.local_decls[RETURN_PLACE] = LocalDecl { mutability: Mutability::Mut, - ty: tcx.mk_nil(), + ty: tcx.mk_unit(), name: None, source_info, visibility_scope: source_info.scope, diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 1c0c98d621c83..50bdc14d50995 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -529,7 +529,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> mutbl: hir::Mutability::MutMutable }); let ref_place = self.new_temp(ref_ty); - let unit_temp = Place::Local(self.new_temp(tcx.mk_nil())); + let unit_temp = Place::Local(self.new_temp(tcx.mk_unit())); let result = BasicBlockData { statements: vec![self.assign( @@ -891,7 +891,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> unwind: Unwind ) -> BasicBlock { let tcx = self.tcx(); - let unit_temp = Place::Local(self.new_temp(tcx.mk_nil())); + let unit_temp = Place::Local(self.new_temp(tcx.mk_unit())); let free_func = tcx.require_lang_item(lang_items::BoxFreeFnLangItem); let args = adt.variants[0].fields.iter().enumerate().map(|(i, f)| { let field = Field::new(i); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index eaf1d03de7d0f..72502cda6e02d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1575,7 +1575,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { let output_ty = match decl.output { hir::Return(ref output) => self.ast_ty_to_ty(output), - hir::DefaultReturn(..) => tcx.mk_nil(), + hir::DefaultReturn(..) => tcx.mk_unit(), }; debug!("ty_of_fn: output_ty={:?}", output_ty); diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index a712bce2a4c4b..9913b8de7a742 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -656,7 +656,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); // us to give better error messages (pointing to a usually better // arm for inconsistent arms or to the whole match when a `()` type // is required). - Expectation::ExpectHasType(ety) if ety != self.tcx.mk_nil() => ety, + Expectation::ExpectHasType(ety) if ety != self.tcx.mk_unit() => ety, _ => self.next_ty_var(TypeVariableOrigin::MiscVariable(expr.span)), }; CoerceMany::with_coercion_sites(coerce_first, arms) diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 4b09e91bdd75f..9604eb3420fb3 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1077,7 +1077,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> self.coerce_inner(fcx, cause, None, - fcx.tcx.mk_nil(), + fcx.tcx.mk_unit(), Some(augment_error), label_unit_as_expected) } diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index c7db3debf5a0d..8215ae211c0b9 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -94,7 +94,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, "load" => (1, vec![tcx.mk_imm_ptr(param(0))], param(0)), "store" => (1, vec![tcx.mk_mut_ptr(param(0)), param(0)], - tcx.mk_nil()), + tcx.mk_unit()), "xchg" | "xadd" | "xsub" | "and" | "nand" | "or" | "xor" | "max" | "min" | "umax" | "umin" => { @@ -102,7 +102,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, param(0)) } "fence" | "singlethreadfence" => { - (0, Vec::new(), tcx.mk_nil()) + (0, Vec::new(), tcx.mk_unit()) } op => { struct_span_err!(tcx.sess, it.span, E0092, @@ -121,7 +121,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, _ => hir::Unsafety::Unsafe, }; let (n_tps, inputs, output) = match &name[..] { - "breakpoint" => (0, Vec::new(), tcx.mk_nil()), + "breakpoint" => (0, Vec::new(), tcx.mk_unit()), "size_of" | "pref_align_of" | "min_align_of" => (1, Vec::new(), tcx.types.usize), "size_of_val" | "min_align_of_val" => { @@ -141,7 +141,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.mk_mut_ptr(param(0)), param(0) ], - tcx.mk_nil()) + tcx.mk_unit()) } "prefetch_read_data" | "prefetch_write_data" | "prefetch_read_instruction" | "prefetch_write_instruction" => { @@ -149,10 +149,10 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: param(0), mutbl: hir::MutImmutable }), tcx.types.i32], - tcx.mk_nil()) + tcx.mk_unit()) } "drop_in_place" => { - (1, vec![tcx.mk_mut_ptr(param(0))], tcx.mk_nil()) + (1, vec![tcx.mk_mut_ptr(param(0))], tcx.mk_unit()) } "needs_drop" => (1, Vec::new(), tcx.types.bool), @@ -185,7 +185,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }), tcx.types.usize, ], - tcx.mk_nil()) + tcx.mk_unit()) } "volatile_copy_memory" | "volatile_copy_nonoverlapping_memory" => { (1, @@ -200,7 +200,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }), tcx.types.usize, ], - tcx.mk_nil()) + tcx.mk_unit()) } "write_bytes" | "volatile_set_memory" => { (1, @@ -212,7 +212,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx.types.u8, tcx.types.usize, ], - tcx.mk_nil()) + tcx.mk_unit()) } "sqrtf32" => (0, vec![ tcx.types.f32 ], tcx.types.f32), "sqrtf64" => (0, vec![ tcx.types.f64 ], tcx.types.f64), @@ -280,7 +280,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, "volatile_load" | "unaligned_volatile_load" => (1, vec![ tcx.mk_imm_ptr(param(0)) ], param(0)), "volatile_store" | "unaligned_volatile_store" => - (1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_nil()), + (1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_unit()), "ctpop" | "ctlz" | "ctlz_nonzero" | "cttz" | "cttz_nonzero" | "bswap" | "bitreverse" => @@ -300,7 +300,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, "fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => (1, vec![param(0), param(0)], param(0)), - "assume" => (0, vec![tcx.types.bool], tcx.mk_nil()), + "assume" => (0, vec![tcx.types.bool], tcx.mk_unit()), "likely" => (0, vec![tcx.types.bool], tcx.types.bool), "unlikely" => (0, vec![tcx.types.bool], tcx.types.bool), @@ -313,7 +313,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut_u8 = tcx.mk_mut_ptr(tcx.types.u8); let fn_ty = ty::Binder::bind(tcx.mk_fn_sig( iter::once(mut_u8), - tcx.mk_nil(), + tcx.mk_unit(), false, hir::Unsafety::Normal, Abi::Rust, @@ -322,7 +322,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } "nontemporal_store" => { - (1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_nil()) + (1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_unit()) } ref other => { @@ -376,7 +376,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, (3, vec![param(0), param(1), param(2)], param(0)) } "simd_scatter" => { - (3, vec![param(0), param(1), param(2)], tcx.mk_nil()) + (3, vec![param(0), param(1), param(2)], tcx.mk_unit()) } "simd_insert" => (2, vec![param(0), tcx.types.u32, param(1)], param(0)), "simd_extract" => (2, vec![param(0), tcx.types.u32], param(1)), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9638b6ca6ab2d..3d66beaf2ecab 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3918,7 +3918,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { for input in inputs { self.check_expr(input); } - tcx.mk_nil() + tcx.mk_unit() } hir::ExprKind::Break(destination, ref expr_opt) => { if let Ok(target_id) = destination.target_id { @@ -3945,7 +3945,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else { // Otherwise, this is a break *without* a value. That's // always legal, and is equivalent to `break ()`. - e_ty = tcx.mk_nil(); + e_ty = tcx.mk_unit(); cause = self.misc(expr.span); } @@ -4052,7 +4052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if lhs_ty.references_error() || rhs_ty.references_error() { tcx.types.err } else { - tcx.mk_nil() + tcx.mk_unit() } } hir::ExprKind::If(ref cond, ref then_expr, ref opt_else_expr) => { @@ -4081,7 +4081,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.diverges.set(Diverges::Maybe); } - self.tcx.mk_nil() + self.tcx.mk_unit() } hir::ExprKind::Loop(ref body, _, source) => { let coerce = match source { @@ -4121,7 +4121,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // [1] self.tcx.sess.delay_span_bug(body.span, "no coercion, but loop may not break"); } - ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_nil()) + ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_unit()) } hir::ExprKind::Match(ref discrim, ref arms, match_src) => { self.check_match(expr, &discrim, arms, expected, match_src) @@ -4352,7 +4352,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "yield statement outside of generator literal").emit(); } } - tcx.mk_nil() + tcx.mk_unit() } } } @@ -4516,7 +4516,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } hir::StmtKind::Expr(ref expr, _) => { // Check with expected type of () - self.check_expr_has_type_or_error(&expr, self.tcx.mk_nil()); + self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit()); } hir::StmtKind::Semi(ref expr, _) => { self.check_expr(&expr); @@ -4529,7 +4529,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } pub fn check_block_no_value(&self, blk: &'gcx hir::Block) { - let unit = self.tcx.mk_nil(); + let unit = self.tcx.mk_unit(); let ty = self.check_block_with_expected(blk, ExpectHasType(unit)); // if the block produces a `!` value, that can always be diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index edfa62f109538..5004880ce47b8 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -35,7 +35,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let ty = if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var() && is_builtin_binop(lhs_ty, rhs_ty, op) { self.enforce_builtin_binop_types(lhs_expr, lhs_ty, rhs_expr, rhs_ty, op); - self.tcx.mk_nil() + self.tcx.mk_unit() } else { return_ty }; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index f465ff4d62163..13ea2fdd89d05 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -225,7 +225,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, actual.output().skip_binder() } else { // standard () main return type - tcx.mk_nil() + tcx.mk_unit() }; let se_ty = tcx.mk_fn_ptr(ty::Binder::bind( From 2be5c722dedf50a95479bad0b4558e5e76a73a00 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Mon, 10 Sep 2018 11:09:54 +0900 Subject: [PATCH 09/23] renamed mk_nil_ptr to mk_unit_ptr --- src/librustc/ty/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ddaa0444cc7f6..d0a569f5256bc 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2491,7 +2491,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.mk_ptr(TypeAndMut {ty: ty, mutbl: hir::MutImmutable}) } - pub fn mk_nil_ptr(self) -> Ty<'tcx> { + pub fn mk_unit_ptr(self) -> Ty<'tcx> { self.mk_imm_ptr(self.mk_unit()) } From 69deed9dc17cfd1c3e02d9e662ebc164885321a6 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Mon, 10 Sep 2018 11:21:30 +0900 Subject: [PATCH 10/23] renamed t_nil to t_unit --- src/librustc_driver/test.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index ff35371976aa4..086d2a15c8cf2 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { ))) } - pub fn t_nil(&self) -> Ty<'tcx> { + pub fn t_unit(&self) -> Ty<'tcx> { self.infcx.tcx.mk_unit() } @@ -491,7 +491,7 @@ fn subst_ty_renumber_bound() { // t_source = fn(A) let t_source = { let t_param = env.t_param(0); - env.t_fn(&[t_param], env.t_nil()) + env.t_fn(&[t_param], env.t_unit()) }; let substs = env.infcx.tcx.intern_substs(&[t_rptr_bound1.into()]); @@ -500,7 +500,7 @@ fn subst_ty_renumber_bound() { // t_expected = fn(&'a isize) let t_expected = { let t_ptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); - env.t_fn(&[t_ptr_bound2], env.t_nil()) + env.t_fn(&[t_ptr_bound2], env.t_unit()) }; debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", @@ -526,7 +526,7 @@ fn subst_ty_renumber_some_bounds() { // t_source = (A, fn(A)) let t_source = { let t_param = env.t_param(0); - env.t_pair(t_param, env.t_fn(&[t_param], env.t_nil())) + env.t_pair(t_param, env.t_fn(&[t_param], env.t_unit())) }; let substs = env.infcx.tcx.intern_substs(&[t_rptr_bound1.into()]); @@ -537,7 +537,7 @@ fn subst_ty_renumber_some_bounds() { // but not that the Debruijn index is different in the different cases. let t_expected = { let t_rptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); - env.t_pair(t_rptr_bound1, env.t_fn(&[t_rptr_bound2], env.t_nil())) + env.t_pair(t_rptr_bound1, env.t_fn(&[t_rptr_bound2], env.t_unit())) }; debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", @@ -559,7 +559,7 @@ fn escaping() { // Theta = [A -> &'a foo] env.create_simple_region_hierarchy(); - assert!(!env.t_nil().has_escaping_regions()); + assert!(!env.t_unit().has_escaping_regions()); let t_rptr_free1 = env.t_rptr_free(1); assert!(!t_rptr_free1.has_escaping_regions()); @@ -573,7 +573,7 @@ fn escaping() { // t_fn = fn(A) let t_param = env.t_param(0); assert!(!t_param.has_escaping_regions()); - let t_fn = env.t_fn(&[t_param], env.t_nil()); + let t_fn = env.t_fn(&[t_param], env.t_unit()); assert!(!t_fn.has_escaping_regions()); }) } @@ -588,7 +588,7 @@ fn subst_region_renumber_region() { // type t_source<'a> = fn(&'a isize) let t_source = { let re_early = env.re_early_bound(0, "'a"); - env.t_fn(&[env.t_rptr(re_early)], env.t_nil()) + env.t_fn(&[env.t_rptr(re_early)], env.t_unit()) }; let substs = env.infcx.tcx.intern_substs(&[re_bound1.into()]); @@ -599,7 +599,7 @@ fn subst_region_renumber_region() { // but not that the Debruijn index is different in the different cases. let t_expected = { let t_rptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); - env.t_fn(&[t_rptr_bound2], env.t_nil()) + env.t_fn(&[t_rptr_bound2], env.t_unit()) }; debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", From 8c53150b1878647ecabbb70c8432c8d1a0ad7703 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Tue, 11 Sep 2018 22:16:04 +0900 Subject: [PATCH 11/23] Revert "renamed t_nil to t_unit" This reverts commit 69deed9dc17cfd1c3e02d9e662ebc164885321a6. --- src/librustc_driver/test.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 086d2a15c8cf2..ff35371976aa4 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -308,7 +308,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> { ))) } - pub fn t_unit(&self) -> Ty<'tcx> { + pub fn t_nil(&self) -> Ty<'tcx> { self.infcx.tcx.mk_unit() } @@ -491,7 +491,7 @@ fn subst_ty_renumber_bound() { // t_source = fn(A) let t_source = { let t_param = env.t_param(0); - env.t_fn(&[t_param], env.t_unit()) + env.t_fn(&[t_param], env.t_nil()) }; let substs = env.infcx.tcx.intern_substs(&[t_rptr_bound1.into()]); @@ -500,7 +500,7 @@ fn subst_ty_renumber_bound() { // t_expected = fn(&'a isize) let t_expected = { let t_ptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); - env.t_fn(&[t_ptr_bound2], env.t_unit()) + env.t_fn(&[t_ptr_bound2], env.t_nil()) }; debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", @@ -526,7 +526,7 @@ fn subst_ty_renumber_some_bounds() { // t_source = (A, fn(A)) let t_source = { let t_param = env.t_param(0); - env.t_pair(t_param, env.t_fn(&[t_param], env.t_unit())) + env.t_pair(t_param, env.t_fn(&[t_param], env.t_nil())) }; let substs = env.infcx.tcx.intern_substs(&[t_rptr_bound1.into()]); @@ -537,7 +537,7 @@ fn subst_ty_renumber_some_bounds() { // but not that the Debruijn index is different in the different cases. let t_expected = { let t_rptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); - env.t_pair(t_rptr_bound1, env.t_fn(&[t_rptr_bound2], env.t_unit())) + env.t_pair(t_rptr_bound1, env.t_fn(&[t_rptr_bound2], env.t_nil())) }; debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", @@ -559,7 +559,7 @@ fn escaping() { // Theta = [A -> &'a foo] env.create_simple_region_hierarchy(); - assert!(!env.t_unit().has_escaping_regions()); + assert!(!env.t_nil().has_escaping_regions()); let t_rptr_free1 = env.t_rptr_free(1); assert!(!t_rptr_free1.has_escaping_regions()); @@ -573,7 +573,7 @@ fn escaping() { // t_fn = fn(A) let t_param = env.t_param(0); assert!(!t_param.has_escaping_regions()); - let t_fn = env.t_fn(&[t_param], env.t_unit()); + let t_fn = env.t_fn(&[t_param], env.t_nil()); assert!(!t_fn.has_escaping_regions()); }) } @@ -588,7 +588,7 @@ fn subst_region_renumber_region() { // type t_source<'a> = fn(&'a isize) let t_source = { let re_early = env.re_early_bound(0, "'a"); - env.t_fn(&[env.t_rptr(re_early)], env.t_unit()) + env.t_fn(&[env.t_rptr(re_early)], env.t_nil()) }; let substs = env.infcx.tcx.intern_substs(&[re_bound1.into()]); @@ -599,7 +599,7 @@ fn subst_region_renumber_region() { // but not that the Debruijn index is different in the different cases. let t_expected = { let t_rptr_bound2 = env.t_rptr_late_bound_with_debruijn(1, d2()); - env.t_fn(&[t_rptr_bound2], env.t_unit()) + env.t_fn(&[t_rptr_bound2], env.t_nil()) }; debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", From d7ebc20e7783133310a65a1555465292fd5cd84e Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Tue, 11 Sep 2018 22:17:43 +0900 Subject: [PATCH 12/23] Revert "renamed mk_nil_ptr to mk_unit_ptr" This reverts commit 2be5c722dedf50a95479bad0b4558e5e76a73a00. --- src/librustc/ty/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index d0a569f5256bc..ddaa0444cc7f6 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2491,7 +2491,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.mk_ptr(TypeAndMut {ty: ty, mutbl: hir::MutImmutable}) } - pub fn mk_unit_ptr(self) -> Ty<'tcx> { + pub fn mk_nil_ptr(self) -> Ty<'tcx> { self.mk_imm_ptr(self.mk_unit()) } From 10b2083a6d3de2dad2a41639bfe5a90c4d87bf31 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Tue, 11 Sep 2018 22:18:49 +0900 Subject: [PATCH 13/23] Revert "renamed is_nil to is_unit" This reverts commit 6f685ffad42a2d12dd1fad5ccb0471e7fa260826. --- src/librustc/ty/sty.rs | 2 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_codegen_llvm/debuginfo/type_names.rs | 2 +- src/librustc_codegen_llvm/mir/rvalue.rs | 4 ++-- src/librustc_lint/types.rs | 4 ++-- src/librustc_mir/build/block.rs | 2 +- src/librustc_mir/monomorphize/item.rs | 2 +- src/librustc_typeck/check/_match.rs | 4 ++-- src/librustc_typeck/check/coercion.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 10 +++++----- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index ea547c592d048..962b115f1877a 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1458,7 +1458,7 @@ impl RegionKind { /// Type utilities impl<'a, 'gcx, 'tcx> TyS<'tcx> { - pub fn is_unit(&self) -> bool { + pub fn is_nil(&self) -> bool { match self.sty { Tuple(ref tys) => tys.is_empty(), _ => false, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 3d7117dd46a21..ddcc0fa9c9280 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -234,7 +234,7 @@ impl PrintContext { } } write!(f, ")")?; - if !output.is_unit() { + if !output.is_nil() { print!(f, self, write(" -> "), print_display(output))?; } diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index f9eb80a1988af..95a094bf909e1 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -160,7 +160,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, output.push(')'); - if !sig.output().is_unit() { + if !sig.output().is_nil() { output.push_str(" -> "); push_debuginfo_type_name(cx, sig.output(), true, output); } diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs index c3ec347f60876..e301e5ae70be8 100644 --- a/src/librustc_codegen_llvm/mir/rvalue.rs +++ b/src/librustc_codegen_llvm/mir/rvalue.rs @@ -566,7 +566,7 @@ impl FunctionCx<'a, 'll, 'tcx> { ) -> &'ll Value { let is_float = input_ty.is_fp(); let is_signed = input_ty.is_signed(); - let is_unit = input_ty.is_unit(); + let is_nil = input_ty.is_nil(); match op { mir::BinOp::Add => if is_float { bx.fadd(lhs, rhs) @@ -604,7 +604,7 @@ impl FunctionCx<'a, 'll, 'tcx> { mir::BinOp::Shl => common::build_unchecked_lshift(bx, lhs, rhs), mir::BinOp::Shr => common::build_unchecked_rshift(bx, input_ty, lhs, rhs), mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt | - mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_unit { + mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_nil { C_bool(bx.cx, match op { mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt => false, mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => true, diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 2bec9203e9ee5..33181bd80e937 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -691,7 +691,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } let sig = cx.erase_late_bound_regions(&sig); - if !sig.output().is_unit() { + if !sig.output().is_nil() { let r = self.check_type_for_ffi(cache, sig.output()); match r { FfiSafe => {} @@ -767,7 +767,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { if let hir::Return(ref ret_hir) = decl.output { let ret_ty = sig.output(); - if !ret_ty.is_unit() { + if !ret_ty.is_nil() { self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty); } } diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index 50d4944d7c242..c3637a5abebdc 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // the case of `!`, no return value is required, as the block will never return. let tcx = this.hir.tcx(); let ty = destination.ty(&this.local_decls, tcx).to_ty(tcx); - if ty.is_unit() { + if ty.is_nil() { // We only want to assign an implicit `()` as the return value of the block if the // block does not diverge. (Otherwise, we may try to assign a unit to a `!`-type.) this.cfg.push_assign_unit(block, source_info, destination); diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 3f5a05f9d0ed8..dc437ee8510d7 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -368,7 +368,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { output.push(')'); - if !sig.output().is_unit() { + if !sig.output().is_nil() { output.push_str(" -> "); self.push_type_name(sig.output(), output); } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 9913b8de7a742..60da6e1d72a88 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -677,14 +677,14 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); // Handle the fallback arm of a desugared if-let like a missing else. let is_if_let_fallback = match match_src { hir::MatchSource::IfLetDesugar { contains_else_clause: false } => { - i == arms.len() - 1 && arm_ty.is_unit() + i == arms.len() - 1 && arm_ty.is_nil() } _ => false }; if is_if_let_fallback { let cause = self.cause(expr.span, ObligationCauseCode::IfExpressionWithNoElse); - assert!(arm_ty.is_unit()); + assert!(arm_ty.is_nil()); coercion.coerce_forced_unit(self, &cause, &mut |_| (), true); } else { let cause = self.cause(expr.span, ObligationCauseCode::MatchExpressionArm { diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 9604eb3420fb3..47c3cf4dfa001 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1146,8 +1146,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> // `expression_ty` will be unit). // // Another example is `break` with no argument expression. - assert!(expression_ty.is_unit()); - assert!(expression_ty.is_unit(), "if let hack without unit type"); + assert!(expression_ty.is_nil()); + assert!(expression_ty.is_nil(), "if let hack without unit type"); fcx.at(cause, fcx.param_env) .eq_exp(label_expression_as_expected, expression_ty, self.merged_ty()) .map(|infer_ok| { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 3d66beaf2ecab..f884a3513d121 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2808,9 +2808,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else { // is the missing argument of type `()`? let sugg_unit = if expected_arg_tys.len() == 1 && supplied_arg_count == 0 { - self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_unit() + self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_nil() } else if fn_inputs.len() == 1 && supplied_arg_count == 0 { - self.resolve_type_vars_if_possible(&fn_inputs[0]).is_unit() + self.resolve_type_vars_if_possible(&fn_inputs[0]).is_nil() } else { false }; @@ -3958,7 +3958,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(ref e) = *expr_opt { coerce.coerce(self, &cause, e, e_ty); } else { - assert!(e_ty.is_unit()); + assert!(e_ty.is_nil()); coerce.coerce_forced_unit(self, &cause, &mut |_| (), true); } } else { @@ -4752,7 +4752,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expression: &'gcx hir::Expr, expected: Ty<'tcx>, cause_span: Span) { - if expected.is_unit() { + if expected.is_nil() { // `BlockTailExpression` only relevant if the tail expr would be // useful on its own. match expression.node { @@ -4795,7 +4795,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { can_suggest: bool) { // Only suggest changing the return type for methods that // haven't set a return type at all (and aren't `fn main()` or an impl). - match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_unit()) { + match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_nil()) { (&hir::FunctionRetTy::DefaultReturn(span), true, true, true) => { err.span_suggestion_with_applicability( span, From fa683ac6563a844327de5e23d2a17bcfb5c328cd Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Tue, 11 Sep 2018 22:20:09 +0900 Subject: [PATCH 14/23] Revert "renamed read_nil to read_unit" This reverts commit 37d0600c23ba1890346078bd7f310e15915417b2. --- src/librustc/ty/codec.rs | 2 +- src/libserialize/json.rs | 2 +- src/libserialize/opaque.rs | 2 +- src/libserialize/serialize.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 051cca49f7e25..cc3e8a458a01f 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -298,7 +298,7 @@ macro_rules! implement_ty_decoder { type Error = String; __impl_decoder_methods! { - read_unit -> (); + read_nil -> (); read_u128 -> u128; read_u64 -> u64; diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index bbb3b73f2fa1d..9439dc78d3ca4 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -2128,7 +2128,7 @@ macro_rules! read_primitive { impl ::Decoder for Decoder { type Error = DecoderError; - fn read_unit(&mut self) -> DecodeResult<()> { + fn read_nil(&mut self) -> DecodeResult<()> { expect!(self.pop(), Null) } diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index fee5e59cc4013..4ce80bc36a080 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -228,7 +228,7 @@ impl<'a> serialize::Decoder for Decoder<'a> { type Error = String; #[inline] - fn read_unit(&mut self) -> Result<(), Self::Error> { + fn read_nil(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 64d6dbecea651..f0b49c3d9bc8f 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -167,7 +167,7 @@ pub trait Decoder { type Error; // Primitive types: - fn read_unit(&mut self) -> Result<(), Self::Error>; + fn read_nil(&mut self) -> Result<(), Self::Error>; fn read_usize(&mut self) -> Result; fn read_u128(&mut self) -> Result; fn read_u64(&mut self) -> Result; @@ -543,7 +543,7 @@ impl Encodable for () { impl Decodable for () { fn decode(d: &mut D) -> Result<(), D::Error> { - d.read_unit() + d.read_nil() } } From 7f8160409f5bb4490720df21e2c4fbf1a647bae2 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Tue, 11 Sep 2018 22:20:22 +0900 Subject: [PATCH 15/23] Revert "renamed emit_nil to emit_unit" This reverts commit d02a5ffaed9c395ae62ee12d0f4e04946c62edb1. --- src/doc/book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/libcompiler_builtins | 2 +- src/liblibc | 2 +- src/librustc/ty/query/on_disk_cache.rs | 2 +- src/librustc_metadata/encoder.rs | 2 +- src/libserialize/json.rs | 10 +++++----- src/libserialize/opaque.rs | 2 +- src/libserialize/serialize.rs | 4 ++-- src/llvm | 2 +- src/stdsimd | 2 +- src/tools/cargo | 2 +- src/tools/clippy | 2 +- src/tools/miri | 2 +- src/tools/rls | 2 +- src/tools/rust-installer | 2 +- src/tools/rustfmt | 2 +- 19 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/doc/book b/src/doc/book index f51127530d46b..cff0930664b68 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit f51127530d46b9acbf4747c859da185e771cfcf3 +Subproject commit cff0930664b688f1dd22aefb3d16944eb4cdbfd5 diff --git a/src/doc/nomicon b/src/doc/nomicon index 748a5e6742db4..7fd493465b7dd 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit 748a5e6742db4a21c4c630a58087f818828e8a0a +Subproject commit 7fd493465b7dd6cf3476f0b834884059bbdd1d93 diff --git a/src/doc/reference b/src/doc/reference index 134f419ee6271..821355a6fd642 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 134f419ee62714590b04712fe6072253bc2a7822 +Subproject commit 821355a6fd642b71988a2f88a3162fb358732012 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index eebda16e4b45f..e459fb3f07f2b 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit eebda16e4b45f2eed4310cf7b9872cc752278163 +Subproject commit e459fb3f07f2b930ccd25d348671b8eae233fd64 diff --git a/src/libcompiler_builtins b/src/libcompiler_builtins index 2a2f6d96c8dc5..0703bfa72524e 160000 --- a/src/libcompiler_builtins +++ b/src/libcompiler_builtins @@ -1 +1 @@ -Subproject commit 2a2f6d96c8dc578d2474742f14c9bab0b36b0408 +Subproject commit 0703bfa72524e01e414477657ca9b64794c5c1c3 diff --git a/src/liblibc b/src/liblibc index a7e78a78e17c8..1844a772b6077 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit a7e78a78e17c8776d7780008ccb3ce541ec64ae9 +Subproject commit 1844a772b60771d0124a157019f627d60fea4e73 diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 19e235154cbd0..6e16d92ba0c8d 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -1020,7 +1020,7 @@ impl<'enc, 'a, 'tcx, E> Encoder for CacheEncoder<'enc, 'a, 'tcx, E> { type Error = E::Error; - fn emit_unit(&mut self) -> Result<(), Self::Error> { + fn emit_nil(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 56b38cfbc872a..aae45c17c6771 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -75,7 +75,7 @@ macro_rules! encoder_methods { impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx> { type Error = ::Error; - fn emit_unit(&mut self) -> Result<(), Self::Error> { + fn emit_nil(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 9439dc78d3ca4..35ef6327de5fd 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -490,7 +490,7 @@ macro_rules! emit_enquoted_if_mapkey { impl<'a> ::Encoder for Encoder<'a> { type Error = EncoderError; - fn emit_unit(&mut self) -> EncodeResult { + fn emit_nil(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } write!(self.writer, "null")?; Ok(()) @@ -648,7 +648,7 @@ impl<'a> ::Encoder for Encoder<'a> { } fn emit_option_none(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_unit() + self.emit_nil() } fn emit_option_some(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, @@ -740,7 +740,7 @@ impl<'a> PrettyEncoder<'a> { impl<'a> ::Encoder for PrettyEncoder<'a> { type Error = EncoderError; - fn emit_unit(&mut self) -> EncodeResult { + fn emit_nil(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } write!(self.writer, "null")?; Ok(()) @@ -923,7 +923,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { } fn emit_option_none(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_unit() + self.emit_nil() } fn emit_option_some(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, @@ -1016,7 +1016,7 @@ impl Encodable for Json { Json::Boolean(v) => v.encode(e), Json::Array(ref v) => v.encode(e), Json::Object(ref v) => v.encode(e), - Json::Null => e.emit_unit(), + Json::Null => e.emit_nil(), } } } diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index 4ce80bc36a080..c71f474891131 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -55,7 +55,7 @@ impl serialize::Encoder for Encoder { type Error = !; #[inline] - fn emit_unit(&mut self) -> EncodeResult { + fn emit_nil(&mut self) -> EncodeResult { Ok(()) } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index f0b49c3d9bc8f..416be50bfe9ea 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -25,7 +25,7 @@ pub trait Encoder { type Error; // Primitive types: - fn emit_unit(&mut self) -> Result<(), Self::Error>; + fn emit_nil(&mut self) -> Result<(), Self::Error>; fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>; fn emit_u128(&mut self, v: u128) -> Result<(), Self::Error>; fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>; @@ -537,7 +537,7 @@ impl Decodable for char { impl Encodable for () { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_unit() + s.emit_nil() } } diff --git a/src/llvm b/src/llvm index 7243155b1c3da..2a1cdeadd3ea8 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 7243155b1c3da0a980c868a87adebf00e0b33989 +Subproject commit 2a1cdeadd3ea8e1eba9cc681037b83f07332763b diff --git a/src/stdsimd b/src/stdsimd index 1ea18a5cb431e..05c2f61c384e2 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 1ea18a5cb431e24aa838b652ac305acc5e394d6b +Subproject commit 05c2f61c384e2097a3a4c648344114fc4ac983be diff --git a/src/tools/cargo b/src/tools/cargo index af3f1cd29bc87..2fb77a49b43bf 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit af3f1cd29bc872b932a13083e531255aab233a7e +Subproject commit 2fb77a49b43bf7266793c07a19a06749e6a8ad5a diff --git a/src/tools/clippy b/src/tools/clippy index e456241f18227..fdd830f52c082 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit e456241f18227c7eb8d78a45daa66c756a9b65e7 +Subproject commit fdd830f52c082b83db0dac3e0066c0cf114050d2 diff --git a/src/tools/miri b/src/tools/miri index e0e1bd7ff778e..e6f1e15676c26 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit e0e1bd7ff778e5913b566c9e03224faecc0eb486 +Subproject commit e6f1e15676c26fdc7c4713647fe007b26f361a8e diff --git a/src/tools/rls b/src/tools/rls index 1263f1ff25bb3..5b5cd9d457194 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 1263f1ff25bb329b76f74715ad4a7ec0d1f71430 +Subproject commit 5b5cd9d45719414196e254ec17baa598acc8cd25 diff --git a/src/tools/rust-installer b/src/tools/rust-installer index 118e078c5badd..27dec6cae3a81 160000 --- a/src/tools/rust-installer +++ b/src/tools/rust-installer @@ -1 +1 @@ -Subproject commit 118e078c5badd520d18b92813fd88789c8d341ab +Subproject commit 27dec6cae3a8132d8a073aad6775425c85095c99 diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 0f8029f251b56..1c408818c8a75 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 0f8029f251b569a010cb5cfc5a8bff8bf3c949ac +Subproject commit 1c408818c8a752dd584e7858b4afd3ceb011a7da From a0e7b6bf6b96e54051aeeede43378b925e2e5201 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Tue, 11 Sep 2018 23:17:35 +0900 Subject: [PATCH 16/23] renamed is_nil to is_unit --- src/librustc/ty/sty.rs | 2 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_codegen_llvm/debuginfo/type_names.rs | 2 +- src/librustc_codegen_llvm/mir/rvalue.rs | 4 ++-- src/librustc_lint/types.rs | 4 ++-- src/librustc_mir/build/block.rs | 2 +- src/librustc_mir/monomorphize/item.rs | 2 +- src/librustc_typeck/check/_match.rs | 4 ++-- src/librustc_typeck/check/coercion.rs | 4 ++-- src/librustc_typeck/check/mod.rs | 10 +++++----- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 962b115f1877a..ea547c592d048 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1458,7 +1458,7 @@ impl RegionKind { /// Type utilities impl<'a, 'gcx, 'tcx> TyS<'tcx> { - pub fn is_nil(&self) -> bool { + pub fn is_unit(&self) -> bool { match self.sty { Tuple(ref tys) => tys.is_empty(), _ => false, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index ddcc0fa9c9280..3d7117dd46a21 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -234,7 +234,7 @@ impl PrintContext { } } write!(f, ")")?; - if !output.is_nil() { + if !output.is_unit() { print!(f, self, write(" -> "), print_display(output))?; } diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index 95a094bf909e1..f9eb80a1988af 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -160,7 +160,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, output.push(')'); - if !sig.output().is_nil() { + if !sig.output().is_unit() { output.push_str(" -> "); push_debuginfo_type_name(cx, sig.output(), true, output); } diff --git a/src/librustc_codegen_llvm/mir/rvalue.rs b/src/librustc_codegen_llvm/mir/rvalue.rs index e301e5ae70be8..c3ec347f60876 100644 --- a/src/librustc_codegen_llvm/mir/rvalue.rs +++ b/src/librustc_codegen_llvm/mir/rvalue.rs @@ -566,7 +566,7 @@ impl FunctionCx<'a, 'll, 'tcx> { ) -> &'ll Value { let is_float = input_ty.is_fp(); let is_signed = input_ty.is_signed(); - let is_nil = input_ty.is_nil(); + let is_unit = input_ty.is_unit(); match op { mir::BinOp::Add => if is_float { bx.fadd(lhs, rhs) @@ -604,7 +604,7 @@ impl FunctionCx<'a, 'll, 'tcx> { mir::BinOp::Shl => common::build_unchecked_lshift(bx, lhs, rhs), mir::BinOp::Shr => common::build_unchecked_rshift(bx, input_ty, lhs, rhs), mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt | - mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_nil { + mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_unit { C_bool(bx.cx, match op { mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt => false, mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => true, diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 33181bd80e937..2bec9203e9ee5 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -691,7 +691,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } let sig = cx.erase_late_bound_regions(&sig); - if !sig.output().is_nil() { + if !sig.output().is_unit() { let r = self.check_type_for_ffi(cache, sig.output()); match r { FfiSafe => {} @@ -767,7 +767,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { if let hir::Return(ref ret_hir) = decl.output { let ret_ty = sig.output(); - if !ret_ty.is_nil() { + if !ret_ty.is_unit() { self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty); } } diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index c3637a5abebdc..50d4944d7c242 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // the case of `!`, no return value is required, as the block will never return. let tcx = this.hir.tcx(); let ty = destination.ty(&this.local_decls, tcx).to_ty(tcx); - if ty.is_nil() { + if ty.is_unit() { // We only want to assign an implicit `()` as the return value of the block if the // block does not diverge. (Otherwise, we may try to assign a unit to a `!`-type.) this.cfg.push_assign_unit(block, source_info, destination); diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index dc437ee8510d7..3f5a05f9d0ed8 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -368,7 +368,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { output.push(')'); - if !sig.output().is_nil() { + if !sig.output().is_unit() { output.push_str(" -> "); self.push_type_name(sig.output(), output); } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 60da6e1d72a88..9913b8de7a742 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -677,14 +677,14 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); // Handle the fallback arm of a desugared if-let like a missing else. let is_if_let_fallback = match match_src { hir::MatchSource::IfLetDesugar { contains_else_clause: false } => { - i == arms.len() - 1 && arm_ty.is_nil() + i == arms.len() - 1 && arm_ty.is_unit() } _ => false }; if is_if_let_fallback { let cause = self.cause(expr.span, ObligationCauseCode::IfExpressionWithNoElse); - assert!(arm_ty.is_nil()); + assert!(arm_ty.is_unit()); coercion.coerce_forced_unit(self, &cause, &mut |_| (), true); } else { let cause = self.cause(expr.span, ObligationCauseCode::MatchExpressionArm { diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 47c3cf4dfa001..9604eb3420fb3 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -1146,8 +1146,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E> // `expression_ty` will be unit). // // Another example is `break` with no argument expression. - assert!(expression_ty.is_nil()); - assert!(expression_ty.is_nil(), "if let hack without unit type"); + assert!(expression_ty.is_unit()); + assert!(expression_ty.is_unit(), "if let hack without unit type"); fcx.at(cause, fcx.param_env) .eq_exp(label_expression_as_expected, expression_ty, self.merged_ty()) .map(|infer_ok| { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f884a3513d121..3d66beaf2ecab 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2808,9 +2808,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } else { // is the missing argument of type `()`? let sugg_unit = if expected_arg_tys.len() == 1 && supplied_arg_count == 0 { - self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_nil() + self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_unit() } else if fn_inputs.len() == 1 && supplied_arg_count == 0 { - self.resolve_type_vars_if_possible(&fn_inputs[0]).is_nil() + self.resolve_type_vars_if_possible(&fn_inputs[0]).is_unit() } else { false }; @@ -3958,7 +3958,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(ref e) = *expr_opt { coerce.coerce(self, &cause, e, e_ty); } else { - assert!(e_ty.is_nil()); + assert!(e_ty.is_unit()); coerce.coerce_forced_unit(self, &cause, &mut |_| (), true); } } else { @@ -4752,7 +4752,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expression: &'gcx hir::Expr, expected: Ty<'tcx>, cause_span: Span) { - if expected.is_nil() { + if expected.is_unit() { // `BlockTailExpression` only relevant if the tail expr would be // useful on its own. match expression.node { @@ -4795,7 +4795,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { can_suggest: bool) { // Only suggest changing the return type for methods that // haven't set a return type at all (and aren't `fn main()` or an impl). - match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_nil()) { + match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_unit()) { (&hir::FunctionRetTy::DefaultReturn(span), true, true, true) => { err.span_suggestion_with_applicability( span, From 8134ee25b88df98c79792d60cbf6745b6cb7ffc5 Mon Sep 17 00:00:00 2001 From: kenta7777 Date: Tue, 11 Sep 2018 23:32:41 +0900 Subject: [PATCH 17/23] renamed emit_nil to emit_unit --- src/librustc/ty/query/on_disk_cache.rs | 2 +- src/librustc_metadata/encoder.rs | 2 +- src/libserialize/json.rs | 10 +++++----- src/libserialize/opaque.rs | 2 +- src/libserialize/serialize.rs | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 6e16d92ba0c8d..19e235154cbd0 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -1020,7 +1020,7 @@ impl<'enc, 'a, 'tcx, E> Encoder for CacheEncoder<'enc, 'a, 'tcx, E> { type Error = E::Error; - fn emit_nil(&mut self) -> Result<(), Self::Error> { + fn emit_unit(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index aae45c17c6771..56b38cfbc872a 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -75,7 +75,7 @@ macro_rules! encoder_methods { impl<'a, 'tcx> Encoder for EncodeContext<'a, 'tcx> { type Error = ::Error; - fn emit_nil(&mut self) -> Result<(), Self::Error> { + fn emit_unit(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 35ef6327de5fd..9439dc78d3ca4 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -490,7 +490,7 @@ macro_rules! emit_enquoted_if_mapkey { impl<'a> ::Encoder for Encoder<'a> { type Error = EncoderError; - fn emit_nil(&mut self) -> EncodeResult { + fn emit_unit(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } write!(self.writer, "null")?; Ok(()) @@ -648,7 +648,7 @@ impl<'a> ::Encoder for Encoder<'a> { } fn emit_option_none(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_nil() + self.emit_unit() } fn emit_option_some(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, @@ -740,7 +740,7 @@ impl<'a> PrettyEncoder<'a> { impl<'a> ::Encoder for PrettyEncoder<'a> { type Error = EncoderError; - fn emit_nil(&mut self) -> EncodeResult { + fn emit_unit(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } write!(self.writer, "null")?; Ok(()) @@ -923,7 +923,7 @@ impl<'a> ::Encoder for PrettyEncoder<'a> { } fn emit_option_none(&mut self) -> EncodeResult { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_nil() + self.emit_unit() } fn emit_option_some(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, @@ -1016,7 +1016,7 @@ impl Encodable for Json { Json::Boolean(v) => v.encode(e), Json::Array(ref v) => v.encode(e), Json::Object(ref v) => v.encode(e), - Json::Null => e.emit_nil(), + Json::Null => e.emit_unit(), } } } diff --git a/src/libserialize/opaque.rs b/src/libserialize/opaque.rs index c71f474891131..4ce80bc36a080 100644 --- a/src/libserialize/opaque.rs +++ b/src/libserialize/opaque.rs @@ -55,7 +55,7 @@ impl serialize::Encoder for Encoder { type Error = !; #[inline] - fn emit_nil(&mut self) -> EncodeResult { + fn emit_unit(&mut self) -> EncodeResult { Ok(()) } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 416be50bfe9ea..f0b49c3d9bc8f 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -25,7 +25,7 @@ pub trait Encoder { type Error; // Primitive types: - fn emit_nil(&mut self) -> Result<(), Self::Error>; + fn emit_unit(&mut self) -> Result<(), Self::Error>; fn emit_usize(&mut self, v: usize) -> Result<(), Self::Error>; fn emit_u128(&mut self, v: u128) -> Result<(), Self::Error>; fn emit_u64(&mut self, v: u64) -> Result<(), Self::Error>; @@ -537,7 +537,7 @@ impl Decodable for char { impl Encodable for () { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_nil() + s.emit_unit() } } From 1ad0919fa9a9404ba82125c2c654f3d8c25a202b Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Thu, 13 Sep 2018 14:58:13 -0400 Subject: [PATCH 18/23] Remove println!() statement from HashMap unit test --- src/libstd/collections/hash/map.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 804d43f4fc683..eb63d547dd557 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -3537,7 +3537,6 @@ mod test_map { match m.entry(x) { Vacant(_) => {} Occupied(e) => { - println!("{}: remove {}", i, x); e.remove(); } } From 7249a1b1ae075e3a955fda69cdea5161d0eb1aa5 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Thu, 13 Sep 2018 08:42:19 +0200 Subject: [PATCH 19/23] Suggest valid crate type if invalid This adds a suggestion to the `invalid_crate_types` lint. The suggestion is based on the Levenshtein distance to existing crate types. If no suggestion is found it will show the lint without any suggestions. --- src/librustc/lint/builtin.rs | 9 ++++ src/librustc_driver/driver.rs | 48 ++++++++++++++--- src/test/ui/invalid/invalid-crate-type.rs | 42 +++++++++++++++ src/test/ui/invalid/invalid-crate-type.stderr | 54 +++++++++++++++++-- 4 files changed, 143 insertions(+), 10 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 6783415619f98..e6452ad09278e 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -422,6 +422,7 @@ pub enum BuiltinLintDiagnostics { ProcMacroDeriveResolutionFallback(Span), MacroExpandedMacroExportsAccessedByAbsolutePaths(Span), ElidedLifetimesInPaths(usize, Span, bool, Span, String), + UnknownCrateTypes(Span, String, String), } impl BuiltinLintDiagnostics { @@ -500,6 +501,14 @@ impl BuiltinLintDiagnostics { Applicability::MachineApplicable ); } + BuiltinLintDiagnostics::UnknownCrateTypes(span, note, sugg) => { + db.span_suggestion_with_applicability( + span, + ¬e, + sugg, + Applicability::MaybeIncorrect + ); + } } } } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index d27b0856c1533..7fb66ea97f26b 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -57,6 +57,8 @@ use syntax::ext::base::ExtCtxt; use syntax::fold::Folder; use syntax::parse::{self, PResult}; use syntax::util::node_count::NodeCounter; +use syntax::util::lev_distance::find_best_match_for_name; +use syntax::symbol::Symbol; use syntax_pos::{FileName, hygiene}; use syntax_ext; @@ -1508,13 +1510,45 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec Some(config::CrateType::Staticlib), Some(ref n) if *n == "proc-macro" => Some(config::CrateType::ProcMacro), Some(ref n) if *n == "bin" => Some(config::CrateType::Executable), - Some(_) => { - session.buffer_lint( - lint::builtin::UNKNOWN_CRATE_TYPES, - ast::CRATE_NODE_ID, - a.span, - "invalid `crate_type` value", - ); + Some(ref n) => { + let crate_types = vec![ + Symbol::intern("rlib"), + Symbol::intern("dylib"), + Symbol::intern("cdylib"), + Symbol::intern("lib"), + Symbol::intern("staticlib"), + Symbol::intern("proc-macro"), + Symbol::intern("bin") + ]; + if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node { + let span = spanned.span; + let lev_candidate = find_best_match_for_name( + crate_types.iter(), + &n.as_str(), + None + ); + if let Some(candidate) = lev_candidate { + session.buffer_lint_with_diagnostic( + lint::builtin::UNKNOWN_CRATE_TYPES, + ast::CRATE_NODE_ID, + span, + "invalid `crate_type` value", + lint::builtin::BuiltinLintDiagnostics:: + UnknownCrateTypes( + span, + "did you mean".to_string(), + format!("\"{}\"", candidate) + ) + ); + } else { + session.buffer_lint( + lint::builtin::UNKNOWN_CRATE_TYPES, + ast::CRATE_NODE_ID, + span, + "invalid `crate_type` value" + ); + } + } None } _ => { diff --git a/src/test/ui/invalid/invalid-crate-type.rs b/src/test/ui/invalid/invalid-crate-type.rs index 4b6b6c2fe7677..e7f4e32dc7c41 100644 --- a/src/test/ui/invalid/invalid-crate-type.rs +++ b/src/test/ui/invalid/invalid-crate-type.rs @@ -11,6 +11,48 @@ // regression test for issue 11256 #![crate_type="foo"] //~ ERROR invalid `crate_type` value +// Tests for suggestions (#53958) + +#![crate_type="statoclib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION staticlib + +#![crate_type="procmacro"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION proc-macro + +#![crate_type="static-lib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION staticlib + +#![crate_type="drylib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION dylib + +#![crate_type="dlib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION rlib + +#![crate_type="lob"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION lib + +#![crate_type="bon"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION bin + +#![crate_type="cdalib"] +//~^ ERROR invalid `crate_type` value +//~| HELP did you mean +//~| SUGGESTION cdylib + fn main() { return } diff --git a/src/test/ui/invalid/invalid-crate-type.stderr b/src/test/ui/invalid/invalid-crate-type.stderr index 6dc8a0f2bbb04..c82da865f3353 100644 --- a/src/test/ui/invalid/invalid-crate-type.stderr +++ b/src/test/ui/invalid/invalid-crate-type.stderr @@ -1,10 +1,58 @@ error: invalid `crate_type` value - --> $DIR/invalid-crate-type.rs:12:1 + --> $DIR/invalid-crate-type.rs:12:15 | LL | #![crate_type="foo"] //~ ERROR invalid `crate_type` value - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | = note: #[deny(unknown_crate_types)] on by default -error: aborting due to previous error +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:16:15 + | +LL | #![crate_type="statoclib"] + | ^^^^^^^^^^^ help: did you mean: `"staticlib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:21:15 + | +LL | #![crate_type="procmacro"] + | ^^^^^^^^^^^ help: did you mean: `"proc-macro"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:26:15 + | +LL | #![crate_type="static-lib"] + | ^^^^^^^^^^^^ help: did you mean: `"staticlib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:31:15 + | +LL | #![crate_type="drylib"] + | ^^^^^^^^ help: did you mean: `"dylib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:36:15 + | +LL | #![crate_type="dlib"] + | ^^^^^^ help: did you mean: `"rlib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:41:15 + | +LL | #![crate_type="lob"] + | ^^^^^ help: did you mean: `"lib"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:46:15 + | +LL | #![crate_type="bon"] + | ^^^^^ help: did you mean: `"bin"` + +error: invalid `crate_type` value + --> $DIR/invalid-crate-type.rs:51:15 + | +LL | #![crate_type="cdalib"] + | ^^^^^^^^ help: did you mean: `"cdylib"` + +error: aborting due to 9 previous errors From e9583628b2dcc389a69999e5ff431b70c1561488 Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Thu, 13 Sep 2018 16:48:09 -0400 Subject: [PATCH 20/23] Eliminate unused variable warning --- src/libstd/collections/hash/map.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index eb63d547dd557..ef5dae724b247 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -3532,7 +3532,7 @@ mod test_map { m.insert(x, ()); } - for i in 0..1000 { + for _ in 0..1000 { let x = rng.gen_range(-10, 10); match m.entry(x) { Vacant(_) => {} From 2e75b07eee8f506e3410c199444abf60b9062055 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 13 Sep 2018 14:25:43 -0700 Subject: [PATCH 21/23] Fix the stable release of os_str_str_ref_eq This was added and stabilized in commit 02503029b83a, but while that claimed to be for 1.28.0, it didn't actually make it until 1.29.0. --- src/libstd/ffi/os_str.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 8ae5e20dac5aa..237af2f04e59d 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -420,14 +420,14 @@ impl PartialEq for str { } } -#[stable(feature = "os_str_str_ref_eq", since = "1.28.0")] +#[stable(feature = "os_str_str_ref_eq", since = "1.29.0")] impl<'a> PartialEq<&'a str> for OsString { fn eq(&self, other: &&'a str) -> bool { **self == **other } } -#[stable(feature = "os_str_str_ref_eq", since = "1.28.0")] +#[stable(feature = "os_str_str_ref_eq", since = "1.29.0")] impl<'a> PartialEq for &'a str { fn eq(&self, other: &OsString) -> bool { **other == **self From dda7e0dec6d3a9dd3a89d6483b81f3d1511ec63a Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 13 Sep 2018 17:31:56 -0500 Subject: [PATCH 22/23] re-mark the never docs as unstable --- src/libstd/primitive_docs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 7074928eaf6da..4c1fdc4f89538 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -250,6 +250,7 @@ mod prim_bool { } /// [`Default`]: default/trait.Default.html /// [`default()`]: default/trait.Default.html#tymethod.default /// +#[unstable(feature = "never_type", issue = "35121")] mod prim_never { } #[doc(primitive = "char")] From 7a1eed73be3e420cf3b3fc9f5cadd64725a17c9f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 13 Sep 2018 18:35:08 -0700 Subject: [PATCH 23/23] Update Cargo Should bring in some nice progress bars for compilations! --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index b917e35248fe5..a5d8294948580 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit b917e35248fe57d11765c5a835de33e335babb7e +Subproject commit a5d82949485802abb45f888d5b8b7f23927f031d