From 3477939b798b64f135a09f1b8b54a0034ede3246 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 6 Mar 2019 20:14:27 -0800 Subject: [PATCH 01/24] [CI] Update binutils for powerpc64 and powerpc64le Cargo powerpc64 and powerpc64le are seeing `SIGILL` crashes in openssl, which was found to be a linking problem, fixed by newer binutils. See For powerpc64 we're using crosstool-ng, which doesn't offer a newer binutils version, but we can just compile it separately. On powerpc64le we're already building binutils. Both are now updated to binutils 2.32. Closes rust-lang/cargo#6320 Closes rust-lang/rust#57345 Closes rust-lang/rustup.rs#1620 --- .../build-powerpc64-toolchain.sh | 19 +++++++++++++++++++ .../build-powerpc64le-toolchain.sh | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh b/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh index f7aa2cd326832..a4431cbc0a16d 100755 --- a/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh +++ b/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh @@ -3,9 +3,28 @@ set -ex source shared.sh +BINUTILS=2.32 +TARGET=powerpc64-unknown-linux-gnu +PREFIX=/x-tools/$TARGET +SYSROOT=$PREFIX/$TARGET/sysroot + mkdir build cd build cp ../powerpc64-linux-gnu.config .config hide_output ct-ng build cd .. rm -rf build + +chmod -R u+w $PREFIX + +# Next, download and build newer binutils. +mkdir binutils-$TARGET +pushd binutils-$TARGET +curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf - +mkdir binutils-build +cd binutils-build +hide_output ../binutils-$BINUTILS/configure --target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT +hide_output make -j10 +hide_output make install +popd +rm -rf binutils-$TARGET diff --git a/src/ci/docker/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh b/src/ci/docker/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh index a01803d9c8f45..f866a24287f9e 100755 --- a/src/ci/docker/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh +++ b/src/ci/docker/dist-powerpc64le-linux/build-powerpc64le-toolchain.sh @@ -4,7 +4,7 @@ set -ex source shared.sh -BINUTILS=2.25.1 +BINUTILS=2.32 GCC=5.3.0 TARGET=powerpc64le-linux-gnu SYSROOT=/usr/local/$TARGET/sysroot From c843fe710bb7fb454d68505c8000c0a50bc2a729 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 6 Mar 2019 20:33:09 -0800 Subject: [PATCH 02/24] Wrap a long configure line --- .../docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh b/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh index a4431cbc0a16d..fc53849a2ada4 100755 --- a/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh +++ b/src/ci/docker/dist-powerpc64-linux/build-powerpc64-toolchain.sh @@ -23,7 +23,8 @@ pushd binutils-$TARGET curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 | tar xjf - mkdir binutils-build cd binutils-build -hide_output ../binutils-$BINUTILS/configure --target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT +hide_output ../binutils-$BINUTILS/configure --target=$TARGET \ + --prefix=$PREFIX --with-sysroot=$SYSROOT hide_output make -j10 hide_output make install popd From b9d12edd6ce7b364fb1a4de53f7541d536df0940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 11 Mar 2019 15:07:07 -0700 Subject: [PATCH 03/24] Be more discerning on when to attempt suggesting a comma in a macro invocation --- src/libsyntax/tokenstream.rs | 8 +++++--- src/test/ui/macros/missing-comma.rs | 7 +++++++ src/test/ui/macros/missing-comma.stderr | 21 +++++++++++++++------ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 4ce308d015c00..5caa59a53f92b 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -178,9 +178,11 @@ impl TokenStream { while let Some((pos, ts)) = iter.next() { if let Some((_, next)) = iter.peek() { let sp = match (&ts, &next) { - ((TokenTree::Token(_, token::Token::Comma), NonJoint), _) | - (_, (TokenTree::Token(_, token::Token::Comma), NonJoint)) => continue, - ((TokenTree::Token(sp, _), NonJoint), _) => *sp, + (_, (TokenTree::Token(_, token::Token::Comma), _)) => continue, + ((TokenTree::Token(sp, token_left), NonJoint), + (TokenTree::Token(_, token_right), _)) + if token_left.is_ident() || token_left.is_lit() && + token_right.is_ident() || token_right.is_lit() => *sp, ((TokenTree::Delimited(sp, ..), NonJoint), _) => sp.entire(), _ => continue, }; diff --git a/src/test/ui/macros/missing-comma.rs b/src/test/ui/macros/missing-comma.rs index 1e146875bcc76..2b411aba8a2ee 100644 --- a/src/test/ui/macros/missing-comma.rs +++ b/src/test/ui/macros/missing-comma.rs @@ -6,6 +6,11 @@ macro_rules! foo { ($a:ident, $b:ident, $c:ident, $d:ident, $e:ident) => (); } +macro_rules! bar { + ($lvl:expr, $($arg:tt)+) => {} +} + + fn main() { println!("{}" a); //~^ ERROR expected token: `,` @@ -17,4 +22,6 @@ fn main() { //~^ ERROR no rules expected the token `d` foo!(a, b, c d e); //~^ ERROR no rules expected the token `d` + bar!(Level::Error, ); + //~^ ERROR unexpected end of macro invocation } diff --git a/src/test/ui/macros/missing-comma.stderr b/src/test/ui/macros/missing-comma.stderr index 5881e0b7b68c6..424fefd00f873 100644 --- a/src/test/ui/macros/missing-comma.stderr +++ b/src/test/ui/macros/missing-comma.stderr @@ -1,11 +1,11 @@ error: expected token: `,` - --> $DIR/missing-comma.rs:10:19 + --> $DIR/missing-comma.rs:15:19 | LL | println!("{}" a); | ^ error: no rules expected the token `b` - --> $DIR/missing-comma.rs:12:12 + --> $DIR/missing-comma.rs:17:12 | LL | macro_rules! foo { | ---------------- when calling this macro @@ -16,7 +16,7 @@ LL | foo!(a b); | help: missing comma here error: no rules expected the token `e` - --> $DIR/missing-comma.rs:14:21 + --> $DIR/missing-comma.rs:19:21 | LL | macro_rules! foo { | ---------------- when calling this macro @@ -27,7 +27,7 @@ LL | foo!(a, b, c, d e); | help: missing comma here error: no rules expected the token `d` - --> $DIR/missing-comma.rs:16:18 + --> $DIR/missing-comma.rs:21:18 | LL | macro_rules! foo { | ---------------- when calling this macro @@ -38,7 +38,7 @@ LL | foo!(a, b, c d, e); | help: missing comma here error: no rules expected the token `d` - --> $DIR/missing-comma.rs:18:18 + --> $DIR/missing-comma.rs:23:18 | LL | macro_rules! foo { | ---------------- when calling this macro @@ -46,5 +46,14 @@ LL | macro_rules! foo { LL | foo!(a, b, c d e); | ^ no rules expected this token in macro call -error: aborting due to 5 previous errors +error: unexpected end of macro invocation + --> $DIR/missing-comma.rs:25:23 + | +LL | macro_rules! bar { + | ---------------- when calling this macro +... +LL | bar!(Level::Error, ); + | ^ missing tokens in macro arguments + +error: aborting due to 6 previous errors From 27abd52170b2d2769f5fbed665795bdb9a3facef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 13 Mar 2019 00:10:16 -0700 Subject: [PATCH 04/24] Fix operator precedence --- src/libsyntax/tokenstream.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsyntax/tokenstream.rs b/src/libsyntax/tokenstream.rs index 5caa59a53f92b..80a7bde606afa 100644 --- a/src/libsyntax/tokenstream.rs +++ b/src/libsyntax/tokenstream.rs @@ -181,8 +181,8 @@ impl TokenStream { (_, (TokenTree::Token(_, token::Token::Comma), _)) => continue, ((TokenTree::Token(sp, token_left), NonJoint), (TokenTree::Token(_, token_right), _)) - if token_left.is_ident() || token_left.is_lit() && - token_right.is_ident() || token_right.is_lit() => *sp, + if (token_left.is_ident() || token_left.is_lit()) && + (token_right.is_ident() || token_right.is_lit()) => *sp, ((TokenTree::Delimited(sp, ..), NonJoint), _) => sp.entire(), _ => continue, }; From 4e5692d9858d298f27757579688c71ba494cb5c3 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 18 Jan 2019 12:18:57 +0100 Subject: [PATCH 05/24] test that wildcard type `_` is not duplicated by `type Foo = (X, X);` and potentially instantiated at different types. (Updated to reflect changes in diagnostic output and compiletest infrastructure.) --- ...ssue-55748-pat-types-constrain-bindings.rs | 70 +++++++++++++++++++ ...-55748-pat-types-constrain-bindings.stderr | 29 ++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.rs create mode 100644 src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr diff --git a/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.rs b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.rs new file mode 100644 index 0000000000000..3d042d442d531 --- /dev/null +++ b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.rs @@ -0,0 +1,70 @@ +// This test is ensuring that type ascriptions on let bindings +// constrain both: +// +// 1. the input expression on the right-hand side (after any potential +// coercion, and allowing for covariance), *and* +// +// 2. the bindings (if any) nested within the pattern on the left-hand +// side (and here, the type-constraint is *invariant*). + +#![feature(nll)] + +#![allow(dead_code, unused_mut)] +type PairUncoupled<'a, 'b, T> = (&'a T, &'b T); +type PairCoupledRegions<'a, T> = (&'a T, &'a T); +type PairCoupledTypes = (T, T); + +fn uncoupled_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { + let ((mut y, mut _z),): (PairUncoupled,) = ((s, &_x),); // ok + // Above compiling does *not* imply below would compile. + // ::std::mem::swap(&mut y, &mut _z); + y +} + +fn swap_regions((mut y, mut _z): PairCoupledRegions) { + ::std::mem::swap(&mut y, &mut _z); +} + +fn coupled_regions_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { + let ((y, _z),): (PairCoupledRegions,) = ((s, &_x),); + // If above line compiled, so should line below ... + + // swap_regions((y, _z)); + + // ... but the ascribed type also invalidates this use of `y` + y //~ ERROR lifetime may not live long enough +} + +fn swap_types((mut y, mut _z): PairCoupledTypes<&u32>) { + ::std::mem::swap(&mut y, &mut _z); +} + +fn coupled_types_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { + let ((y, _z),): (PairCoupledTypes<&u32>,) = ((s, &_x),); + // If above line compiled, so should line below ... + + // swap_types((y, _z)); + + // ... but the ascribed type also invalidates this use of `y` + y //~ ERROR lifetime may not live long enough +} + +fn swap_wilds((mut y, mut _z): PairCoupledTypes<&u32>) { + ::std::mem::swap(&mut y, &mut _z); +} + +fn coupled_wilds_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { + let ((y, _z),): (PairCoupledTypes<_>,) = ((s, &_x),); + // If above line compiled, so should line below + // swap_wilds((y, _z)); + + // ... but the ascribed type also invalidates this use of `y` + y //~ ERROR lifetime may not live long enough +} + +fn main() { + uncoupled_lhs(&3, &4); + coupled_regions_lhs(&3, &4); + coupled_types_lhs(&3, &4); + coupled_wilds_lhs(&3, &4); +} diff --git a/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr new file mode 100644 index 0000000000000..5929707e41e10 --- /dev/null +++ b/src/test/ui/nll/user-annotations/issue-55748-pat-types-constrain-bindings.stderr @@ -0,0 +1,29 @@ +error: lifetime may not live long enough + --> $DIR/issue-55748-pat-types-constrain-bindings.rs:35:5 + | +LL | fn coupled_regions_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { + | -- lifetime `'a` defined here +... +LL | y + | ^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/issue-55748-pat-types-constrain-bindings.rs:49:5 + | +LL | fn coupled_types_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { + | -- lifetime `'a` defined here +... +LL | y + | ^ returning this value requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/issue-55748-pat-types-constrain-bindings.rs:62:5 + | +LL | fn coupled_wilds_lhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 { + | -- lifetime `'a` defined here +... +LL | y + | ^ returning this value requires that `'a` must outlive `'static` + +error: aborting due to 3 previous errors + From a7bd36c9e8cdfac6a6edd4124e0d1d99a41b99a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Mon, 11 Mar 2019 16:07:31 +0000 Subject: [PATCH 06/24] Add peer_addr function to UdpSocket --- src/libstd/net/udp.rs | 17 +++++++++++++++++ src/libstd/sys/cloudabi/shims/net.rs | 4 ++++ src/libstd/sys/redox/net/udp.rs | 5 +++++ src/libstd/sys/sgx/net.rs | 4 ++++ src/libstd/sys_common/net.rs | 6 ++++++ 5 files changed, 36 insertions(+) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index edc9d665444a0..c7ccf45b953e7 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -180,6 +180,23 @@ impl UdpSocket { } } + /// Returns the socket address of the remote peer this socket was connected to. + /// + /// # Examples + /// + /// ```no_run + /// use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, UdpSocket}; + /// + /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); + /// socket.connect("192.168.0.1:41203").expect("couldn't connect to address"); + /// assert_eq!(socket.peer_addr().unwrap(), + /// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203))); + /// ``` + #[stable(feature = "rust1", since = "1.0.0")] + pub fn peer_addr(&self) -> io::Result { + self.0.peer_addr() + } + /// Returns the socket address that this socket was created from. /// /// # Examples diff --git a/src/libstd/sys/cloudabi/shims/net.rs b/src/libstd/sys/cloudabi/shims/net.rs index 6d2a4962ab444..4364a1365443a 100644 --- a/src/libstd/sys/cloudabi/shims/net.rs +++ b/src/libstd/sys/cloudabi/shims/net.rs @@ -159,6 +159,10 @@ impl UdpSocket { unsupported() } + pub fn peer_addr(&self) -> io::Result { + match self.0 {} + } + pub fn socket_addr(&self) -> io::Result { match self.0 {} } diff --git a/src/libstd/sys/redox/net/udp.rs b/src/libstd/sys/redox/net/udp.rs index b1a60b1457083..274123dce4b58 100644 --- a/src/libstd/sys/redox/net/udp.rs +++ b/src/libstd/sys/redox/net/udp.rs @@ -72,6 +72,11 @@ impl UdpSocket { Ok(None) } + pub fn peer_addr(&self) -> Result { + let path = self.0.path()?; + Ok(path_to_peer_addr(path.to_str().unwrap_or(""))) + } + pub fn socket_addr(&self) -> Result { let path = self.0.path()?; Ok(path_to_local_addr(path.to_str().unwrap_or(""))) diff --git a/src/libstd/sys/sgx/net.rs b/src/libstd/sys/sgx/net.rs index e5e42e3d0b048..e851bdfe6a831 100644 --- a/src/libstd/sys/sgx/net.rs +++ b/src/libstd/sys/sgx/net.rs @@ -257,6 +257,10 @@ impl UdpSocket { unsupported() } + pub fn peer_addr(&self) -> io::Result { + match self.0 {} + } + pub fn socket_addr(&self) -> io::Result { match self.0 {} } diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs index b9505aaa69ba5..b77bcee4b9d04 100644 --- a/src/libstd/sys_common/net.rs +++ b/src/libstd/sys_common/net.rs @@ -472,6 +472,12 @@ impl UdpSocket { pub fn into_socket(self) -> Socket { self.inner } + pub fn peer_addr(&self) -> io::Result { + sockname(|buf, len| unsafe { + c::getpeername(*self.inner.as_inner(), buf, len) + }) + } + pub fn socket_addr(&self) -> io::Result { sockname(|buf, len| unsafe { c::getsockname(*self.inner.as_inner(), buf, len) From bf473e3c153dfa84056249864a9f696d72f4e9a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 10:32:23 +0000 Subject: [PATCH 07/24] Mark UdpSocket peer_addr unstable w/ tracking issue --- src/libstd/net/udp.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index c7ccf45b953e7..164039b303230 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -185,6 +185,7 @@ impl UdpSocket { /// # Examples /// /// ```no_run + /// #![feature(udp_peer_addr)] /// use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4, UdpSocket}; /// /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); @@ -192,7 +193,7 @@ impl UdpSocket { /// assert_eq!(socket.peer_addr().unwrap(), /// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203))); /// ``` - #[stable(feature = "rust1", since = "1.0.0")] + #[unstable(feature = "udp_peer_addr", issue = "59127")] pub fn peer_addr(&self) -> io::Result { self.0.peer_addr() } From 24e3fa079c150675e1911f1a9f958b690ecaa1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 11:19:33 +0000 Subject: [PATCH 08/24] Document UdpSocket peer_addr NotConnected error --- src/libstd/net/udp.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 164039b303230..79e5ae79e4c01 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -193,6 +193,19 @@ impl UdpSocket { /// assert_eq!(socket.peer_addr().unwrap(), /// SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 41203))); /// ``` + /// + /// If the socket isn't connected, it will return a [`NotConnected`] error. + /// + /// [`NotConnected`]: ../../std/io/enum.ErrorKind.html#variant.NotConnected + /// + /// ```no_run + /// #![feature(udp_peer_addr)] + /// use std::net::UdpSocket; + /// + /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address"); + /// assert_eq!(socket.peer_addr().unwrap_err().kind(), + /// ::std::io::ErrorKind::NotConnected); + /// ``` #[unstable(feature = "udp_peer_addr", issue = "59127")] pub fn peer_addr(&self) -> io::Result { self.0.peer_addr() From 7f7cfaee6aafbaa2477cb00b273299ec4e7d18d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 16:50:00 +0000 Subject: [PATCH 09/24] Add test for UdpSocket peer_addr --- src/libstd/net/udp.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index 79e5ae79e4c01..f3f65034f4256 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -903,6 +903,16 @@ mod tests { }) } + #[test] + fn socket_peer_ip4() { + each_ip(&mut |addr1, addr2| { + let server = t!(UdpSocket::bind(&addr1)); + assert_eq!(server.peer_addr().unwrap_err().kind(), ErrorKind::NotConnected); + t!(server.connect(&addr2)); + assert_eq!(addr2, t!(server.peer_addr())); + }) + } + #[test] fn udp_clone_smoke() { each_ip(&mut |addr1, addr2| { From 7e73cd48c4d531d8c3048941b4436833ec8651e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 12 Mar 2019 17:18:07 +0000 Subject: [PATCH 10/24] Fix test names regarding ip version --- src/libstd/net/udp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index f3f65034f4256..b42a812304269 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -896,7 +896,7 @@ mod tests { } #[test] - fn socket_name_ip4() { + fn socket_name() { each_ip(&mut |addr, _| { let server = t!(UdpSocket::bind(&addr)); assert_eq!(addr, t!(server.local_addr())); @@ -904,7 +904,7 @@ mod tests { } #[test] - fn socket_peer_ip4() { + fn socket_peer() { each_ip(&mut |addr1, addr2| { let server = t!(UdpSocket::bind(&addr1)); assert_eq!(server.peer_addr().unwrap_err().kind(), ErrorKind::NotConnected); From 214110bb4c7902e4787612efc265e4b2bdf0c1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Sat, 16 Mar 2019 11:19:01 +0000 Subject: [PATCH 11/24] Add UdpSocket peer_addr implementation for L4Re --- src/libstd/sys/unix/l4re.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/sys/unix/l4re.rs b/src/libstd/sys/unix/l4re.rs index b9e725371a36e..b3dd1cf6aaac7 100644 --- a/src/libstd/sys/unix/l4re.rs +++ b/src/libstd/sys/unix/l4re.rs @@ -292,6 +292,10 @@ pub mod net { pub fn into_socket(self) -> Socket { self.inner } + pub fn peer_addr(&self) -> io::Result { + unimpl!(); + } + pub fn socket_addr(&self) -> io::Result { unimpl!(); } @@ -463,4 +467,3 @@ pub mod net { } } } - From 81d5fb5c6fc65e947ff97c02997bfff9a1f6ce16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Sat, 16 Mar 2019 11:20:02 +0000 Subject: [PATCH 12/24] Add UdpSocket peer_addr implementation for Wasm --- src/libstd/sys/wasm/net.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/sys/wasm/net.rs b/src/libstd/sys/wasm/net.rs index a2ea2dfbbc032..c85dd000afe6f 100644 --- a/src/libstd/sys/wasm/net.rs +++ b/src/libstd/sys/wasm/net.rs @@ -156,6 +156,10 @@ impl UdpSocket { unsupported() } + pub fn peer_addr(&self) -> io::Result { + match self.0 {} + } + pub fn socket_addr(&self) -> io::Result { match self.0 {} } From b392c5e3c17396f3987f671a61fa9fbf9f999dae Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sat, 16 Mar 2019 13:14:01 -0400 Subject: [PATCH 13/24] use the identifier span for missing struct field --- src/librustc_typeck/check/_match.rs | 16 ++++++++-------- src/test/ui/issues/issue-17800.stderr | 4 ++-- src/test/ui/issues/issue-51102.stderr | 4 ++-- src/test/ui/issues/issue-52717.stderr | 2 +- src/test/ui/numeric/numeric-fields.stderr | 2 +- src/test/ui/structs/struct-field-cfg.stderr | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 1a3ade7f8baf6..87e0f7d201c17 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -971,7 +971,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); self.field_ty(span, f, substs) }) .unwrap_or_else(|| { - inexistent_fields.push((span, field.ident)); + inexistent_fields.push(field.ident); no_field_errors = false; tcx.types.err }) @@ -987,15 +987,15 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); .collect::>(); if inexistent_fields.len() > 0 { let (field_names, t, plural) = if inexistent_fields.len() == 1 { - (format!("a field named `{}`", inexistent_fields[0].1), "this", "") + (format!("a field named `{}`", inexistent_fields[0]), "this", "") } else { (format!("fields named {}", inexistent_fields.iter() - .map(|(_, name)| format!("`{}`", name)) + .map(|ident| format!("`{}`", ident)) .collect::>() .join(", ")), "these", "s") }; - let spans = inexistent_fields.iter().map(|(span, _)| *span).collect::>(); + let spans = inexistent_fields.iter().map(|ident| ident.span).collect::>(); let mut err = struct_span_err!(tcx.sess, spans, E0026, @@ -1003,8 +1003,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); kind_name, tcx.item_path_str(variant.did), field_names); - if let Some((span, ident)) = inexistent_fields.last() { - err.span_label(*span, + if let Some(ident) = inexistent_fields.last() { + err.span_label(ident.span, format!("{} `{}` does not have {} field{}", kind_name, tcx.item_path_str(variant.did), @@ -1016,8 +1016,8 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); find_best_match_for_name(input, &ident.as_str(), None); if let Some(suggested_name) = suggested_name { err.span_suggestion( - *span, - "did you mean", + ident.span, + "a field with a similar name exists", suggested_name.to_string(), Applicability::MaybeIncorrect, ); diff --git a/src/test/ui/issues/issue-17800.stderr b/src/test/ui/issues/issue-17800.stderr index b4234245bfb38..6efc7f0c06e11 100644 --- a/src/test/ui/issues/issue-17800.stderr +++ b/src/test/ui/issues/issue-17800.stderr @@ -2,10 +2,10 @@ error[E0026]: variant `MyOption::MySome` does not have a field named `x` --> $DIR/issue-17800.rs:8:28 | LL | MyOption::MySome { x: 42 } => (), - | ^^^^^ + | ^ | | | variant `MyOption::MySome` does not have this field - | help: did you mean: `0` + | help: a field with a similar name exists: `0` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-51102.stderr b/src/test/ui/issues/issue-51102.stderr index 1b2948db2d6c3..4d4b977374ef9 100644 --- a/src/test/ui/issues/issue-51102.stderr +++ b/src/test/ui/issues/issue-51102.stderr @@ -2,7 +2,7 @@ error[E0026]: struct `SimpleStruct` does not have a field named `state` --> $DIR/issue-51102.rs:13:17 | LL | state: 0, - | ^^^^^^^^ struct `SimpleStruct` does not have this field + | ^^^^^ struct `SimpleStruct` does not have this field error[E0025]: field `no_state_here` bound multiple times in the pattern --> $DIR/issue-51102.rs:24:17 @@ -16,7 +16,7 @@ error[E0026]: variant `SimpleEnum::NoState` does not have a field named `state` --> $DIR/issue-51102.rs:33:17 | LL | state: 0 - | ^^^^^^^^ variant `SimpleEnum::NoState` does not have this field + | ^^^^^ variant `SimpleEnum::NoState` does not have this field error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-52717.stderr b/src/test/ui/issues/issue-52717.stderr index 408819813b075..468cdf2dcf921 100644 --- a/src/test/ui/issues/issue-52717.stderr +++ b/src/test/ui/issues/issue-52717.stderr @@ -5,7 +5,7 @@ LL | A::A { fob } => { println!("{}", fob); } | ^^^ | | | variant `A::A` does not have this field - | help: did you mean: `foo` + | help: a field with a similar name exists: `foo` error: aborting due to previous error diff --git a/src/test/ui/numeric/numeric-fields.stderr b/src/test/ui/numeric/numeric-fields.stderr index 1a2ad4a0c0945..ce51bbaa114fd 100644 --- a/src/test/ui/numeric/numeric-fields.stderr +++ b/src/test/ui/numeric/numeric-fields.stderr @@ -10,7 +10,7 @@ error[E0026]: struct `S` does not have a field named `0x1` --> $DIR/numeric-fields.rs:7:17 | LL | S{0: a, 0x1: b, ..} => {} - | ^^^^^^ struct `S` does not have this field + | ^^^ struct `S` does not have this field error: aborting due to 2 previous errors diff --git a/src/test/ui/structs/struct-field-cfg.stderr b/src/test/ui/structs/struct-field-cfg.stderr index c8c624d548b67..565866a682ada 100644 --- a/src/test/ui/structs/struct-field-cfg.stderr +++ b/src/test/ui/structs/struct-field-cfg.stderr @@ -22,7 +22,7 @@ error[E0026]: struct `Foo` does not have a field named `absent` --> $DIR/struct-field-cfg.rs:16:42 | LL | let Foo { present: (), #[cfg(all())] absent: () } = foo; - | ^^^^^^^^^^ struct `Foo` does not have this field + | ^^^^^^ struct `Foo` does not have this field error: aborting due to 4 previous errors From 498beaddf42092f91df3bc9a0af9a80489b2a38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 16:20:15 -0700 Subject: [PATCH 14/24] Tweak spans for E0599 --- src/librustc_typeck/check/method/suggest.rs | 35 +++++++++++-------- .../associated-const-no-item.stderr | 4 +-- src/test/ui/bogus-tag.stderr | 2 +- src/test/ui/did_you_mean/bad-assoc-pat.stderr | 16 +++------ .../dont-suggest-private-trait-method.stderr | 4 +-- .../ui/empty/empty-struct-braces-expr.stderr | 16 ++++----- src/test/ui/error-codes/E0599.stderr | 2 +- .../ui/invalid/invalid-path-in-const.stderr | 4 +-- src/test/ui/issues/issue-22933-2.stderr | 4 +-- src/test/ui/issues/issue-22933-3.stderr | 4 +-- src/test/ui/issues/issue-23173.stderr | 16 +++------ src/test/ui/issues/issue-23217.stderr | 8 ++--- src/test/ui/issues/issue-28344.stderr | 16 ++++----- src/test/ui/issues/issue-28586.stderr | 4 +-- src/test/ui/issues/issue-28971.stderr | 8 ++--- src/test/ui/issues/issue-30123.stderr | 4 +-- src/test/ui/issues/issue-38919.stderr | 4 +-- src/test/ui/issues/issue-39559.stderr | 4 +-- src/test/ui/issues/issue-3973.stderr | 4 +-- src/test/ui/issues/issue-42880.stderr | 2 +- src/test/ui/issues/issue-57362-2.stderr | 4 +-- src/test/ui/issues/issue-7950.stderr | 4 +-- src/test/ui/lexical-scopes.stderr | 4 +-- .../no-double-error.stderr | 4 +-- .../rust-2018/trait-import-suggestions.stderr | 4 +-- src/test/ui/traits/trait-item-privacy.stderr | 16 +++------ .../ui/ufcs/ufcs-partially-resolved.stderr | 8 ++--- .../ui/unspecified-self-in-trait-ref.stderr | 16 +++------ 28 files changed, 81 insertions(+), 140 deletions(-) diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index b4a1a2d76c262..cfee7d0c20c4f 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -60,20 +60,26 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - pub fn report_method_error<'b>(&self, - span: Span, - rcvr_ty: Ty<'tcx>, - item_name: ast::Ident, - source: SelfSource<'b>, - error: MethodError<'tcx>, - args: Option<&'gcx [hir::Expr]>) { + pub fn report_method_error<'b>( + &self, + span: Span, + rcvr_ty: Ty<'tcx>, + item_name: ast::Ident, + source: SelfSource<'b>, + error: MethodError<'tcx>, + args: Option<&'gcx [hir::Expr]>, + ) { + let mut span = span; // Avoid suggestions when we don't know what's going on. if rcvr_ty.references_error() { return; } - let report_candidates = |err: &mut DiagnosticBuilder<'_>, - mut sources: Vec| { + let report_candidates = | + span: Span, + err: &mut DiagnosticBuilder<'_>, + mut sources: Vec, + | { sources.sort(); sources.dedup(); // Dynamic limit to avoid hiding just one candidate, which is silly. @@ -291,9 +297,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err.emit(); return; } else { + span = item_name.span; let mut err = struct_span_err!( tcx.sess, - item_name.span, + span, E0599, "no {} named `{}` found for type `{}` in the current scope", item_kind, @@ -303,7 +310,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if let Some(suggestion) = suggestion { // enum variant err.span_suggestion( - item_name.span, + span, "did you mean", suggestion.to_string(), Applicability::MaybeIncorrect, @@ -414,9 +421,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.ty_to_string(actual), item_name)); } - report_candidates(&mut err, static_sources); + report_candidates(span, &mut err, static_sources); } else if static_sources.len() > 1 { - report_candidates(&mut err, static_sources); + report_candidates(span, &mut err, static_sources); } if !unsatisfied_predicates.is_empty() { @@ -461,7 +468,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "multiple applicable items in scope"); err.span_label(span, format!("multiple `{}` found", item_name)); - report_candidates(&mut err, sources); + report_candidates(span, &mut err, sources); err.emit(); } diff --git a/src/test/ui/associated-const/associated-const-no-item.stderr b/src/test/ui/associated-const/associated-const-no-item.stderr index de172049872f5..d96cf67b87578 100644 --- a/src/test/ui/associated-const/associated-const-no-item.stderr +++ b/src/test/ui/associated-const/associated-const-no-item.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `ID` found for type `i32` in the current --> $DIR/associated-const-no-item.rs:5:23 | LL | const X: i32 = ::ID; - | -------^^ - | | - | associated item not found in `i32` + | ^^ associated item not found in `i32` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `ID`, perhaps you need to implement it: diff --git a/src/test/ui/bogus-tag.stderr b/src/test/ui/bogus-tag.stderr index 3750df841720c..0bf0d4b14ee91 100644 --- a/src/test/ui/bogus-tag.stderr +++ b/src/test/ui/bogus-tag.stderr @@ -5,7 +5,7 @@ LL | enum Color { Rgb(isize, isize, isize), Rgba(isize, isize, isize, isize), } | ---------- variant `Hsl` not found here ... LL | Color::Hsl(h, s, l) => { println!("hsl"); } - | -------^^^--------- variant not found in `Color` + | ^^^ variant not found in `Color` error: aborting due to previous error diff --git a/src/test/ui/did_you_mean/bad-assoc-pat.stderr b/src/test/ui/did_you_mean/bad-assoc-pat.stderr index 92fd9f26777f1..5d407a5ee8acf 100644 --- a/src/test/ui/did_you_mean/bad-assoc-pat.stderr +++ b/src/test/ui/did_you_mean/bad-assoc-pat.stderr @@ -26,33 +26,25 @@ error[E0599]: no associated item named `AssocItem` found for type `[u8]` in the --> $DIR/bad-assoc-pat.rs:3:15 | LL | [u8]::AssocItem => {} - | ------^^^^^^^^^ - | | - | associated item not found in `[u8]` + | ^^^^^^^^^ associated item not found in `[u8]` error[E0599]: no associated item named `AssocItem` found for type `(u8, u8)` in the current scope --> $DIR/bad-assoc-pat.rs:6:19 | LL | (u8, u8)::AssocItem => {} - | ----------^^^^^^^^^ - | | - | associated item not found in `(u8, u8)` + | ^^^^^^^^^ associated item not found in `(u8, u8)` error[E0599]: no associated item named `AssocItem` found for type `_` in the current scope --> $DIR/bad-assoc-pat.rs:9:12 | LL | _::AssocItem => {} - | ---^^^^^^^^^ - | | - | associated item not found in `_` + | ^^^^^^^^^ associated item not found in `_` error[E0599]: no associated item named `AssocItem` found for type `(u8,)` in the current scope --> $DIR/bad-assoc-pat.rs:14:17 | LL | &(u8,)::AssocItem => {} - | -------^^^^^^^^^ - | | - | associated item not found in `(u8,)` + | ^^^^^^^^^ associated item not found in `(u8,)` error: aborting due to 8 previous errors diff --git a/src/test/ui/dont-suggest-private-trait-method.stderr b/src/test/ui/dont-suggest-private-trait-method.stderr index af4253779a4f5..5189ffa62d1ba 100644 --- a/src/test/ui/dont-suggest-private-trait-method.stderr +++ b/src/test/ui/dont-suggest-private-trait-method.stderr @@ -5,9 +5,7 @@ LL | struct T; | --------- function or associated item `new` not found for this ... LL | T::new(); - | ---^^^ - | | - | function or associated item not found in `T` + | ^^^ function or associated item not found in `T` error: aborting due to previous error diff --git a/src/test/ui/empty/empty-struct-braces-expr.stderr b/src/test/ui/empty/empty-struct-braces-expr.stderr index a20d79982493e..57c8c1c85dd41 100644 --- a/src/test/ui/empty/empty-struct-braces-expr.stderr +++ b/src/test/ui/empty/empty-struct-braces-expr.stderr @@ -50,19 +50,19 @@ error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the --> $DIR/empty-struct-braces-expr.rs:22:19 | LL | let xe3 = XE::Empty3; - | ----^^^^^^ - | | | - | | help: did you mean: `XEmpty3` - | variant not found in `empty_struct::XE` + | ^^^^^^ + | | + | variant not found in `empty_struct::XE` + | help: did you mean: `XEmpty3` error[E0599]: no variant named `Empty3` found for type `empty_struct::XE` in the current scope --> $DIR/empty-struct-braces-expr.rs:23:19 | LL | let xe3 = XE::Empty3(); - | ----^^^^^^ - | | | - | | help: did you mean: `XEmpty3` - | variant not found in `empty_struct::XE` + | ^^^^^^ + | | + | variant not found in `empty_struct::XE` + | help: did you mean: `XEmpty3` error: aborting due to 8 previous errors diff --git a/src/test/ui/error-codes/E0599.stderr b/src/test/ui/error-codes/E0599.stderr index 6fb53e727630f..89bfccf2fbc56 100644 --- a/src/test/ui/error-codes/E0599.stderr +++ b/src/test/ui/error-codes/E0599.stderr @@ -5,7 +5,7 @@ LL | struct Foo; | ----------- associated item `NotEvenReal` not found for this ... LL | || if let Foo::NotEvenReal() = Foo {}; - | -----^^^^^^^^^^^-- associated item not found in `Foo` + | ^^^^^^^^^^^ associated item not found in `Foo` error: aborting due to previous error diff --git a/src/test/ui/invalid/invalid-path-in-const.stderr b/src/test/ui/invalid/invalid-path-in-const.stderr index 13176b8b8fb15..a14ab7d85e851 100644 --- a/src/test/ui/invalid/invalid-path-in-const.stderr +++ b/src/test/ui/invalid/invalid-path-in-const.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `DOESNOTEXIST` found for type `u32` in th --> $DIR/invalid-path-in-const.rs:2:23 | LL | fn f(a: [u8; u32::DOESNOTEXIST]) {} - | -----^^^^^^^^^^^^ - | | - | associated item not found in `u32` + | ^^^^^^^^^^^^ associated item not found in `u32` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22933-2.stderr b/src/test/ui/issues/issue-22933-2.stderr index 97962adc2d286..23b1474bde704 100644 --- a/src/test/ui/issues/issue-22933-2.stderr +++ b/src/test/ui/issues/issue-22933-2.stderr @@ -5,9 +5,7 @@ LL | enum Delicious { | -------------- variant `PIE` not found here ... LL | ApplePie = Delicious::Apple as isize | Delicious::PIE as isize, - | -----------^^^ - | | - | variant not found in `Delicious` + | ^^^ variant not found in `Delicious` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22933-3.stderr b/src/test/ui/issues/issue-22933-3.stderr index aa0052f97013e..b1afda6d15114 100644 --- a/src/test/ui/issues/issue-22933-3.stderr +++ b/src/test/ui/issues/issue-22933-3.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `MIN` found for type `u8` in the current --> $DIR/issue-22933-3.rs:1:22 | LL | const FOO: [u32; u8::MIN as usize] = []; - | ----^^^ - | | - | associated item not found in `u8` + | ^^^ associated item not found in `u8` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23173.stderr b/src/test/ui/issues/issue-23173.stderr index 98c4f867ad6a0..75dba883608e9 100644 --- a/src/test/ui/issues/issue-23173.stderr +++ b/src/test/ui/issues/issue-23173.stderr @@ -5,9 +5,7 @@ LL | enum Token { LeftParen, RightParen, Plus, Minus, /* etc */ } | ---------- variant `Homura` not found here ... LL | use_token(&Token::Homura); - | -------^^^^^^ - | | - | variant not found in `Token` + | ^^^^^^ variant not found in `Token` error[E0599]: no function or associated item named `method` found for type `Struct` in the current scope --> $DIR/issue-23173.rs:11:13 @@ -16,9 +14,7 @@ LL | struct Struct { | ------------- function or associated item `method` not found for this ... LL | Struct::method(); - | --------^^^^^^ - | | - | function or associated item not found in `Struct` + | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no function or associated item named `method` found for type `Struct` in the current scope --> $DIR/issue-23173.rs:13:13 @@ -27,9 +23,7 @@ LL | struct Struct { | ------------- function or associated item `method` not found for this ... LL | Struct::method; - | --------^^^^^^ - | | - | function or associated item not found in `Struct` + | ^^^^^^ function or associated item not found in `Struct` error[E0599]: no associated item named `Assoc` found for type `Struct` in the current scope --> $DIR/issue-23173.rs:15:13 @@ -38,9 +32,7 @@ LL | struct Struct { | ------------- associated item `Assoc` not found for this ... LL | Struct::Assoc; - | --------^^^^^ - | | - | associated item not found in `Struct` + | ^^^^^ associated item not found in `Struct` error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-23217.stderr b/src/test/ui/issues/issue-23217.stderr index 9cad002036fff..2a982422cab9c 100644 --- a/src/test/ui/issues/issue-23217.stderr +++ b/src/test/ui/issues/issue-23217.stderr @@ -4,10 +4,10 @@ error[E0599]: no variant named `A` found for type `SomeEnum` in the current scop LL | pub enum SomeEnum { | ----------------- variant `A` not found here LL | B = SomeEnum::A, - | ----------^ - | | | - | | help: did you mean: `B` - | variant not found in `SomeEnum` + | ^ + | | + | variant not found in `SomeEnum` + | help: did you mean: `B` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-28344.stderr b/src/test/ui/issues/issue-28344.stderr index b6f520c644b32..fcd98b111cfc5 100644 --- a/src/test/ui/issues/issue-28344.stderr +++ b/src/test/ui/issues/issue-28344.stderr @@ -8,10 +8,10 @@ error[E0599]: no function or associated item named `bitor` found for type `dyn s --> $DIR/issue-28344.rs:4:25 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); - | --------^^^^^ - | | - | function or associated item not found in `dyn std::ops::BitXor<_>` - | help: did you mean: `bitxor` + | ^^^^^ + | | + | function or associated item not found in `dyn std::ops::BitXor<_>` + | help: did you mean: `bitxor` error[E0191]: the value of the associated type `Output` (from the trait `std::ops::BitXor`) must be specified --> $DIR/issue-28344.rs:8:13 @@ -23,10 +23,10 @@ error[E0599]: no function or associated item named `bitor` found for type `dyn s --> $DIR/issue-28344.rs:8:21 | LL | let g = BitXor::bitor; - | --------^^^^^ - | | - | function or associated item not found in `dyn std::ops::BitXor<_>` - | help: did you mean: `bitxor` + | ^^^^^ + | | + | function or associated item not found in `dyn std::ops::BitXor<_>` + | help: did you mean: `bitxor` error: aborting due to 4 previous errors diff --git a/src/test/ui/issues/issue-28586.stderr b/src/test/ui/issues/issue-28586.stderr index eccb474c15eb6..d19c4af2df7c9 100644 --- a/src/test/ui/issues/issue-28586.stderr +++ b/src/test/ui/issues/issue-28586.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `BYTES` found for type `usize` in the cur --> $DIR/issue-28586.rs:4:26 | LL | impl Foo for [u8; usize::BYTES] {} - | -------^^^^^ - | | - | associated item not found in `usize` + | ^^^^^ associated item not found in `usize` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-28971.stderr b/src/test/ui/issues/issue-28971.stderr index 77d0b53ad216b..4781f7abe8116 100644 --- a/src/test/ui/issues/issue-28971.stderr +++ b/src/test/ui/issues/issue-28971.stderr @@ -5,10 +5,10 @@ LL | enum Foo { | -------- variant `Baz` not found here ... LL | Foo::Baz(..) => (), - | -----^^^---- - | | | - | | help: did you mean: `Bar` - | variant not found in `Foo` + | ^^^ + | | + | variant not found in `Foo` + | help: did you mean: `Bar` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-30123.stderr b/src/test/ui/issues/issue-30123.stderr index 555bdb1236fe6..32bbd4d03d6d7 100644 --- a/src/test/ui/issues/issue-30123.stderr +++ b/src/test/ui/issues/issue-30123.stderr @@ -2,9 +2,7 @@ error[E0599]: no function or associated item named `new_undirected` found for ty --> $DIR/issue-30123.rs:7:33 | LL | let ug = Graph::::new_undirected(); - | -------------------^^^^^^^^^^^^^^ - | | - | function or associated item not found in `issue_30123_aux::Graph` + | ^^^^^^^^^^^^^^ function or associated item not found in `issue_30123_aux::Graph` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38919.stderr b/src/test/ui/issues/issue-38919.stderr index d23a4dfd0a496..603d42ca35e0b 100644 --- a/src/test/ui/issues/issue-38919.stderr +++ b/src/test/ui/issues/issue-38919.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `Item` found for type `T` in the current --> $DIR/issue-38919.rs:2:8 | LL | T::Item; - | ---^^^^ - | | - | associated item not found in `T` + | ^^^^ associated item not found in `T` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-39559.stderr b/src/test/ui/issues/issue-39559.stderr index e851e79faee06..aded0c2de45e4 100644 --- a/src/test/ui/issues/issue-39559.stderr +++ b/src/test/ui/issues/issue-39559.stderr @@ -2,9 +2,7 @@ error[E0599]: no function or associated item named `dim` found for type `D` in t --> $DIR/issue-39559.rs:14:21 | LL | entries: [T; D::dim()], - | ---^^^ - | | - | function or associated item not found in `D` + | ^^^ function or associated item not found in `D` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `dim`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-3973.stderr b/src/test/ui/issues/issue-3973.stderr index 2ece4c396067c..576da4bcd31c8 100644 --- a/src/test/ui/issues/issue-3973.stderr +++ b/src/test/ui/issues/issue-3973.stderr @@ -14,9 +14,7 @@ LL | struct Point { | ------------ function or associated item `new` not found for this ... LL | let p = Point::new(0.0, 0.0); - | -------^^^ - | | - | function or associated item not found in `Point` + | ^^^ function or associated item not found in `Point` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-42880.stderr b/src/test/ui/issues/issue-42880.stderr index 8a40a49c0def5..763bb9ae0ea9c 100644 --- a/src/test/ui/issues/issue-42880.stderr +++ b/src/test/ui/issues/issue-42880.stderr @@ -2,7 +2,7 @@ error[E0599]: no associated item named `String` found for type `std::string::Str --> $DIR/issue-42880.rs:4:22 | LL | let f = |&Value::String(_)| (); - | -------^^^^^^--- associated item not found in `std::string::String` + | ^^^^^^ associated item not found in `std::string::String` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-57362-2.stderr b/src/test/ui/issues/issue-57362-2.stderr index 522b201ec78cd..2e713cc0ab508 100644 --- a/src/test/ui/issues/issue-57362-2.stderr +++ b/src/test/ui/issues/issue-57362-2.stderr @@ -2,9 +2,7 @@ error[E0599]: no function or associated item named `make_g` found for type `for< --> $DIR/issue-57362-2.rs:22:25 | LL | let x = ::make_g(); - | ------------^^^^^^ - | | - | function or associated item not found in `for<'r> fn(&'r ())` + | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `make_g`, perhaps you need to implement it: diff --git a/src/test/ui/issues/issue-7950.stderr b/src/test/ui/issues/issue-7950.stderr index e30f04753762e..bbeab405e2935 100644 --- a/src/test/ui/issues/issue-7950.stderr +++ b/src/test/ui/issues/issue-7950.stderr @@ -5,9 +5,7 @@ LL | struct Foo; | ----------- function or associated item `bar` not found for this ... LL | Foo::bar(); - | -----^^^ - | | - | function or associated item not found in `Foo` + | ^^^ function or associated item not found in `Foo` error: aborting due to previous error diff --git a/src/test/ui/lexical-scopes.stderr b/src/test/ui/lexical-scopes.stderr index fb823ebde2edb..859eb04749f23 100644 --- a/src/test/ui/lexical-scopes.stderr +++ b/src/test/ui/lexical-scopes.stderr @@ -12,9 +12,7 @@ error[E0599]: no function or associated item named `f` found for type `Foo` in t --> $DIR/lexical-scopes.rs:10:10 | LL | Foo::f(); - | -----^ - | | - | function or associated item not found in `Foo` + | ^ function or associated item not found in `Foo` error: aborting due to 2 previous errors diff --git a/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr b/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr index 1bf9b09fcc5ef..c672acee040b6 100644 --- a/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr +++ b/src/test/ui/rfc-2005-default-binding-mode/no-double-error.stderr @@ -2,9 +2,7 @@ error[E0599]: no associated item named `XXX` found for type `u32` in the current --> $DIR/no-double-error.rs:8:14 | LL | u32::XXX => { } - | -----^^^ - | | - | associated item not found in `u32` + | ^^^ associated item not found in `u32` error: aborting due to previous error diff --git a/src/test/ui/rust-2018/trait-import-suggestions.stderr b/src/test/ui/rust-2018/trait-import-suggestions.stderr index e2ffeaee4b423..a81181228dfda 100644 --- a/src/test/ui/rust-2018/trait-import-suggestions.stderr +++ b/src/test/ui/rust-2018/trait-import-suggestions.stderr @@ -30,9 +30,7 @@ error[E0599]: no function or associated item named `from_str` found for type `u3 --> $DIR/trait-import-suggestions.rs:30:18 | LL | let y = u32::from_str("33"); - | -----^^^^^^^^ - | | - | function or associated item not found in `u32` + | ^^^^^^^^ function or associated item not found in `u32` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/traits/trait-item-privacy.stderr b/src/test/ui/traits/trait-item-privacy.stderr index 97e7ed0ebb071..3bf5309ee7d0c 100644 --- a/src/test/ui/traits/trait-item-privacy.stderr +++ b/src/test/ui/traits/trait-item-privacy.stderr @@ -39,9 +39,7 @@ LL | struct S; | --------- function or associated item `a` not found for this ... LL | S::a(&S); - | ---^ - | | - | function or associated item not found in `S` + | ^ function or associated item not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `a`, perhaps you need to implement it: @@ -54,9 +52,7 @@ LL | struct S; | --------- function or associated item `b` not found for this ... LL | S::b(&S); - | ---^ - | | - | function or associated item not found in `S` + | ^ function or associated item not found in `S` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: @@ -77,9 +73,7 @@ LL | struct S; | --------- associated item `A` not found for this ... LL | S::A; - | ---^ - | | - | associated item not found in `S` + | ^ associated item not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `A`, perhaps you need to implement it: @@ -92,9 +86,7 @@ LL | struct S; | --------- associated item `B` not found for this ... LL | S::B; - | ---^ - | | - | associated item not found in `S` + | ^ associated item not found in `S` | = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope, perhaps add a `use` for it: diff --git a/src/test/ui/ufcs/ufcs-partially-resolved.stderr b/src/test/ui/ufcs/ufcs-partially-resolved.stderr index 799dbf7a6d20f..900c729721104 100644 --- a/src/test/ui/ufcs/ufcs-partially-resolved.stderr +++ b/src/test/ui/ufcs/ufcs-partially-resolved.stderr @@ -190,17 +190,13 @@ error[E0599]: no associated item named `NN` found for type `::Y` in th --> $DIR/ufcs-partially-resolved.rs:38:20 | LL | ::Y::NN; - | ---------------^^ - | | - | associated item not found in `::Y` + | ^^ associated item not found in `::Y` error[E0599]: no associated item named `N` found for type `::X` in the current scope --> $DIR/ufcs-partially-resolved.rs:55:20 | LL | ::X::N; - | ---------------^ - | | - | associated item not found in `::X` + | ^ associated item not found in `::X` error: aborting due to 32 previous errors diff --git a/src/test/ui/unspecified-self-in-trait-ref.stderr b/src/test/ui/unspecified-self-in-trait-ref.stderr index b295b39d33c1d..f894cd36a4f90 100644 --- a/src/test/ui/unspecified-self-in-trait-ref.stderr +++ b/src/test/ui/unspecified-self-in-trait-ref.stderr @@ -2,33 +2,25 @@ error[E0599]: no function or associated item named `lol` found for type `dyn Foo --> $DIR/unspecified-self-in-trait-ref.rs:10:18 | LL | let a = Foo::lol(); - | -----^^^ - | | - | function or associated item not found in `dyn Foo<_>` + | ^^^ function or associated item not found in `dyn Foo<_>` error[E0599]: no function or associated item named `lol` found for type `dyn Foo<_>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:12:23 | LL | let b = Foo::<_>::lol(); - | ----------^^^ - | | - | function or associated item not found in `dyn Foo<_>` + | ^^^ function or associated item not found in `dyn Foo<_>` error[E0599]: no function or associated item named `lol` found for type `dyn Bar<_, _>` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:14:18 | LL | let c = Bar::lol(); - | -----^^^ - | | - | function or associated item not found in `dyn Bar<_, _>` + | ^^^ function or associated item not found in `dyn Bar<_, _>` error[E0599]: no function or associated item named `lol` found for type `dyn Bar` in the current scope --> $DIR/unspecified-self-in-trait-ref.rs:16:30 | LL | let d = Bar::::lol(); - | -----------------^^^ - | | - | function or associated item not found in `dyn Bar` + | ^^^ function or associated item not found in `dyn Bar` error[E0393]: the type parameter `A` must be explicitly specified --> $DIR/unspecified-self-in-trait-ref.rs:18:13 From 713f96d53d2671136bef8f1123fbf0b91c2bdaef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 17:28:52 -0700 Subject: [PATCH 15/24] Swap const evaluation lint spans to point at problem in primary span --- src/librustc/mir/interpret/error.rs | 11 ++ src/librustc_mir/const_eval.rs | 2 + src/librustc_mir/transform/const_prop.rs | 1 + src/test/ui/array_const_index-0.stderr | 4 +- src/test/ui/array_const_index-1.stderr | 4 +- src/test/ui/consts/const-err-early.stderr | 20 +-- src/test/ui/consts/const-err-multi.stderr | 16 +- src/test/ui/consts/const-err.stderr | 4 +- .../conditional_array_execution.stderr | 4 +- .../consts/const-eval/const-eval-overflow2.rs | 24 ++- .../const-eval/const-eval-overflow2.stderr | 48 +++--- .../const-eval/const-eval-overflow2b.rs | 24 ++- .../const-eval/const-eval-overflow2b.stderr | 48 +++--- .../const-eval/const-eval-overflow2c.rs | 24 ++- .../const-eval/const-eval-overflow2c.stderr | 48 +++--- ...nst-pointer-values-in-various-types.stderr | 80 ++++----- .../ui/consts/const-eval/const_panic.stderr | 12 +- .../const-eval/const_panic_libcore.stderr | 12 +- .../const_panic_libcore_main.stderr | 12 +- .../const-eval/const_raw_ptr_ops.stderr | 16 +- .../ui/consts/const-eval/issue-43197.stderr | 8 +- .../ui/consts/const-eval/issue-49296.stderr | 4 +- .../ui/consts/const-eval/issue-50814-2.stderr | 4 +- .../ui/consts/const-eval/issue-50814.stderr | 4 +- .../consts/const-eval/promoted_errors.stderr | 8 +- .../ui/consts/const-eval/pub_const_err.stderr | 4 +- .../const-eval/pub_const_err_bin.stderr | 4 +- .../const-eval/unused-broken-const.stderr | 4 +- src/test/ui/consts/const-int-unchecked.stderr | 160 +++++++++--------- .../const-len-underflow-separate-spans.stderr | 4 +- src/test/ui/consts/const-slice-oob.stderr | 4 +- .../ui/consts/dangling-alloc-id-ice.stderr | 16 +- src/test/ui/consts/dangling_raw_ptr.stderr | 16 +- src/test/ui/error-codes/E0396-fixed.stderr | 4 +- src/test/ui/issues/issue-43105.stderr | 4 +- 35 files changed, 358 insertions(+), 304 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 819c65e250326..5cd1ced20220a 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -100,6 +100,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { tcx: TyCtxtAt<'a, 'gcx, 'tcx>, message: &str, lint_root: hir::HirId, + span: Option, ) -> ErrorHandled { let lint = self.struct_generic( tcx, @@ -108,6 +109,16 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { ); match lint { Ok(mut lint) => { + if let Some(span) = span { + let primary_spans = lint.span.primary_spans().to_vec(); + // point at the actual error as the primary span + lint.replace_span_with(span); + // point to the `const` statement as a secondary span + // they don't have any label + for sp in primary_spans { + lint.span_label(sp, ""); + } + } lint.emit(); ErrorHandled::Reported }, diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 71d9398c686b7..63ea1ece70c16 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -668,6 +668,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.at(tcx.def_span(def_id)), "any use of this value will cause an error", hir_id, + Some(err.span), ) }, // promoting runtime code is only allowed to error if it references broken constants @@ -684,6 +685,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.at(span), "reaching this expression at runtime will panic or abort", tcx.hir().as_local_hir_id(def_id).unwrap(), + Some(err.span), ) } // anything else (array lengths, enum initializers, constant patterns) are reported diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 23d8138efccaf..c546520e554ef 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -237,6 +237,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> { self.ecx.tcx, "this expression will panic at runtime", lint_root, + None, ); } } diff --git a/src/test/ui/array_const_index-0.stderr b/src/test/ui/array_const_index-0.stderr index dfc89e0ae86ad..78d456d6c2e0e 100644 --- a/src/test/ui/array_const_index-0.stderr +++ b/src/test/ui/array_const_index-0.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/array_const_index-0.rs:2:1 + --> $DIR/array_const_index-0.rs:2:16 | LL | const B: i32 = (&A)[1]; - | ^^^^^^^^^^^^^^^-------^ + | ---------------^^^^^^^- | | | index out of bounds: the len is 0 but the index is 1 | diff --git a/src/test/ui/array_const_index-1.stderr b/src/test/ui/array_const_index-1.stderr index 3e912fad53a5f..3e7360f935bb9 100644 --- a/src/test/ui/array_const_index-1.stderr +++ b/src/test/ui/array_const_index-1.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/array_const_index-1.rs:2:1 + --> $DIR/array_const_index-1.rs:2:16 | LL | const B: i32 = A[1]; - | ^^^^^^^^^^^^^^^----^ + | ---------------^^^^- | | | index out of bounds: the len is 0 but the index is 1 | diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index a61f9b303aa15..9b0ef94a5b8c3 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-err-early.rs:3:1 + --> $DIR/const-err-early.rs:3:19 | LL | pub const A: i8 = -std::i8::MIN; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to negate with overflow | @@ -13,34 +13,34 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-early.rs:4:1 + --> $DIR/const-err-early.rs:4:19 | LL | pub const B: u8 = 200u8 + 200u8; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to add with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:5:1 + --> $DIR/const-err-early.rs:5:19 | LL | pub const C: u8 = 200u8 * 4; - | ^^^^^^^^^^^^^^^^^^---------^ + | ------------------^^^^^^^^^- | | | attempt to multiply with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:6:1 + --> $DIR/const-err-early.rs:6:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^^-----------------^ + | ------------------^^^^^^^^^^^^^^^^^- | | | attempt to subtract with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:7:1 + --> $DIR/const-err-early.rs:7:19 | LL | pub const E: u8 = [5u8][1]; - | ^^^^^^^^^^^^^^^^^^--------^ + | ------------------^^^^^^^^- | | | index out of bounds: the len is 1 but the index is 1 diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index af62665c056b0..c647f13fc7520 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:3:1 + --> $DIR/const-err-multi.rs:3:19 | LL | pub const A: i8 = -std::i8::MIN; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to negate with overflow | @@ -13,26 +13,26 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:5:1 + --> $DIR/const-err-multi.rs:5:19 | LL | pub const B: i8 = A; - | ^^^^^^^^^^^^^^^^^^-^ + | ------------------^- | | | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:7:1 + --> $DIR/const-err-multi.rs:7:19 | LL | pub const C: u8 = A as u8; - | ^^^^^^^^^^^^^^^^^^-------^ + | ------------------^^^^^^^- | | | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:9:1 + --> $DIR/const-err-multi.rs:9:19 | LL | pub const D: i8 = 50 - A; - | ^^^^^^^^^^^^^^^^^^------^ + | ------------------^^^^^^- | | | referenced constant has errors diff --git a/src/test/ui/consts/const-err.stderr b/src/test/ui/consts/const-err.stderr index 082494b43c25b..0ee9ecdef451d 100644 --- a/src/test/ui/consts/const-err.stderr +++ b/src/test/ui/consts/const-err.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/const-err.rs:10:1 + --> $DIR/const-err.rs:10:17 | LL | const FOO: u8 = [5u8][1]; - | ^^^^^^^^^^^^^^^^--------^ + | ----------------^^^^^^^^- | | | index out of bounds: the len is 1 but the index is 1 | diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr index 7722c7423fc87..7f94d849c006c 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/conditional_array_execution.rs:5:1 + --> $DIR/conditional_array_execution.rs:5:19 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ------------------^^^^^--------------------------- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs index 4700c63adbcb3..a0dbcc88cea8a 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -11,43 +11,51 @@ use std::fmt; use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr index 44ee8b336c89c..419b3d52dbff1 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:14:1 + --> $DIR/const-eval-overflow2.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MIN - 1, - | | ----------- attempt to subtract with overflow + | | ^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:19:1 + --> $DIR/const-eval-overflow2.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:24:1 + --> $DIR/const-eval-overflow2.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:29:1 + --> $DIR/const-eval-overflow2.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:34:1 + --> $DIR/const-eval-overflow2.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MIN - 1, - | | ----------- attempt to subtract with overflow + | | ^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:39:1 + --> $DIR/const-eval-overflow2.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:43:1 + --> $DIR/const-eval-overflow2.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:47:1 + --> $DIR/const-eval-overflow2.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs index 6bed90aa8ea65..da883671a60a3 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -11,43 +11,51 @@ use std::fmt; use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr index 69e165bef4a7a..2cfd34c9fc3c7 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:14:1 + --> $DIR/const-eval-overflow2b.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MAX + 1, - | | ----------- attempt to add with overflow + | | ^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2b.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:19:1 + --> $DIR/const-eval-overflow2b.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:24:1 + --> $DIR/const-eval-overflow2b.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:29:1 + --> $DIR/const-eval-overflow2b.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:34:1 + --> $DIR/const-eval-overflow2b.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MAX + 1, - | | ----------- attempt to add with overflow + | | ^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:39:1 + --> $DIR/const-eval-overflow2b.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:43:1 + --> $DIR/const-eval-overflow2b.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:47:1 + --> $DIR/const-eval-overflow2b.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs index 108251e4bd281..e87344405a103 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -11,43 +11,51 @@ use std::fmt; use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr index ba606f6d09de5..5e63286c594d9 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:14:1 + --> $DIR/const-eval-overflow2c.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MIN * 2, - | | ----------- attempt to multiply with overflow + | | ^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2c.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:19:1 + --> $DIR/const-eval-overflow2c.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:24:1 + --> $DIR/const-eval-overflow2c.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:29:1 + --> $DIR/const-eval-overflow2c.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:34:1 + --> $DIR/const-eval-overflow2c.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MAX * 2, - | | ----------- attempt to multiply with overflow + | | ^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:39:1 + --> $DIR/const-eval-overflow2c.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:43:1 + --> $DIR/const-eval-overflow2c.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:47:1 + --> $DIR/const-eval-overflow2c.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr index 786338222e3ba..284b06984a31c 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr @@ -7,28 +7,28 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 } = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:27:5 + --> $DIR/const-pointer-values-in-various-types.rs:27:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:30:5 + --> $DIR/const-pointer-values-in-various-types.rs:30:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:33:5 + --> $DIR/const-pointer-values-in-various-types.rs:33:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -49,26 +49,26 @@ LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.u = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:42:5 + --> $DIR/const-pointer-values-in-various-types.rs:42:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:45:5 + --> $DIR/const-pointer-values-in-various-types.rs:45:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:48:5 + --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -89,10 +89,10 @@ LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.i = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:57:5 + --> $DIR/const-pointer-values-in-various-types.rs:57:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -105,42 +105,42 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:63:5 + --> $DIR/const-pointer-values-in-various-types.rs:63:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------------^^^ + | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:66:5 + --> $DIR/const-pointer-values-in-various-types.rs:66:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:69:5 + --> $DIR/const-pointer-values-in-various-types.rs:69:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:72:5 + --> $DIR/const-pointer-values-in-various-types.rs:72:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:75:5 + --> $DIR/const-pointer-values-in-various-types.rs:75:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -153,34 +153,34 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:81:5 + --> $DIR/const-pointer-values-in-various-types.rs:81:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:84:5 + --> $DIR/const-pointer-values-in-various-types.rs:84:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:87:5 + --> $DIR/const-pointer-values-in-various-types.rs:87:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:90:5 + --> $DIR/const-pointer-values-in-various-types.rs:90:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -193,18 +193,18 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:96:5 + --> $DIR/const-pointer-values-in-various-types.rs:96:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:99:5 + --> $DIR/const-pointer-values-in-various-types.rs:99:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -217,18 +217,18 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:105:5 + --> $DIR/const-pointer-values-in-various-types.rs:105:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:108:5 + --> $DIR/const-pointer-values-in-various-types.rs:108:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index eecac7c71075b..12c7e3d34ab9e 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic.rs:4:1 + --> $DIR/const_panic.rs:4:19 | LL | pub const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^----------------^ + | ------------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:19 | @@ -10,20 +10,20 @@ LL | pub const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:7:1 + --> $DIR/const_panic.rs:7:19 | LL | pub const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^^^^^--------------^ + | ------------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:7:19 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:10:1 + --> $DIR/const_panic.rs:10:19 | LL | pub const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^^^^^----------------^ + | ------------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic.rs:10:19 | diff --git a/src/test/ui/consts/const-eval/const_panic_libcore.stderr b/src/test/ui/consts/const-eval/const_panic_libcore.stderr index 83c89c329dcf5..9dddac49c92b8 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:5:1 + --> $DIR/const_panic_libcore.rs:5:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore.rs:5:15 | @@ -10,20 +10,20 @@ LL | const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:8:1 + --> $DIR/const_panic_libcore.rs:8:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^--------------^ + | --------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore.rs:8:15 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:11:1 + --> $DIR/const_panic_libcore.rs:11:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore.rs:11:15 | diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr index 4cc48618e3212..df04a03681127 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:9:1 + --> $DIR/const_panic_libcore_main.rs:9:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:9:15 | @@ -10,20 +10,20 @@ LL | const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:12:1 + --> $DIR/const_panic_libcore_main.rs:12:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^--------------^ + | --------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:12:15 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:15:1 + --> $DIR/const_panic_libcore_main.rs:15:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore_main.rs:15:15 | diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr index 773441182b4be..0d4c0b98879cc 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr @@ -1,34 +1,34 @@ error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:6:1 + --> $DIR/const_raw_ptr_ops.rs:6:26 | LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer arithmetic or comparison" needs an rfc before being allowed inside constants | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:12:1 + --> $DIR/const_raw_ptr_ops.rs:12:28 | LL | const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------^^^ + | ---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer arithmetic or comparison" needs an rfc before being allowed inside constants error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:16:1 + --> $DIR/const_raw_ptr_ops.rs:16:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:17:1 + --> $DIR/const_raw_ptr_ops.rs:17:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index 84c686102609e..478e453fe0834 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:8:5 + --> $DIR/issue-43197.rs:8:20 | LL | const X: u32 = 0-1; - | ^^^^^^^^^^^^^^^---^ + | ---------------^^^- | | | attempt to subtract with overflow | @@ -13,10 +13,10 @@ LL | #![warn(const_err)] | ^^^^^^^^^ warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:10:5 + --> $DIR/issue-43197.rs:10:24 | LL | const Y: u32 = foo(0-1); - | ^^^^^^^^^^^^^^^^^^^---^^ + | -------------------^^^-- | | | attempt to subtract with overflow diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index 37462db4c965e..5a59a8b2dffcd 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-49296.rs:18:1 + --> $DIR/issue-49296.rs:18:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^^^^^^^^--------^ + | ---------------^^^^^^^^- | | | dangling pointer was dereferenced | diff --git a/src/test/ui/consts/const-eval/issue-50814-2.stderr b/src/test/ui/consts/const-eval/issue-50814-2.stderr index 29ebc31b634ad..da560046c547c 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-50814-2.rs:12:5 + --> $DIR/issue-50814-2.rs:12:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ^^^^^^^^^^^^^^^^^^^-----------------^ + | -------------------^^^^^^^^^^^^^^^^^- | | | index out of bounds: the len is 3 but the index is 42 | diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index 6fbfb4d11fe5a..bc9443b26f5fd 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-50814.rs:13:5 + --> $DIR/issue-50814.rs:13:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^^---------------^ + | ----------------^^^^^^^^^^^^^^^- | | | attempt to add with overflow | diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index c9d5ede61ade4..ca870c649f5b2 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -50,11 +50,15 @@ warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:14:20 | LL | println!("{}", 1/(false as u32)); - | ^^^^^^^^^^^^^^^^ attempt to divide by zero + | ^^^^^^^^^^^^^^^^ + | | + | attempt to divide by zero warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); - | ^^^^^^^ attempt to divide by zero + | ^^^^^^^ + | | + | attempt to divide by zero diff --git a/src/test/ui/consts/const-eval/pub_const_err.stderr b/src/test/ui/consts/const-eval/pub_const_err.stderr index 9395832108d93..bd262b69da81a 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/pub_const_err.rs:6:1 + --> $DIR/pub_const_err.rs:6:20 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ + | -------------------^^^^^- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr index 6716f337f4148..866d1753edb95 100644 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/pub_const_err_bin.rs:4:1 + --> $DIR/pub_const_err_bin.rs:4:20 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ + | -------------------^^^^^- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-eval/unused-broken-const.stderr b/src/test/ui/consts/const-eval/unused-broken-const.stderr index c0061f8b30cbc..603efe449f143 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.stderr +++ b/src/test/ui/consts/const-eval/unused-broken-const.stderr @@ -1,10 +1,10 @@ warning: due to multiple output types requested, the explicitly specified output file name will be adapted for each output type error: any use of this value will cause an error - --> $DIR/unused-broken-const.rs:5:1 + --> $DIR/unused-broken-const.rs:5:18 | LL | const FOO: i32 = [][0]; - | ^^^^^^^^^^^^^^^^^-----^ + | -----------------^^^^^- | | | index out of bounds: the len is 0 but the index is 0 | diff --git a/src/test/ui/consts/const-int-unchecked.stderr b/src/test/ui/consts/const-int-unchecked.stderr index 4382d9174b757..0fa82008711c9 100644 --- a/src/test/ui/consts/const-int-unchecked.stderr +++ b/src/test/ui/consts/const-int-unchecked.stderr @@ -1,322 +1,322 @@ error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:14:1 + --> $DIR/const-int-unchecked.rs:14:29 | LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shl | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:16:1 + --> $DIR/const-int-unchecked.rs:16:31 | LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:18:1 + --> $DIR/const-int-unchecked.rs:18:31 | LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:20:1 + --> $DIR/const-int-unchecked.rs:20:31 | LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:22:1 + --> $DIR/const-int-unchecked.rs:22:33 | LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:27:1 + --> $DIR/const-int-unchecked.rs:27:29 | LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:29:1 + --> $DIR/const-int-unchecked.rs:29:31 | LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:31:1 + --> $DIR/const-int-unchecked.rs:31:31 | LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:33:1 + --> $DIR/const-int-unchecked.rs:33:31 | LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:35:1 + --> $DIR/const-int-unchecked.rs:35:33 | LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:40:1 + --> $DIR/const-int-unchecked.rs:40:33 | LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 255 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:42:1 + --> $DIR/const-int-unchecked.rs:42:35 | LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65535 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:44:1 + --> $DIR/const-int-unchecked.rs:44:35 | LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967295 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:46:1 + --> $DIR/const-int-unchecked.rs:46:35 | LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551615 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:48:1 + --> $DIR/const-int-unchecked.rs:48:37 | LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211455 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:54:1 + --> $DIR/const-int-unchecked.rs:54:40 | LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 250 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:56:1 + --> $DIR/const-int-unchecked.rs:56:42 | LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65523 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:58:1 + --> $DIR/const-int-unchecked.rs:58:42 | LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967271 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:60:1 + --> $DIR/const-int-unchecked.rs:60:42 | LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551586 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:62:1 + --> $DIR/const-int-unchecked.rs:62:44 | LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211363 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:69:1 + --> $DIR/const-int-unchecked.rs:69:29 | LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:71:1 + --> $DIR/const-int-unchecked.rs:71:31 | LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:73:1 + --> $DIR/const-int-unchecked.rs:73:31 | LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:75:1 + --> $DIR/const-int-unchecked.rs:75:31 | LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:77:1 + --> $DIR/const-int-unchecked.rs:77:33 | LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:82:1 + --> $DIR/const-int-unchecked.rs:82:29 | LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:84:1 + --> $DIR/const-int-unchecked.rs:84:31 | LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:86:1 + --> $DIR/const-int-unchecked.rs:86:31 | LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:88:1 + --> $DIR/const-int-unchecked.rs:88:31 | LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:90:1 + --> $DIR/const-int-unchecked.rs:90:33 | LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:95:1 + --> $DIR/const-int-unchecked.rs:95:33 | LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 255 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:97:1 + --> $DIR/const-int-unchecked.rs:97:35 | LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65535 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:99:1 + --> $DIR/const-int-unchecked.rs:99:35 | LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967295 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:101:1 + --> $DIR/const-int-unchecked.rs:101:35 | LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551615 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:103:1 + --> $DIR/const-int-unchecked.rs:103:37 | LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211455 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:109:1 + --> $DIR/const-int-unchecked.rs:109:40 | LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 250 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:111:1 + --> $DIR/const-int-unchecked.rs:111:42 | LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65523 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:113:1 + --> $DIR/const-int-unchecked.rs:113:42 | LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967271 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:115:1 + --> $DIR/const-int-unchecked.rs:115:42 | LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551586 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:117:1 + --> $DIR/const-int-unchecked.rs:117:44 | LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211363 in unchecked_shr diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.stderr b/src/test/ui/consts/const-len-underflow-separate-spans.stderr index 6ee92032bd777..ef4fa126dca32 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/consts/const-len-underflow-separate-spans.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-len-underflow-separate-spans.rs:7:1 + --> $DIR/const-len-underflow-separate-spans.rs:7:20 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^^^^^^^^^^^---------^ + | -------------------^^^^^^^^^- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-slice-oob.stderr b/src/test/ui/consts/const-slice-oob.stderr index 1122665cf8e55..c90cdbcb26970 100644 --- a/src/test/ui/consts/const-slice-oob.stderr +++ b/src/test/ui/consts/const-slice-oob.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-slice-oob.rs:4:1 + --> $DIR/const-slice-oob.rs:4:18 | LL | const BAR: u32 = FOO[5]; - | ^^^^^^^^^^^^^^^^^------^ + | -----------------^^^^^^- | | | index out of bounds: the len is 3 but the index is 5 | diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index 87f84480bf66b..ba640b90e7d79 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -1,11 +1,17 @@ error: any use of this value will cause an error --> $DIR/dangling-alloc-id-ice.rs:8:1 | -LL | / const FOO: &() = { -LL | | let y = (); -LL | | unsafe { Foo { y: &y }.long_live_the_unit } -LL | | }; - | |__^ type validation failed: encountered dangling pointer in final constant +LL | const FOO: &() = { + | _^ + | |_| + | || +LL | || let y = (); +LL | || unsafe { Foo { y: &y }.long_live_the_unit } +LL | || }; + | || ^ + | ||__| + | |___type validation failed: encountered dangling pointer in final constant + | | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/consts/dangling_raw_ptr.stderr b/src/test/ui/consts/dangling_raw_ptr.stderr index 0168c08f011d4..cedcbf819e2d8 100644 --- a/src/test/ui/consts/dangling_raw_ptr.stderr +++ b/src/test/ui/consts/dangling_raw_ptr.stderr @@ -1,11 +1,17 @@ error: any use of this value will cause an error --> $DIR/dangling_raw_ptr.rs:1:1 | -LL | / const FOO: *const u32 = { -LL | | let x = 42; -LL | | &x -LL | | }; - | |__^ type validation failed: encountered dangling pointer in final constant +LL | const FOO: *const u32 = { + | _^ + | |_| + | || +LL | || let x = 42; +LL | || &x +LL | || }; + | || ^ + | ||__| + | |___type validation failed: encountered dangling pointer in final constant + | | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/error-codes/E0396-fixed.stderr b/src/test/ui/error-codes/E0396-fixed.stderr index 2923d97662868..4b7f1fa82c26c 100644 --- a/src/test/ui/error-codes/E0396-fixed.stderr +++ b/src/test/ui/error-codes/E0396-fixed.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/E0396-fixed.rs:5:1 + --> $DIR/E0396-fixed.rs:5:28 | LL | const VALUE: u8 = unsafe { *REG_ADDR }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^^ + | ---------------------------^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer | diff --git a/src/test/ui/issues/issue-43105.stderr b/src/test/ui/issues/issue-43105.stderr index 3cc0440d2c77a..378fbe6d5c430 100644 --- a/src/test/ui/issues/issue-43105.stderr +++ b/src/test/ui/issues/issue-43105.stderr @@ -5,10 +5,10 @@ LL | const NUM: u8 = xyz(); | ^^^^^ error: any use of this value will cause an error - --> $DIR/issue-43105.rs:3:1 + --> $DIR/issue-43105.rs:3:17 | LL | const NUM: u8 = xyz(); - | ^^^^^^^^^^^^^^^^-----^ + | ----------------^^^^^- | | | calling non-const function `xyz` | From 690bc57882ba94166446403423ac3dc278506d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 18:03:59 -0700 Subject: [PATCH 16/24] Swap primary/secondary spans for E0458 --- src/librustc_metadata/native_libs.rs | 5 +++-- src/test/ui/bad/bad-extern-link-attrs.stderr | 4 ++-- src/test/ui/error-codes/E0458.stderr | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 80786992cd956..87dca77be50ca 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -74,9 +74,10 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { "dylib" => cstore::NativeUnknown, "framework" => cstore::NativeFramework, k => { - struct_span_err!(self.tcx.sess, m.span, E0458, + struct_span_err!(self.tcx.sess, item.span, E0458, "unknown kind: `{}`", k) - .span_label(item.span(), "unknown kind").emit(); + .span_label(item.span(), "unknown kind") + .span_label(m.span, "").emit(); cstore::NativeUnknown } }; diff --git a/src/test/ui/bad/bad-extern-link-attrs.stderr b/src/test/ui/bad/bad-extern-link-attrs.stderr index 5baba599e741f..a77f5f9f4383f 100644 --- a/src/test/ui/bad/bad-extern-link-attrs.stderr +++ b/src/test/ui/bad/bad-extern-link-attrs.stderr @@ -11,10 +11,10 @@ LL | #[link(name = "")] | ^^^^^^^^^^^^^^^^^^ empty name given error[E0458]: unknown kind: `bar` - --> $DIR/bad-extern-link-attrs.rs:4:1 + --> $DIR/bad-extern-link-attrs.rs:4:22 | LL | #[link(name = "foo", kind = "bar")] - | ^^^^^^^^^^^^^^^^^^^^^------------^^ + | ---------------------^^^^^^^^^^^^-- | | | unknown kind diff --git a/src/test/ui/error-codes/E0458.stderr b/src/test/ui/error-codes/E0458.stderr index 9cfe7cccac1a5..154e0b121797d 100644 --- a/src/test/ui/error-codes/E0458.stderr +++ b/src/test/ui/error-codes/E0458.stderr @@ -1,8 +1,8 @@ error[E0458]: unknown kind: `wonderful_unicorn` - --> $DIR/E0458.rs:1:1 + --> $DIR/E0458.rs:1:8 | LL | #[link(kind = "wonderful_unicorn")] extern {} - | ^^^^^^^--------------------------^^ + | -------^^^^^^^^^^^^^^^^^^^^^^^^^^-- | | | unknown kind From 18d727f0d7d89ea5529bf91c0d62aad55db7b8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 19:46:44 -0700 Subject: [PATCH 17/24] Tweak unsupported negative trait bounds message --- src/librustc_errors/diagnostic.rs | 2 +- src/libsyntax/parse/parser.rs | 21 +++++++++----- src/test/ui/issues/issue-58857.stderr | 3 +- src/test/ui/parser/issue-33418.fixed | 11 +++++-- src/test/ui/parser/issue-33418.rs | 15 ++++++---- src/test/ui/parser/issue-33418.stderr | 41 +++++++++++++-------------- 6 files changed, 55 insertions(+), 38 deletions(-) diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 851b19e8177b5..fc1fd960c4ace 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -366,7 +366,7 @@ impl Diagnostic { }], }], msg: msg.to_owned(), - style: SuggestionStyle::HideCodeInline, + style: SuggestionStyle::HideCodeAlways, applicability, }); self diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa70c54a1ef8a..7a41675c814bc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5599,8 +5599,14 @@ impl<'a> Parser<'a> { if !negative_bounds.is_empty() || was_negative { let plural = negative_bounds.len() > 1; - let mut err = self.struct_span_err(negative_bounds, - "negative trait bounds are not supported"); + let last_span = negative_bounds.last().map(|sp| *sp); + let mut err = self.struct_span_err( + negative_bounds, + "negative trait bounds are not supported", + ); + if let Some(sp) = last_span { + err.span_label(sp, "negative trait bounds are not supported"); + } if let Some(bound_list) = colon_span { let bound_list = bound_list.to(self.prev_span); let mut new_bound_list = String::new(); @@ -5613,11 +5619,12 @@ impl<'a> Parser<'a> { } new_bound_list = new_bound_list.replacen(" +", ":", 1); } - err.span_suggestion_short(bound_list, - &format!("remove the trait bound{}", - if plural { "s" } else { "" }), - new_bound_list, - Applicability::MachineApplicable); + err.span_suggestion_hidden( + bound_list, + &format!("remove the trait bound{}", if plural { "s" } else { "" }), + new_bound_list, + Applicability::MachineApplicable, + ); } err.emit(); } diff --git a/src/test/ui/issues/issue-58857.stderr b/src/test/ui/issues/issue-58857.stderr index 040e9eb8a6567..56e87215a800c 100644 --- a/src/test/ui/issues/issue-58857.stderr +++ b/src/test/ui/issues/issue-58857.stderr @@ -2,7 +2,8 @@ error: negative trait bounds are not supported --> $DIR/issue-58857.rs:4:7 | LL | impl Conj{} - | ^^^^^^^^ help: remove the trait bound + | ^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: aborting due to previous error diff --git a/src/test/ui/parser/issue-33418.fixed b/src/test/ui/parser/issue-33418.fixed index df11f2d855ce0..2aaa3b5b1ea50 100644 --- a/src/test/ui/parser/issue-33418.fixed +++ b/src/test/ui/parser/issue-33418.fixed @@ -1,10 +1,15 @@ // run-rustfix -trait Tr {} //~ ERROR negative trait bounds are not supported -trait Tr2: SuperA {} //~ ERROR negative trait bounds are not supported -trait Tr3: SuperB {} //~ ERROR negative trait bounds are not supported +trait Tr {} +//~^ ERROR negative trait bounds are not supported +trait Tr2: SuperA {} +//~^ ERROR negative trait bounds are not supported +trait Tr3: SuperB {} +//~^ ERROR negative trait bounds are not supported trait Tr4: SuperB + SuperD {} +//~^ ERROR negative trait bounds are not supported trait Tr5 {} +//~^ ERROR negative trait bounds are not supported trait SuperA {} trait SuperB {} diff --git a/src/test/ui/parser/issue-33418.rs b/src/test/ui/parser/issue-33418.rs index 5bb5f2afca377..5533152092719 100644 --- a/src/test/ui/parser/issue-33418.rs +++ b/src/test/ui/parser/issue-33418.rs @@ -1,12 +1,17 @@ // run-rustfix -trait Tr: !SuperA {} //~ ERROR negative trait bounds are not supported -trait Tr2: SuperA + !SuperB {} //~ ERROR negative trait bounds are not supported -trait Tr3: !SuperA + SuperB {} //~ ERROR negative trait bounds are not supported -trait Tr4: !SuperA + SuperB //~ ERROR negative trait bounds are not supported +trait Tr: !SuperA {} +//~^ ERROR negative trait bounds are not supported +trait Tr2: SuperA + !SuperB {} +//~^ ERROR negative trait bounds are not supported +trait Tr3: !SuperA + SuperB {} +//~^ ERROR negative trait bounds are not supported +trait Tr4: !SuperA + SuperB + !SuperC + SuperD {} -trait Tr5: !SuperA //~ ERROR negative trait bounds are not supported +//~^ ERROR negative trait bounds are not supported +trait Tr5: !SuperA + !SuperB {} +//~^ ERROR negative trait bounds are not supported trait SuperA {} trait SuperB {} diff --git a/src/test/ui/parser/issue-33418.stderr b/src/test/ui/parser/issue-33418.stderr index acbe597ef31a3..660d9fd30c82e 100644 --- a/src/test/ui/parser/issue-33418.stderr +++ b/src/test/ui/parser/issue-33418.stderr @@ -2,41 +2,40 @@ error: negative trait bounds are not supported --> $DIR/issue-33418.rs:3:9 | LL | trait Tr: !SuperA {} - | ^^^^^^^^^ help: remove the trait bound + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:4:19 + --> $DIR/issue-33418.rs:5:19 | LL | trait Tr2: SuperA + !SuperB {} - | ---------^^^^^^^^^ - | | - | help: remove the trait bound + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:5:10 + --> $DIR/issue-33418.rs:7:10 | LL | trait Tr3: !SuperA + SuperB {} - | ^^^^^^^^^--------- - | | - | help: remove the trait bound + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bound error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:6:10 + --> $DIR/issue-33418.rs:9:10 | -LL | trait Tr4: !SuperA + SuperB - | __________-^^^^^^^^ -LL | | + !SuperC + SuperD {} - | |_____^^^^^^^^^________- help: remove the trait bounds +LL | trait Tr4: !SuperA + SuperB + | ^^^^^^^^^ +LL | + !SuperC + SuperD {} + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bounds error: negative trait bounds are not supported - --> $DIR/issue-33418.rs:8:10 + --> $DIR/issue-33418.rs:12:10 | -LL | trait Tr5: !SuperA - | __________-^^^^^^^^ -LL | | + !SuperB {} - | | ^^^^^^^^- - | |_____________| - | help: remove the trait bounds +LL | trait Tr5: !SuperA + | ^^^^^^^^^ +LL | + !SuperB {} + | ^^^^^^^^^ negative trait bounds are not supported + = help: remove the trait bounds error: aborting due to 5 previous errors From bb15af16634424fd6fea17bd51b1513a615a6c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 20:05:01 -0700 Subject: [PATCH 18/24] Tweak unnecessary import suggestion --- src/librustc_resolve/lib.rs | 2 +- src/test/ui/double-type-import.stderr | 6 ++---- src/test/ui/imports/duplicate.stderr | 6 ++---- src/test/ui/issues/issue-26886.stderr | 12 ++++-------- src/test/ui/issues/issue-52891.stderr | 12 ++++-------- src/test/ui/proc-macro/shadow.stderr | 14 ++++++-------- .../resolve-conflict-import-vs-import.stderr | 6 ++---- .../unresolved-extern-mod-suggestion.stderr | 6 ++---- src/test/ui/use/use-paths-as-items.stderr | 6 ++---- 9 files changed, 25 insertions(+), 45 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index ac149be4b2a89..973c58a67a5d4 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4932,7 +4932,7 @@ impl<'a> Resolver<'a> { Some((directive, _, true)) if should_remove_import && !directive.is_glob() => { // Simple case - remove the entire import. Due to the above match arm, this can // only be a single use so just remove it entirely. - err.span_suggestion( + err.span_suggestion_hidden( directive.use_span_with_attributes, "remove unnecessary import", String::new(), diff --git a/src/test/ui/double-type-import.stderr b/src/test/ui/double-type-import.stderr index c7288af13c278..d5e153d22ad7c 100644 --- a/src/test/ui/double-type-import.stderr +++ b/src/test/ui/double-type-import.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `X` is defined multiple times LL | pub use self::bar::X; | ------------ previous import of the type `X` here LL | use self::bar::X; - | ----^^^^^^^^^^^^- - | | | - | | `X` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^ `X` reimported here | = note: `X` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/imports/duplicate.stderr b/src/test/ui/imports/duplicate.stderr index 7c43c642ec36e..f85a265487bfd 100644 --- a/src/test/ui/imports/duplicate.stderr +++ b/src/test/ui/imports/duplicate.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `foo` is defined multiple times LL | use a::foo; | ------ previous import of the value `foo` here LL | use a::foo; - | ----^^^^^^- - | | | - | | `foo` reimported here - | help: remove unnecessary import + | ^^^^^^ `foo` reimported here | = note: `foo` must be defined only once in the value namespace of this module + = help: remove unnecessary import error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:46:15 diff --git a/src/test/ui/issues/issue-26886.stderr b/src/test/ui/issues/issue-26886.stderr index fa7f922707ab9..6002befe0d817 100644 --- a/src/test/ui/issues/issue-26886.stderr +++ b/src/test/ui/issues/issue-26886.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `Arc` is defined multiple times LL | use std::sync::{self, Arc}; | --- previous import of the type `Arc` here LL | use std::sync::Arc; - | ----^^^^^^^^^^^^^^- - | | | - | | `Arc` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^^^ `Arc` reimported here | = note: `Arc` must be defined only once in the type namespace of this module + = help: remove unnecessary import error[E0252]: the name `sync` is defined multiple times --> $DIR/issue-26886.rs:4:5 @@ -18,12 +16,10 @@ LL | use std::sync::{self, Arc}; | ---- previous import of the module `sync` here ... LL | use std::sync; - | ----^^^^^^^^^- - | | | - | | `sync` reimported here - | help: remove unnecessary import + | ^^^^^^^^^ `sync` reimported here | = note: `sync` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-52891.stderr b/src/test/ui/issues/issue-52891.stderr index 1385693e91ae0..6068c97505767 100644 --- a/src/test/ui/issues/issue-52891.stderr +++ b/src/test/ui/issues/issue-52891.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `a` is defined multiple times LL | use issue_52891::a; | -------------- previous import of the module `a` here LL | use issue_52891::a; - | ----^^^^^^^^^^^^^^- - | | | - | | `a` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^^^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module + = help: remove unnecessary import error[E0252]: the name `a` is defined multiple times --> $DIR/issue-52891.rs:14:19 @@ -129,15 +127,13 @@ error[E0252]: the name `n` is defined multiple times --> $DIR/issue-52891.rs:36:5 | LL | use issue_52891::n; - | ------------------- - | | | - | | previous import of the module `n` here - | help: remove unnecessary import + | -------------- previous import of the module `n` here LL | #[macro_use] LL | use issue_52891::n; | ^^^^^^^^^^^^^^ `n` reimported here | = note: `n` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to 10 previous errors diff --git a/src/test/ui/proc-macro/shadow.stderr b/src/test/ui/proc-macro/shadow.stderr index 91b73903aca29..597c05434f33b 100644 --- a/src/test/ui/proc-macro/shadow.stderr +++ b/src/test/ui/proc-macro/shadow.stderr @@ -1,16 +1,14 @@ error[E0259]: the name `derive_a` is defined multiple times --> $DIR/shadow.rs:6:1 | -LL | extern crate derive_a; - | ---------------------- previous import of the extern crate `derive_a` here -LL | / #[macro_use] -LL | | extern crate derive_a; - | | ^^^^^^^^^^^^^^^^^^^^^- - | |_|____________________| - | | help: remove unnecessary import - | `derive_a` reimported here +LL | extern crate derive_a; + | ---------------------- previous import of the extern crate `derive_a` here +LL | #[macro_use] +LL | extern crate derive_a; + | ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here | = note: `derive_a` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr index 1b4b058b783ad..34f18feb9dcd0 100644 --- a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr +++ b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `transmute` is defined multiple times LL | use std::mem::transmute; | ------------------- previous import of the value `transmute` here LL | use std::mem::transmute; - | ----^^^^^^^^^^^^^^^^^^^- - | | | - | | `transmute` reimported here - | help: remove unnecessary import + | ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here | = note: `transmute` must be defined only once in the value namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr index e8679a3726d30..cfae699b6edc3 100644 --- a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr +++ b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr @@ -4,12 +4,10 @@ error[E0254]: the name `core` is defined multiple times LL | extern crate core; | ------------------ previous import of the extern crate `core` here LL | use core; - | ----^^^^- - | | | - | | `core` reimported here - | help: remove unnecessary import + | ^^^^ `core` reimported here | = note: `core` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/use/use-paths-as-items.stderr b/src/test/ui/use/use-paths-as-items.stderr index 334e145098be0..43ebbf157c3c2 100644 --- a/src/test/ui/use/use-paths-as-items.stderr +++ b/src/test/ui/use/use-paths-as-items.stderr @@ -4,12 +4,10 @@ error[E0252]: the name `mem` is defined multiple times LL | use std::{mem, ptr}; | --- previous import of the module `mem` here LL | use std::mem; - | ----^^^^^^^^- - | | | - | | `mem` reimported here - | help: remove unnecessary import + | ^^^^^^^^ `mem` reimported here | = note: `mem` must be defined only once in the type namespace of this module + = help: remove unnecessary import error: aborting due to previous error From b616ccae5ff718d71c242d3ac9c50ccae07c855f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 10 Mar 2019 22:25:23 -0700 Subject: [PATCH 19/24] Hide obvious suggestion from cli output --- src/librustc_resolve/lib.rs | 2 +- src/test/ui/error-codes/E0430.stderr | 6 ++---- .../ui/issues/issue-45829/import-twice.stderr | 6 ++---- src/test/ui/issues/issue-52891.stderr | 18 +++++------------- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 973c58a67a5d4..4c5b9e3675b47 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -5112,7 +5112,7 @@ impl<'a> Resolver<'a> { // extra for the comma. span.lo().0 - (prev_comma.as_bytes().len() as u32) - 1 )); - err.span_suggestion( + err.tool_only_span_suggestion( span, message, String::new(), Applicability::MaybeIncorrect, ); return; diff --git a/src/test/ui/error-codes/E0430.stderr b/src/test/ui/error-codes/E0430.stderr index 9f8b053de2cac..d8e4a802959a0 100644 --- a/src/test/ui/error-codes/E0430.stderr +++ b/src/test/ui/error-codes/E0430.stderr @@ -10,10 +10,8 @@ error[E0252]: the name `fmt` is defined multiple times --> $DIR/E0430.rs:1:22 | LL | use std::fmt::{self, self}; - | ------^^^^ - | | | | - | | | `fmt` reimported here - | | help: remove unnecessary import + | ---- ^^^^ `fmt` reimported here + | | | previous import of the module `fmt` here | = note: `fmt` must be defined only once in the type namespace of this module diff --git a/src/test/ui/issues/issue-45829/import-twice.stderr b/src/test/ui/issues/issue-45829/import-twice.stderr index 2a1ac57651138..656b011bc3be8 100644 --- a/src/test/ui/issues/issue-45829/import-twice.stderr +++ b/src/test/ui/issues/issue-45829/import-twice.stderr @@ -2,10 +2,8 @@ error[E0252]: the name `A` is defined multiple times --> $DIR/import-twice.rs:6:14 | LL | use foo::{A, A}; - | ---^ - | || | - | || `A` reimported here - | |help: remove unnecessary import + | - ^ `A` reimported here + | | | previous import of the type `A` here | = note: `A` must be defined only once in the type namespace of this module diff --git a/src/test/ui/issues/issue-52891.stderr b/src/test/ui/issues/issue-52891.stderr index 6068c97505767..895e3a77946ef 100644 --- a/src/test/ui/issues/issue-52891.stderr +++ b/src/test/ui/issues/issue-52891.stderr @@ -44,10 +44,7 @@ LL | use issue_52891::a; | -------------- previous import of the module `a` here ... LL | use issue_52891::{f, g, a}; - | --^ - | | | - | | `a` reimported here - | help: remove unnecessary import + | ^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module @@ -82,16 +79,11 @@ LL | a, error[E0252]: the name `a` is defined multiple times --> $DIR/issue-52891.rs:26:5 | -LL | use issue_52891::a; - | -------------- previous import of the module `a` here +LL | use issue_52891::a; + | -------------- previous import of the module `a` here ... -LL | m, - | ______- -LL | | a}; - | | ^ - | | | - | |_____`a` reimported here - | help: remove unnecessary import +LL | a}; + | ^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module From 743d0197bf8ad8d452e836ed87257c214609cd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 11 Mar 2019 09:43:05 -0700 Subject: [PATCH 20/24] Deduplicate const eval error spans for better output --- src/librustc/mir/interpret/error.rs | 4 +++- .../ui/consts/const-eval/promoted_errors.stderr | 8 ++------ src/test/ui/consts/dangling-alloc-id-ice.stderr | 16 +++++----------- src/test/ui/consts/dangling_raw_ptr.stderr | 16 +++++----------- 4 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 5cd1ced20220a..fc04c7672db68 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -116,7 +116,9 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { // point to the `const` statement as a secondary span // they don't have any label for sp in primary_spans { - lint.span_label(sp, ""); + if sp != span { + lint.span_label(sp, ""); + } } } lint.emit(); diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index ca870c649f5b2..c9d5ede61ade4 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -50,15 +50,11 @@ warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:14:20 | LL | println!("{}", 1/(false as u32)); - | ^^^^^^^^^^^^^^^^ - | | - | attempt to divide by zero + | ^^^^^^^^^^^^^^^^ attempt to divide by zero warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); - | ^^^^^^^ - | | - | attempt to divide by zero + | ^^^^^^^ attempt to divide by zero diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index ba640b90e7d79..87f84480bf66b 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -1,17 +1,11 @@ error: any use of this value will cause an error --> $DIR/dangling-alloc-id-ice.rs:8:1 | -LL | const FOO: &() = { - | _^ - | |_| - | || -LL | || let y = (); -LL | || unsafe { Foo { y: &y }.long_live_the_unit } -LL | || }; - | || ^ - | ||__| - | |___type validation failed: encountered dangling pointer in final constant - | +LL | / const FOO: &() = { +LL | | let y = (); +LL | | unsafe { Foo { y: &y }.long_live_the_unit } +LL | | }; + | |__^ type validation failed: encountered dangling pointer in final constant | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/consts/dangling_raw_ptr.stderr b/src/test/ui/consts/dangling_raw_ptr.stderr index cedcbf819e2d8..0168c08f011d4 100644 --- a/src/test/ui/consts/dangling_raw_ptr.stderr +++ b/src/test/ui/consts/dangling_raw_ptr.stderr @@ -1,17 +1,11 @@ error: any use of this value will cause an error --> $DIR/dangling_raw_ptr.rs:1:1 | -LL | const FOO: *const u32 = { - | _^ - | |_| - | || -LL | || let x = 42; -LL | || &x -LL | || }; - | || ^ - | ||__| - | |___type validation failed: encountered dangling pointer in final constant - | +LL | / const FOO: *const u32 = { +LL | | let x = 42; +LL | | &x +LL | | }; + | |__^ type validation failed: encountered dangling pointer in final constant | = note: #[deny(const_err)] on by default From b53ca900db381c72b1fb7eeb7289167b78076603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 11 Mar 2019 09:50:50 -0700 Subject: [PATCH 21/24] Mark duplicate import removal suggestion tool only --- src/librustc_resolve/lib.rs | 2 +- src/test/ui/double-type-import.stderr | 1 - src/test/ui/imports/duplicate.stderr | 1 - src/test/ui/issues/issue-26886.stderr | 2 -- src/test/ui/issues/issue-52891.stderr | 2 -- src/test/ui/proc-macro/shadow.stderr | 1 - src/test/ui/resolve/resolve-conflict-import-vs-import.stderr | 1 - src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr | 1 - src/test/ui/use/use-paths-as-items.stderr | 1 - 9 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 4c5b9e3675b47..38ca5f0b6640a 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4932,7 +4932,7 @@ impl<'a> Resolver<'a> { Some((directive, _, true)) if should_remove_import && !directive.is_glob() => { // Simple case - remove the entire import. Due to the above match arm, this can // only be a single use so just remove it entirely. - err.span_suggestion_hidden( + err.tool_only_span_suggestion( directive.use_span_with_attributes, "remove unnecessary import", String::new(), diff --git a/src/test/ui/double-type-import.stderr b/src/test/ui/double-type-import.stderr index d5e153d22ad7c..a2f30d82ec38b 100644 --- a/src/test/ui/double-type-import.stderr +++ b/src/test/ui/double-type-import.stderr @@ -7,7 +7,6 @@ LL | use self::bar::X; | ^^^^^^^^^^^^ `X` reimported here | = note: `X` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/imports/duplicate.stderr b/src/test/ui/imports/duplicate.stderr index f85a265487bfd..cc897b2b6b7e9 100644 --- a/src/test/ui/imports/duplicate.stderr +++ b/src/test/ui/imports/duplicate.stderr @@ -7,7 +7,6 @@ LL | use a::foo; | ^^^^^^ `foo` reimported here | = note: `foo` must be defined only once in the value namespace of this module - = help: remove unnecessary import error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module) --> $DIR/duplicate.rs:46:15 diff --git a/src/test/ui/issues/issue-26886.stderr b/src/test/ui/issues/issue-26886.stderr index 6002befe0d817..e2b925ec5a705 100644 --- a/src/test/ui/issues/issue-26886.stderr +++ b/src/test/ui/issues/issue-26886.stderr @@ -7,7 +7,6 @@ LL | use std::sync::Arc; | ^^^^^^^^^^^^^^ `Arc` reimported here | = note: `Arc` must be defined only once in the type namespace of this module - = help: remove unnecessary import error[E0252]: the name `sync` is defined multiple times --> $DIR/issue-26886.rs:4:5 @@ -19,7 +18,6 @@ LL | use std::sync; | ^^^^^^^^^ `sync` reimported here | = note: `sync` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-52891.stderr b/src/test/ui/issues/issue-52891.stderr index 895e3a77946ef..9173c02bcd866 100644 --- a/src/test/ui/issues/issue-52891.stderr +++ b/src/test/ui/issues/issue-52891.stderr @@ -7,7 +7,6 @@ LL | use issue_52891::a; | ^^^^^^^^^^^^^^ `a` reimported here | = note: `a` must be defined only once in the type namespace of this module - = help: remove unnecessary import error[E0252]: the name `a` is defined multiple times --> $DIR/issue-52891.rs:14:19 @@ -125,7 +124,6 @@ LL | use issue_52891::n; | ^^^^^^^^^^^^^^ `n` reimported here | = note: `n` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to 10 previous errors diff --git a/src/test/ui/proc-macro/shadow.stderr b/src/test/ui/proc-macro/shadow.stderr index 597c05434f33b..08057e163496d 100644 --- a/src/test/ui/proc-macro/shadow.stderr +++ b/src/test/ui/proc-macro/shadow.stderr @@ -8,7 +8,6 @@ LL | extern crate derive_a; | ^^^^^^^^^^^^^^^^^^^^^^ `derive_a` reimported here | = note: `derive_a` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr index 34f18feb9dcd0..8df68ad3229ed 100644 --- a/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr +++ b/src/test/ui/resolve/resolve-conflict-import-vs-import.stderr @@ -7,7 +7,6 @@ LL | use std::mem::transmute; | ^^^^^^^^^^^^^^^^^^^ `transmute` reimported here | = note: `transmute` must be defined only once in the value namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr index cfae699b6edc3..28333228a29ba 100644 --- a/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr +++ b/src/test/ui/unresolved/unresolved-extern-mod-suggestion.stderr @@ -7,7 +7,6 @@ LL | use core; | ^^^^ `core` reimported here | = note: `core` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error diff --git a/src/test/ui/use/use-paths-as-items.stderr b/src/test/ui/use/use-paths-as-items.stderr index 43ebbf157c3c2..b09001a9bcd45 100644 --- a/src/test/ui/use/use-paths-as-items.stderr +++ b/src/test/ui/use/use-paths-as-items.stderr @@ -7,7 +7,6 @@ LL | use std::mem; | ^^^^^^^^ `mem` reimported here | = note: `mem` must be defined only once in the type namespace of this module - = help: remove unnecessary import error: aborting due to previous error From d1656f1e0dc7288a87ee44e706552db8db7a9eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 16 Mar 2019 18:36:47 -0700 Subject: [PATCH 22/24] Fix rebase --- src/librustc_metadata/native_libs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs index 87dca77be50ca..04afe56f1d6aa 100644 --- a/src/librustc_metadata/native_libs.rs +++ b/src/librustc_metadata/native_libs.rs @@ -74,7 +74,7 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for Collector<'a, 'tcx> { "dylib" => cstore::NativeUnknown, "framework" => cstore::NativeFramework, k => { - struct_span_err!(self.tcx.sess, item.span, E0458, + struct_span_err!(self.tcx.sess, item.span(), E0458, "unknown kind: `{}`", k) .span_label(item.span(), "unknown kind") .span_label(m.span, "").emit(); From 64303189f0b3a111c3b1e59d77cdaad91ca90efe Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sun, 17 Mar 2019 10:36:10 +0000 Subject: [PATCH 23/24] Use a valid name for graphviz graphs --- src/librustc_driver/pretty.rs | 12 +++++++++- src/librustc_mir/borrow_check/mod.rs | 8 +++---- src/librustc_mir/dataflow/graphviz.rs | 17 +++++++------- src/librustc_mir/dataflow/mod.rs | 12 +++++----- src/librustc_mir/transform/elaborate_drops.rs | 12 +++++----- src/librustc_mir/transform/generator.rs | 6 ++--- src/librustc_mir/transform/rustc_peek.rs | 19 ++++++++------- src/librustc_mir/util/graphviz.rs | 14 ++++++++++- src/librustc_mir/util/mod.rs | 2 +- src/test/mir-opt/graphviz.rs | 23 +++++++++++++++++++ 10 files changed, 85 insertions(+), 40 deletions(-) create mode 100644 src/test/mir-opt/graphviz.rs diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index dde88a212408d..ace5198deaf2e 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -633,10 +633,20 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec, let body = tcx.hir().body(body_id); let cfg = cfg::CFG::new(tcx, &body); let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges; + let hir_id = code.id(); + // We have to disassemble the hir_id because name must be ASCII + // alphanumeric. This does not appear in the rendered graph, so it does not + // have to be user friendly. + let name = format!( + "hir_id_{}_{}_{}", + hir_id.owner.address_space().index(), + hir_id.owner.as_array_index(), + hir_id.local_id.index(), + ); let lcfg = LabelledCFG { tcx, cfg: &cfg, - name: format!("node_{}", code.id()), + name, labelled_edges, }; diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index c4e371d5afedb..551f18b95fe52 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -156,7 +156,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( let mut flow_inits = FlowAtLocation::new(do_dataflow( tcx, mir, - id, + def_id, &attributes, &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &mdpe), @@ -191,7 +191,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( let flow_borrows = FlowAtLocation::new(do_dataflow( tcx, mir, - id, + def_id, &attributes, &dead_unwinds, Borrows::new(tcx, mir, regioncx.clone(), &borrow_set), @@ -200,7 +200,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( let flow_uninits = FlowAtLocation::new(do_dataflow( tcx, mir, - id, + def_id, &attributes, &dead_unwinds, MaybeUninitializedPlaces::new(tcx, mir, &mdpe), @@ -209,7 +209,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( let flow_ever_inits = FlowAtLocation::new(do_dataflow( tcx, mir, - id, + def_id, &attributes, &dead_unwinds, EverInitializedPlaces::new(tcx, mir, &mdpe), diff --git a/src/librustc_mir/dataflow/graphviz.rs b/src/librustc_mir/dataflow/graphviz.rs index da9cc118f5521..d68377681f1ca 100644 --- a/src/librustc_mir/dataflow/graphviz.rs +++ b/src/librustc_mir/dataflow/graphviz.rs @@ -1,6 +1,6 @@ //! Hook into libgraphviz for rendering dataflow graphs for MIR. -use rustc::hir::HirId; +use rustc::hir::def_id::DefId; use rustc::mir::{BasicBlock, Mir}; use std::fs; @@ -8,13 +8,15 @@ use std::io; use std::marker::PhantomData; use std::path::Path; +use crate::util::graphviz_safe_def_name; + use super::{BitDenotation, DataflowState}; use super::DataflowBuilder; use super::DebugFormatted; pub trait MirWithFlowState<'tcx> { type BD: BitDenotation<'tcx>; - fn hir_id(&self) -> HirId; + fn def_id(&self) -> DefId; fn mir(&self) -> &Mir<'tcx>; fn flow_state(&self) -> &DataflowState<'tcx, Self::BD>; } @@ -23,7 +25,7 @@ impl<'a, 'tcx, BD> MirWithFlowState<'tcx> for DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation<'tcx> { type BD = BD; - fn hir_id(&self) -> HirId { self.hir_id } + fn def_id(&self) -> DefId { self.def_id } fn mir(&self) -> &Mir<'tcx> { self.flow_state.mir() } fn flow_state(&self) -> &DataflowState<'tcx, Self::BD> { &self.flow_state.flow_state } } @@ -47,8 +49,8 @@ pub(crate) fn print_borrowck_graph_to<'a, 'tcx, BD, P>( let g = Graph { mbcx, phantom: PhantomData, render_idx }; let mut v = Vec::new(); dot::render(&g, &mut v)?; - debug!("print_borrowck_graph_to path: {} hir_id: {}", - path.display(), mbcx.hir_id); + debug!("print_borrowck_graph_to path: {} def_id: {:?}", + path.display(), mbcx.def_id); fs::write(path, v) } @@ -69,9 +71,8 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P> type Node = Node; type Edge = Edge; fn graph_id(&self) -> dot::Id<'_> { - dot::Id::new(format!("graph_for_node_{}", - self.mbcx.hir_id())) - .unwrap() + let name = graphviz_safe_def_name(self.mbcx.def_id()); + dot::Id::new(format!("graph_for_def_id_{}", name)).unwrap() } fn node_id(&self, n: &Node) -> dot::Id<'_> { diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 03f8ac6743617..d0035bf7d3bc2 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -4,7 +4,7 @@ use rustc_data_structures::bit_set::{BitSet, BitSetOperator, HybridBitSet}; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::work_queue::WorkQueue; -use rustc::hir::HirId; +use rustc::hir::def_id::DefId; use rustc::ty::{self, TyCtxt}; use rustc::mir::{self, Mir, BasicBlock, BasicBlockData, Location, Statement, Terminator}; use rustc::mir::traversal; @@ -39,7 +39,7 @@ pub(crate) struct DataflowBuilder<'a, 'tcx: 'a, BD> where BD: BitDenotation<'tcx> { - hir_id: HirId, + def_id: DefId, flow_state: DataflowAnalysis<'a, 'tcx, BD>, print_preflow_to: Option, print_postflow_to: Option, @@ -117,7 +117,7 @@ pub struct MoveDataParamEnv<'gcx, 'tcx> { pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>(tcx: TyCtxt<'a, 'gcx, 'tcx>, mir: &'a Mir<'tcx>, - hir_id: HirId, + def_id: DefId, attributes: &[ast::Attribute], dead_unwinds: &BitSet, bd: BD, @@ -127,14 +127,14 @@ pub(crate) fn do_dataflow<'a, 'gcx, 'tcx, BD, P>(tcx: TyCtxt<'a, 'gcx, 'tcx>, P: Fn(&BD, BD::Idx) -> DebugFormatted { let flow_state = DataflowAnalysis::new(mir, dead_unwinds, bd); - flow_state.run(tcx, hir_id, attributes, p) + flow_state.run(tcx, def_id, attributes, p) } impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation<'tcx> { pub(crate) fn run

(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, - hir_id: HirId, + def_id: DefId, attributes: &[ast::Attribute], p: P) -> DataflowResults<'tcx, BD> where P: Fn(&BD, BD::Idx) -> DebugFormatted @@ -159,7 +159,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitD name_found(tcx.sess, attributes, "borrowck_graphviz_postflow"); let mut mbcx = DataflowBuilder { - hir_id, + def_id, print_preflow_to, print_postflow_to, flow_state: self, }; diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 32c027d90a0ce..3b0db48a94f18 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -28,7 +28,7 @@ impl MirPass for ElaborateDrops { { debug!("elaborate_drops({:?} @ {:?})", src, mir.span); - let id = tcx.hir().as_local_hir_id(src.def_id()).unwrap(); + let def_id = src.def_id(); let param_env = tcx.param_env(src.def_id()).with_reveal_all(); let move_data = match MoveData::gather_moves(mir, tcx) { Ok(move_data) => move_data, @@ -50,13 +50,13 @@ impl MirPass for ElaborateDrops { move_data, param_env, }; - let dead_unwinds = find_dead_unwinds(tcx, mir, id, &env); + let dead_unwinds = find_dead_unwinds(tcx, mir, def_id, &env); let flow_inits = - do_dataflow(tcx, mir, id, &[], &dead_unwinds, + do_dataflow(tcx, mir, def_id, &[], &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &env), |bd, p| DebugFormatted::new(&bd.move_data().move_paths[p])); let flow_uninits = - do_dataflow(tcx, mir, id, &[], &dead_unwinds, + do_dataflow(tcx, mir, def_id, &[], &dead_unwinds, MaybeUninitializedPlaces::new(tcx, mir, &env), |bd, p| DebugFormatted::new(&bd.move_data().move_paths[p])); @@ -80,7 +80,7 @@ impl MirPass for ElaborateDrops { fn find_dead_unwinds<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &Mir<'tcx>, - id: hir::HirId, + def_id: hir::def_id::DefId, env: &MoveDataParamEnv<'tcx, 'tcx>) -> BitSet { @@ -89,7 +89,7 @@ fn find_dead_unwinds<'a, 'tcx>( // reach cleanup blocks, which can't have unwind edges themselves. let mut dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); let flow_inits = - do_dataflow(tcx, mir, id, &[], &dead_unwinds, + do_dataflow(tcx, mir, def_id, &[], &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &env), |bd, p| DebugFormatted::new(&bd.move_data().move_paths[p])); for (bb, bb_data) in mir.basic_blocks().iter_enumerated() { diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 1f59802f8c6c0..98dcc3a16f209 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -383,13 +383,13 @@ fn locals_live_across_suspend_points( FxHashMap, ) { let dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); - let hir_id = tcx.hir().as_local_hir_id(source.def_id()).unwrap(); + let def_id = source.def_id(); // Calculate when MIR locals have live storage. This gives us an upper bound of their // lifetimes. let storage_live_analysis = MaybeStorageLive::new(mir); let storage_live = - do_dataflow(tcx, mir, hir_id, &[], &dead_unwinds, storage_live_analysis, + do_dataflow(tcx, mir, def_id, &[], &dead_unwinds, storage_live_analysis, |bd, p| DebugFormatted::new(&bd.mir().local_decls[p])); // Find the MIR locals which do not use StorageLive/StorageDead statements. @@ -403,7 +403,7 @@ fn locals_live_across_suspend_points( let borrowed_locals = if !movable { let analysis = HaveBeenBorrowedLocals::new(mir); let result = - do_dataflow(tcx, mir, hir_id, &[], &dead_unwinds, analysis, + do_dataflow(tcx, mir, def_id, &[], &dead_unwinds, analysis, |bd, p| DebugFormatted::new(&bd.mir().local_decls[p])); Some((analysis, result)) } else { diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index f9f8abbe6c065..246f876235d71 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -3,7 +3,7 @@ use syntax::ast; use syntax_pos::Span; use rustc::ty::{self, TyCtxt}; -use rustc::hir; +use rustc::hir::def_id::DefId; use rustc::mir::{self, Mir, Location}; use rustc_data_structures::bit_set::BitSet; use crate::transform::{MirPass, MirSource}; @@ -27,7 +27,6 @@ impl MirPass for SanityCheck { fn run_pass<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, src: MirSource<'tcx>, mir: &mut Mir<'tcx>) { let def_id = src.def_id(); - let id = tcx.hir().as_local_hir_id(def_id).unwrap(); if !tcx.has_attr(def_id, "rustc_mir") { debug!("skipping rustc_peek::SanityCheck on {}", tcx.def_path_str(def_id)); return; @@ -41,26 +40,26 @@ impl MirPass for SanityCheck { let mdpe = MoveDataParamEnv { move_data: move_data, param_env: param_env }; let dead_unwinds = BitSet::new_empty(mir.basic_blocks().len()); let flow_inits = - do_dataflow(tcx, mir, id, &attributes, &dead_unwinds, + do_dataflow(tcx, mir, def_id, &attributes, &dead_unwinds, MaybeInitializedPlaces::new(tcx, mir, &mdpe), |bd, i| DebugFormatted::new(&bd.move_data().move_paths[i])); let flow_uninits = - do_dataflow(tcx, mir, id, &attributes, &dead_unwinds, + do_dataflow(tcx, mir, def_id, &attributes, &dead_unwinds, MaybeUninitializedPlaces::new(tcx, mir, &mdpe), |bd, i| DebugFormatted::new(&bd.move_data().move_paths[i])); let flow_def_inits = - do_dataflow(tcx, mir, id, &attributes, &dead_unwinds, + do_dataflow(tcx, mir, def_id, &attributes, &dead_unwinds, DefinitelyInitializedPlaces::new(tcx, mir, &mdpe), |bd, i| DebugFormatted::new(&bd.move_data().move_paths[i])); if has_rustc_mir_with(&attributes, "rustc_peek_maybe_init").is_some() { - sanity_check_via_rustc_peek(tcx, mir, id, &attributes, &flow_inits); + sanity_check_via_rustc_peek(tcx, mir, def_id, &attributes, &flow_inits); } if has_rustc_mir_with(&attributes, "rustc_peek_maybe_uninit").is_some() { - sanity_check_via_rustc_peek(tcx, mir, id, &attributes, &flow_uninits); + sanity_check_via_rustc_peek(tcx, mir, def_id, &attributes, &flow_uninits); } if has_rustc_mir_with(&attributes, "rustc_peek_definite_init").is_some() { - sanity_check_via_rustc_peek(tcx, mir, id, &attributes, &flow_def_inits); + sanity_check_via_rustc_peek(tcx, mir, def_id, &attributes, &flow_def_inits); } if has_rustc_mir_with(&attributes, "stop_after_dataflow").is_some() { tcx.sess.fatal("stop_after_dataflow ended compilation"); @@ -86,12 +85,12 @@ impl MirPass for SanityCheck { /// errors are not intended to be used for unit tests.) pub fn sanity_check_via_rustc_peek<'a, 'tcx, O>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &Mir<'tcx>, - id: hir::HirId, + def_id: DefId, _attributes: &[ast::Attribute], results: &DataflowResults<'tcx, O>) where O: BitDenotation<'tcx, Idx=MovePathIndex> + HasMoveData<'tcx> { - debug!("sanity_check_via_rustc_peek id: {:?}", id); + debug!("sanity_check_via_rustc_peek def_id: {:?}", def_id); // FIXME: this is not DRY. Figure out way to abstract this and // `dataflow::build_sets`. (But note it is doing non-standard // stuff, so such generalization may not be realistic.) diff --git a/src/librustc_mir/util/graphviz.rs b/src/librustc_mir/util/graphviz.rs index 69a2adcfce026..f87714b58c442 100644 --- a/src/librustc_mir/util/graphviz.rs +++ b/src/librustc_mir/util/graphviz.rs @@ -1,6 +1,7 @@ use rustc::hir::def_id::DefId; use rustc::mir::*; use rustc::ty::TyCtxt; +use rustc_data_structures::indexed_vec::Idx; use std::fmt::Debug; use std::io::{self, Write}; @@ -20,6 +21,17 @@ pub fn write_mir_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, Ok(()) } +// Must match `[0-9A-Za-z_]*`. This does not appear in the rendered graph, so +// it does not have to be user friendly. +pub fn graphviz_safe_def_name(def_id: DefId) -> String { + format!( + "{}_{}_{}", + def_id.krate.index(), + def_id.index.address_space().index(), + def_id.index.as_array_index(), + ) +} + /// Write a graphviz DOT graph of the MIR. pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, def_id: DefId, @@ -27,7 +39,7 @@ pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, w: &mut W) -> io::Result<()> where W: Write { - writeln!(w, "digraph Mir_{} {{", tcx.hir().as_local_hir_id(def_id).unwrap())?; + writeln!(w, "digraph Mir_{} {{", graphviz_safe_def_name(def_id))?; // Global graph properties writeln!(w, r#" graph [fontname="monospace"];"#)?; diff --git a/src/librustc_mir/util/mod.rs b/src/librustc_mir/util/mod.rs index 29614a33f8e27..1a5a2a92247dd 100644 --- a/src/librustc_mir/util/mod.rs +++ b/src/librustc_mir/util/mod.rs @@ -15,7 +15,7 @@ pub mod collect_writes; pub use self::alignment::is_disaligned; pub use self::pretty::{dump_enabled, dump_mir, write_mir_pretty, PassWhere}; -pub use self::graphviz::{write_mir_graphviz}; +pub use self::graphviz::{graphviz_safe_def_name, write_mir_graphviz}; pub use self::graphviz::write_node_label as write_graphviz_node_label; /// If possible, suggest replacing `ref` with `ref mut`. diff --git a/src/test/mir-opt/graphviz.rs b/src/test/mir-opt/graphviz.rs new file mode 100644 index 0000000000000..660576996e5d4 --- /dev/null +++ b/src/test/mir-opt/graphviz.rs @@ -0,0 +1,23 @@ +// Test graphviz output +// compile-flags: -Z dump-mir-graphviz + +// ignore-tidy-linelength + +fn main() {} + +// END RUST SOURCE +// START rustc.main.mir_map.0.dot +// digraph Mir_0_0_3 { // The name here MUST be an ASCII identifier. +// graph [fontname="monospace"]; +// node [fontname="monospace"]; +// edge [fontname="monospace"]; +// label=>; +// bb0 [shape="none", label=<
0
_0 = ()
goto
+// >]; +// bb1 [shape="none", label=<
1
resume
+// >]; +// bb2 [shape="none", label=<
2
return
+// >]; +// bb0 -> bb2 [label=""]; +// } +// END rustc.main.mir_map.0.dot From 98b26728e0627ef417599497e2355e784a1e9f9c Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Sun, 17 Mar 2019 11:55:56 +0100 Subject: [PATCH 24/24] update mailmap for Bastian Kauschke --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index a928606b693e5..5f2f9c8995553 100644 --- a/.mailmap +++ b/.mailmap @@ -29,6 +29,7 @@ Ariel Ben-Yehuda Ariel Ben-Yehuda Ariel Ben-Yehuda arielb1 Austin Seipp Aydin Kim aydin.kim +Bastian Kauschke Barosl Lee Barosl LEE Ben Alpert Ben Sago Ben S