From e4d4fa3295bf5bfd8a798557d5cf0158ca453f84 Mon Sep 17 00:00:00 2001 From: James Miller Date: Mon, 4 Apr 2016 19:21:27 +1200 Subject: [PATCH 01/20] Handle operand temps for function calls This allows temporary destinations for function calls to have their allocas omitted. --- src/librustc/middle/region.rs | 5 +- src/librustc/mir/visit.rs | 7 +- src/librustc_trans/mir/analyze.rs | 1 + src/librustc_trans/mir/block.rs | 192 +++++++++++++++++++++++------- src/librustc_trans/mir/lvalue.rs | 31 +++++ 5 files changed, 191 insertions(+), 45 deletions(-) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 2cde6ce93208..5fe70608ec6d 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -45,8 +45,9 @@ impl fmt::Debug for CodeExtent { ty::tls::with_opt(|opt_tcx| { if let Some(tcx) = opt_tcx { - let data = tcx.region_maps.code_extents.borrow()[self.0 as usize]; - write!(f, "/{:?}", data)?; + if let Some(data) = tcx.region_maps.code_extents.borrow().get(self.0 as usize) { + write!(f, "/{:?}", data)?; + } } Ok(()) })?; diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 403c749fe4bc..66c7c4e41c13 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -407,7 +407,7 @@ macro_rules! make_mir_visitor { self.visit_operand(arg); } if let Some((ref $($mutability)* destination, target)) = *destination { - self.visit_lvalue(destination, LvalueContext::Store); + self.visit_lvalue(destination, LvalueContext::Call); self.visit_branch(block, target); } cleanup.map(|t| self.visit_branch(block, t)); @@ -692,9 +692,12 @@ make_mir_visitor!(MutVisitor,mut); #[derive(Copy, Clone, Debug)] pub enum LvalueContext { - // Appears as LHS of an assignment or as dest of a call + // Appears as LHS of an assignment Store, + // Dest of a call + Call, + // Being dropped Drop, diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index 9aa3d6c7dd08..9b7b55842ccd 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -105,6 +105,7 @@ impl<'tcx> Visitor<'tcx> for TempAnalyzer { match *lvalue { mir::Lvalue::Temp(index) => { match context { + LvalueContext::Call | LvalueContext::Consume => { } LvalueContext::Store | diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 3fabdd8fd422..b8417f985650 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -11,7 +11,7 @@ use llvm::{self, BasicBlockRef, ValueRef, OperandBundleDef}; use rustc::ty; use rustc::mir::repr as mir; -use abi::{Abi, FnType}; +use abi::{Abi, FnType, ArgType}; use adt; use base; use build; @@ -25,7 +25,7 @@ use type_of; use glue; use type_::Type; -use super::{MirContext, drop}; +use super::{MirContext, TempRef, drop}; use super::lvalue::{LvalueRef, load_fat_ptr}; use super::operand::OperandRef; use super::operand::OperandValue::{self, FatPtr, Immediate, Ref}; @@ -191,25 +191,10 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { if intrinsic == Some("transmute") { let &(ref dest, target) = destination.as_ref().unwrap(); - let dst = self.trans_lvalue(&bcx, dest); - let mut val = self.trans_operand(&bcx, &args[0]); - if let ty::TyFnDef(def_id, substs, _) = val.ty.sty { - let llouttype = type_of::type_of(bcx.ccx(), dst.ty.to_ty(bcx.tcx())); - let out_type_size = llbitsize_of_real(bcx.ccx(), llouttype); - if out_type_size != 0 { - // FIXME #19925 Remove this hack after a release cycle. - let f = Callee::def(bcx.ccx(), def_id, substs); - let datum = f.reify(bcx.ccx()); - val = OperandRef { - val: OperandValue::Immediate(datum.val), - ty: datum.ty - }; - } - } + self.with_lvalue_ref(&bcx, dest, |this, dest| { + this.trans_transmute(&bcx, &args[0], dest); + }); - let llty = type_of::type_of(bcx.ccx(), val.ty); - let cast_ptr = bcx.pointercast(dst.llval, llty.ptr_to()); - self.store_operand(&bcx, cast_ptr, val); self.set_operand_dropped(&bcx, &args[0]); funclet_br(bcx, self.llblock(target)); return; @@ -227,17 +212,71 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { // Prepare the return value destination let ret_dest = if let Some((ref d, _)) = *destination { - let dest = self.trans_lvalue(&bcx, d); - if fn_ty.ret.is_indirect() { - llargs.push(dest.llval); - None - } else if fn_ty.ret.is_ignore() { - None - } else { - Some(dest) + match *d { + // Handle temporary lvalues, specifically Operand ones, as + // they don't have allocas + mir::Lvalue::Temp(idx) => { + let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), d); + let ret_ty = lvalue_ty.to_ty(bcx.tcx()); + match self.temps[idx as usize] { + TempRef::Lvalue(dest) => { + if fn_ty.ret.is_indirect() { + llargs.push(dest.llval); + ReturnDest::Nothing + } else if fn_ty.ret.is_ignore() { + ReturnDest::Nothing + } else { + ReturnDest::Store(dest.llval) + } + } + TempRef::Operand(None) => { + let is_intrinsic = if let Intrinsic = callee.data { + true + } else { + false + }; + + if fn_ty.ret.is_indirect() { + // Odd, but possible, case, we have an operand temporary, + // but the calling convention has an indirect return. + let tmp = bcx.with_block(|bcx| { + base::alloc_ty(bcx, ret_ty, "tmp_ret") + }); + llargs.push(tmp); + ReturnDest::IndirectOperand(tmp, idx) + } else if is_intrinsic { + // Currently, intrinsics always need a location to store + // the result. so we create a temporary alloca for the + // result + let tmp = bcx.with_block(|bcx| { + base::alloc_ty(bcx, ret_ty, "tmp_ret") + }); + ReturnDest::IndirectOperand(tmp, idx) + } else if fn_ty.ret.is_ignore() { + ReturnDest::Nothing + } else { + ReturnDest::DirectOperand(idx) + } + } + TempRef::Operand(Some(_)) => { + bug!("lvalue temp already assigned to"); + } + } + } + _ => { + let dest = self.trans_lvalue(&bcx, d); + if fn_ty.ret.is_indirect() { + llargs.push(dest.llval); + ReturnDest::Nothing + } else if fn_ty.ret.is_ignore() { + ReturnDest::Nothing + } else { + ReturnDest::Store(dest.llval) + } + } } } else { - None + ReturnDest::Nothing }; // Split the rust-call tupled arguments off. @@ -269,12 +308,15 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { use expr::{Ignore, SaveIn}; use intrinsic::trans_intrinsic_call; - let (dest, llargs) = if fn_ty.ret.is_indirect() { - (SaveIn(llargs[0]), &llargs[1..]) - } else if let Some(dest) = ret_dest { - (SaveIn(dest.llval), &llargs[..]) - } else { - (Ignore, &llargs[..]) + let (dest, llargs) = match ret_dest { + _ if fn_ty.ret.is_indirect() => { + (SaveIn(llargs[0]), &llargs[1..]) + } + ReturnDest::Nothing => (Ignore, &llargs[..]), + ReturnDest::IndirectOperand(dst, _) | + ReturnDest::Store(dst) => (SaveIn(dst), &llargs[..]), + ReturnDest::DirectOperand(_) => + bug!("Cannot use direct operand with an intrinsic call") }; bcx.with_block(|bcx| { @@ -292,6 +334,16 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { // bcx.unreachable(); } }); + + if let ReturnDest::IndirectOperand(dst, _) = ret_dest { + // Make a fake operand for store_return + let op = OperandRef { + val: OperandValue::Ref(dst), + ty: sig.0.output.unwrap() + }; + self.store_return(&bcx, ret_dest, fn_ty.ret, op); + } + return; } Fn(f) => f, @@ -321,9 +373,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { if destination.is_some() { let ret_bcx = ret_bcx.build(); ret_bcx.at_start(|ret_bcx| { - if let Some(ret_dest) = ret_dest { - fn_ty.ret.store(&ret_bcx, invokeret, ret_dest.llval); - } + let op = OperandRef { + val: OperandValue::Immediate(invokeret), + ty: sig.0.output.unwrap() + }; + self.store_return(&ret_bcx, ret_dest, fn_ty.ret, op); for op in args { self.set_operand_dropped(&ret_bcx, op); } @@ -333,9 +387,11 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { let llret = bcx.call(fn_ptr, &llargs, cleanup_bundle.as_ref()); fn_ty.apply_attrs_callsite(llret); if let Some((_, target)) = *destination { - if let Some(ret_dest) = ret_dest { - fn_ty.ret.store(&bcx, llret, ret_dest.llval); - } + let op = OperandRef { + val: OperandValue::Immediate(llret), + ty: sig.0.output.unwrap() + }; + self.store_return(&bcx, ret_dest, fn_ty.ret, op); for op in args { self.set_operand_dropped(&bcx, op); } @@ -544,4 +600,58 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { pub fn llblock(&self, bb: mir::BasicBlock) -> BasicBlockRef { self.blocks[bb.index()].llbb } + + fn trans_transmute(&mut self, bcx: &BlockAndBuilder<'bcx, 'tcx>, + src: &mir::Operand<'tcx>, dst: LvalueRef<'tcx>) { + let mut val = self.trans_operand(bcx, src); + if let ty::TyFnDef(def_id, substs, _) = val.ty.sty { + let llouttype = type_of::type_of(bcx.ccx(), dst.ty.to_ty(bcx.tcx())); + let out_type_size = llbitsize_of_real(bcx.ccx(), llouttype); + if out_type_size != 0 { + // FIXME #19925 Remove this hack after a release cycle. + let f = Callee::def(bcx.ccx(), def_id, substs); + let datum = f.reify(bcx.ccx()); + val = OperandRef { + val: OperandValue::Immediate(datum.val), + ty: datum.ty + }; + } + } + + let llty = type_of::type_of(bcx.ccx(), val.ty); + let cast_ptr = bcx.pointercast(dst.llval, llty.ptr_to()); + self.store_operand(bcx, cast_ptr, val); + } + + // Stores the return value of a function call into it's final location. + fn store_return(&mut self, + bcx: &BlockAndBuilder<'bcx, 'tcx>, + dest: ReturnDest, + ret_ty: ArgType, + op: OperandRef<'tcx>) { + use self::ReturnDest::*; + + match dest { + Nothing => (), + Store(dst) => ret_ty.store(bcx, op.immediate(), dst), + IndirectOperand(tmp, idx) => { + let op = self.trans_load(bcx, tmp, op.ty); + self.temps[idx as usize] = TempRef::Operand(Some(op)); + } + DirectOperand(idx) => { + self.temps[idx as usize] = TempRef::Operand(Some(op)); + } + } + } +} + +enum ReturnDest { + // Do nothing, the return value is indirect or ignored + Nothing, + // Store the return value to the pointer + Store(ValueRef), + // Stores an indirect return value to an operand temporary lvalue + IndirectOperand(ValueRef, u32), + // Stores a direct return value to an operand temporary lvalue + DirectOperand(u32) } diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs index c9087181f9dd..5a0992a6b6b4 100644 --- a/src/librustc_trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -207,6 +207,37 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { } } + // Perform an action using the given Lvalue. + // If the Lvalue is an empty TempRef::Operand, then a temporary stack slot + // is created first, then used as an operand to update the Lvalue. + pub fn with_lvalue_ref(&mut self, bcx: &BlockAndBuilder<'bcx, 'tcx>, + lvalue: &mir::Lvalue<'tcx>, f: F) -> U + where F: FnOnce(&mut Self, LvalueRef<'tcx>) -> U + { + match *lvalue { + mir::Lvalue::Temp(idx) => { + match self.temps[idx as usize] { + TempRef::Lvalue(lvalue) => f(self, lvalue), + TempRef::Operand(None) => { + let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), lvalue); + let lvalue = LvalueRef::alloca(bcx, lvalue_ty.to_ty(bcx.tcx()), "lvalue_temp"); + let ret = f(self, lvalue); + let op = self.trans_load(bcx, lvalue.llval, lvalue_ty.to_ty(bcx.tcx())); + self.temps[idx as usize] = TempRef::Operand(Some(op)); + ret + } + TempRef::Operand(Some(_)) => { + bug!("Lvalue temp already set"); + } + } + } + _ => { + let lvalue = self.trans_lvalue(bcx, lvalue); + f(self, lvalue) + } + } + } + /// Adjust the bitwidth of an index since LLVM is less forgiving /// than we are. /// From 1e9595e1169a31b518d72c9c64e990a20faec869 Mon Sep 17 00:00:00 2001 From: pierzchalski Date: Mon, 4 Apr 2016 19:44:38 +1000 Subject: [PATCH 02/20] Change build_helper to modify suffix of cc This should help avoid issues when using tools like ccache. --- src/build_helper/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 092a1cabc746..87e93afcf09b 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -43,10 +43,16 @@ pub fn cc2ar(cc: &Path, target: &str) -> PathBuf { if target.contains("musl") || target.contains("msvc") { PathBuf::from("ar") } else { + let parent = cc.parent().unwrap(); let file = cc.file_name().unwrap().to_str().unwrap(); - cc.parent().unwrap().join(file.replace("gcc", "ar") - .replace("cc", "ar") - .replace("clang", "ar")) + for suffix in &["gcc", "cc", "clang"] { + if let Some(idx) = file.rfind(suffix) { + let mut file = file[..idx].to_owned(); + file.push_str(suffix); + return parent.join(&file); + } + } + parent.join(file) } } From 0fe1359885288537833d4b8cd6db724b46ea07b7 Mon Sep 17 00:00:00 2001 From: pierzchalski Date: Mon, 4 Apr 2016 21:14:15 +1000 Subject: [PATCH 03/20] whoops --- src/build_helper/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 87e93afcf09b..8e1da69cf02e 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -48,7 +48,7 @@ pub fn cc2ar(cc: &Path, target: &str) -> PathBuf { for suffix in &["gcc", "cc", "clang"] { if let Some(idx) = file.rfind(suffix) { let mut file = file[..idx].to_owned(); - file.push_str(suffix); + file.push_str("ar"); return parent.join(&file); } } From c822546c9ebd79a245ca171a56f452b373ab623f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 4 Apr 2016 11:24:44 -0700 Subject: [PATCH 04/20] mk: Hardcode the bootstrap key for each release Starting with the 1.10.0 release we would like to bootstrap all compilers from the previous stable release. For example the 1.10.0 compiler should bootstrap from the literal 1.9.0 release artifacts. To do this, however, we need a way to enable unstable features temporarily in a stable compiler (as the released compiler is stable), but it turns out we already have a way to do that! At compile time the configure script selects a `CFG_BOOTSTRAP_KEY` variable value and then exports it into the makefiles. If the `RUSTC_BOOTSTRAP_KEY` environment variable is set to this value, then the compiler is allowed to "cheat" and use unstable features. This method of choosing the bootstrap key, however, is problematic for the intention of bootstrapping from the previous release. Each time a 1.9.0 compiler is created, a new bootstrap key will be selected. That means that the 1.10.0 compiler will only compile from *our* literal release artifacts. Instead distributions would like to bootstrap from their own compilers, so instead we simply hardcode the bootstrap key for each release. This patch uses the same `CFG_FILENAME_EXTRA` value (a hash of the release string) as the bootstrap key. Consequently all 1.9.0 compilers, no matter where they are compiled, will have the same bootstrap key. Additionally we won't need to keep updating this as it'll be based on the release number anyway. Once the 1.9.0 beta has been created, we can update the 1.10.0 nightly sources (the `master` branch at that time) to bootstrap from that release using this hard-coded bootstrap key. We will likely just hardcode into the makefiles what the previous bootstrap key was and we'll change that whenever the stage0 compiler is updated. --- configure | 12 ------------ mk/main.mk | 11 +++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 2a18beeb8c95..84ed6fa89542 100755 --- a/configure +++ b/configure @@ -716,18 +716,6 @@ if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; f if [ -n "$CFG_ENABLE_ORBIT" ]; then putvar CFG_ENABLE_ORBIT; fi -# A magic value that allows the compiler to use unstable features -# during the bootstrap even when doing so would normally be an error -# because of feature staging or because the build turns on -# warnings-as-errors and unstable features default to warnings. The -# build has to match this key in an env var. Meant to be a mild -# deterrent from users just turning on unstable features on the stable -# channel. -# Basing CFG_BOOTSTRAP_KEY on CFG_BOOTSTRAP_KEY lets it get picked up -# during a Makefile reconfig. -CFG_BOOTSTRAP_KEY="${CFG_BOOTSTRAP_KEY-`date +%H:%M:%S`}" -putvar CFG_BOOTSTRAP_KEY - step_msg "looking for build programs" probe_need CFG_CURLORWGET curl wget diff --git a/mk/main.mk b/mk/main.mk index a32658ddcefd..9b8080f96610 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -24,6 +24,17 @@ CFG_PRERELEASE_VERSION=.1 # versions in the same place CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND)) +# A magic value that allows the compiler to use unstable features during the +# bootstrap even when doing so would normally be an error because of feature +# staging or because the build turns on warnings-as-errors and unstable features +# default to warnings. The build has to match this key in an env var. +# +# This value is keyed off the release to ensure that all compilers for one +# particular release have the same bootstrap key. Note that this is +# intentionally not "secure" by any definition, this is largely just a deterrent +# from users enabling unstable features on the stable compiler. +CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA) + ifeq ($(CFG_RELEASE_CHANNEL),stable) # This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly" CFG_RELEASE=$(CFG_RELEASE_NUM) From 0936b5885d5886304ecb8639882f2e5a6d20ab7d Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Tue, 5 Apr 2016 11:02:49 +0200 Subject: [PATCH 05/20] Remove strange names created by lack of privacy-conscious name lookup The fixed issue that allowed this was #12808. --- src/liballoc/arc.rs | 44 ++++++++++++--------------- src/liballoc/rc.rs | 42 ++++++++++++------------- src/libcore/cell.rs | 74 +++++++++++++++++++++------------------------ 3 files changed, 74 insertions(+), 86 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 055029dddcdd..79bd5a913448 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -124,9 +124,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; #[unsafe_no_drop_flag] #[stable(feature = "rust1", since = "1.0.0")] pub struct Arc { - // FIXME #12808: strange name to try to avoid interfering with - // field accesses of the contained type via Deref - _ptr: Shared>, + ptr: Shared>, } #[stable(feature = "rust1", since = "1.0.0")] @@ -144,9 +142,7 @@ impl, U: ?Sized> CoerceUnsized> for Arc {} #[unsafe_no_drop_flag] #[stable(feature = "arc_weak", since = "1.4.0")] pub struct Weak { - // FIXME #12808: strange name to try to avoid interfering with - // field accesses of the contained type via Deref - _ptr: Shared>, + ptr: Shared>, } #[stable(feature = "arc_weak", since = "1.4.0")] @@ -198,7 +194,7 @@ impl Arc { weak: atomic::AtomicUsize::new(1), data: data, }; - Arc { _ptr: unsafe { Shared::new(Box::into_raw(x)) } } + Arc { ptr: unsafe { Shared::new(Box::into_raw(x)) } } } /// Unwraps the contained value if the `Arc` has exactly one strong reference. @@ -230,11 +226,11 @@ impl Arc { atomic::fence(Acquire); unsafe { - let ptr = *this._ptr; + let ptr = *this.ptr; let elem = ptr::read(&(*ptr).data); // Make a weak pointer to clean up the implicit strong-weak reference - let _weak = Weak { _ptr: this._ptr }; + let _weak = Weak { ptr: this.ptr }; mem::forget(this); Ok(elem) @@ -274,7 +270,7 @@ impl Arc { // synchronize with the write coming from `is_unique`, so that the // events prior to that write happen before this read. match this.inner().weak.compare_exchange_weak(cur, cur + 1, Acquire, Relaxed) { - Ok(_) => return Weak { _ptr: this._ptr }, + Ok(_) => return Weak { ptr: this.ptr }, Err(old) => cur = old, } } @@ -303,13 +299,13 @@ impl Arc { // `ArcInner` structure itself is `Sync` because the inner data is // `Sync` as well, so we're ok loaning out an immutable pointer to these // contents. - unsafe { &**self._ptr } + unsafe { &**self.ptr } } // Non-inlined part of `drop`. #[inline(never)] unsafe fn drop_slow(&mut self) { - let ptr = *self._ptr; + let ptr = *self.ptr; // Destroy the data at this time, even though we may not free the box // allocation itself (there may still be weak pointers lying around). @@ -367,7 +363,7 @@ impl Clone for Arc { } } - Arc { _ptr: self._ptr } + Arc { ptr: self.ptr } } } @@ -435,7 +431,7 @@ impl Arc { // Materialize our own implicit weak pointer, so that it can clean // up the ArcInner as needed. - let weak = Weak { _ptr: this._ptr }; + let weak = Weak { ptr: this.ptr }; // mark the data itself as already deallocated unsafe { @@ -443,7 +439,7 @@ impl Arc { // here (due to zeroing) because data is no longer accessed by // other threads (due to there being no more strong refs at this // point). - let mut swap = Arc::new(ptr::read(&(**weak._ptr).data)); + let mut swap = Arc::new(ptr::read(&(**weak.ptr).data)); mem::swap(this, &mut swap); mem::forget(swap); } @@ -456,7 +452,7 @@ impl Arc { // As with `get_mut()`, the unsafety is ok because our reference was // either unique to begin with, or became one upon cloning the contents. unsafe { - let inner = &mut **this._ptr; + let inner = &mut **this.ptr; &mut inner.data } } @@ -488,7 +484,7 @@ impl Arc { // the Arc itself to be `mut`, so we're returning the only possible // reference to the inner data. unsafe { - let inner = &mut **this._ptr; + let inner = &mut **this.ptr; Some(&mut inner.data) } } else { @@ -557,7 +553,7 @@ impl Drop for Arc { // This structure has #[unsafe_no_drop_flag], so this drop glue may run // more than once (but it is guaranteed to be zeroed after the first if // it's run more than once) - let thin = *self._ptr as *const (); + let thin = *self.ptr as *const (); if thin as usize == mem::POST_DROP_USIZE { return; @@ -638,7 +634,7 @@ impl Weak { // Relaxed is valid for the same reason it is on Arc's Clone impl match inner.strong.compare_exchange_weak(n, n + 1, Relaxed, Relaxed) { - Ok(_) => return Some(Arc { _ptr: self._ptr }), + Ok(_) => return Some(Arc { ptr: self.ptr }), Err(old) => n = old, } } @@ -647,7 +643,7 @@ impl Weak { #[inline] fn inner(&self) -> &ArcInner { // See comments above for why this is "safe" - unsafe { &**self._ptr } + unsafe { &**self.ptr } } } @@ -681,7 +677,7 @@ impl Clone for Weak { } } - return Weak { _ptr: self._ptr }; + return Weak { ptr: self.ptr }; } } @@ -713,7 +709,7 @@ impl Drop for Weak { /// } // implicit drop /// ``` fn drop(&mut self) { - let ptr = *self._ptr; + let ptr = *self.ptr; let thin = ptr as *const (); // see comments above for why this check is here @@ -885,7 +881,7 @@ impl fmt::Debug for Arc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Arc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Pointer::fmt(&*self._ptr, f) + fmt::Pointer::fmt(&*self.ptr, f) } } @@ -930,7 +926,7 @@ impl Weak { issue = "30425")] pub fn new() -> Weak { unsafe { - Weak { _ptr: Shared::new(Box::into_raw(box ArcInner { + Weak { ptr: Shared::new(Box::into_raw(box ArcInner { strong: atomic::AtomicUsize::new(0), weak: atomic::AtomicUsize::new(1), data: uninitialized(), diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index da803f57a59d..c2f0a9613273 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -184,9 +184,7 @@ struct RcBox { #[unsafe_no_drop_flag] #[stable(feature = "rust1", since = "1.0.0")] pub struct Rc { - // FIXME #12808: strange names to try to avoid interfering with field - // accesses of the contained type via Deref - _ptr: Shared>, + ptr: Shared>, } #[stable(feature = "rust1", since = "1.0.0")] @@ -215,7 +213,7 @@ impl Rc { // pointers, which ensures that the weak destructor never frees // the allocation while the strong destructor is running, even // if the weak pointer is stored inside the strong one. - _ptr: Shared::new(Box::into_raw(box RcBox { + ptr: Shared::new(Box::into_raw(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value: value, @@ -254,7 +252,7 @@ impl Rc { // pointer while also handling drop logic by just crafting a // fake Weak. this.dec_strong(); - let _weak = Weak { _ptr: this._ptr }; + let _weak = Weak { ptr: this.ptr }; forget(this); Ok(val) } @@ -287,7 +285,7 @@ impl Rc { #[stable(feature = "rc_weak", since = "1.4.0")] pub fn downgrade(this: &Self) -> Weak { this.inc_weak(); - Weak { _ptr: this._ptr } + Weak { ptr: this.ptr } } /// Get the number of weak references to this value. @@ -348,7 +346,7 @@ impl Rc { #[stable(feature = "rc_unique", since = "1.4.0")] pub fn get_mut(this: &mut Self) -> Option<&mut T> { if Rc::is_unique(this) { - let inner = unsafe { &mut **this._ptr }; + let inner = unsafe { &mut **this.ptr }; Some(&mut inner.value) } else { None @@ -390,7 +388,7 @@ impl Rc { } else if Rc::weak_count(this) != 0 { // Can just steal the data, all that's left is Weaks unsafe { - let mut swap = Rc::new(ptr::read(&(**this._ptr).value)); + let mut swap = Rc::new(ptr::read(&(**this.ptr).value)); mem::swap(this, &mut swap); swap.dec_strong(); // Remove implicit strong-weak ref (no need to craft a fake @@ -404,7 +402,7 @@ impl Rc { // reference count is guaranteed to be 1 at this point, and we required // the `Rc` itself to be `mut`, so we're returning the only possible // reference to the inner value. - let inner = unsafe { &mut **this._ptr }; + let inner = unsafe { &mut **this.ptr }; &mut inner.value } } @@ -449,7 +447,7 @@ impl Drop for Rc { #[unsafe_destructor_blind_to_params] fn drop(&mut self) { unsafe { - let ptr = *self._ptr; + let ptr = *self.ptr; let thin = ptr as *const (); if thin as usize != mem::POST_DROP_USIZE { @@ -490,7 +488,7 @@ impl Clone for Rc { #[inline] fn clone(&self) -> Rc { self.inc_strong(); - Rc { _ptr: self._ptr } + Rc { ptr: self.ptr } } } @@ -691,7 +689,7 @@ impl fmt::Debug for Rc { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for Rc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Pointer::fmt(&*self._ptr, f) + fmt::Pointer::fmt(&*self.ptr, f) } } @@ -711,9 +709,7 @@ impl From for Rc { #[unsafe_no_drop_flag] #[stable(feature = "rc_weak", since = "1.4.0")] pub struct Weak { - // FIXME #12808: strange names to try to avoid interfering with - // field accesses of the contained type via Deref - _ptr: Shared>, + ptr: Shared>, } #[stable(feature = "rc_weak", since = "1.4.0")] @@ -749,7 +745,7 @@ impl Weak { None } else { self.inc_strong(); - Some(Rc { _ptr: self._ptr }) + Some(Rc { ptr: self.ptr }) } } } @@ -783,7 +779,7 @@ impl Drop for Weak { /// ``` fn drop(&mut self) { unsafe { - let ptr = *self._ptr; + let ptr = *self.ptr; let thin = ptr as *const (); if thin as usize != mem::POST_DROP_USIZE { @@ -816,7 +812,7 @@ impl Clone for Weak { #[inline] fn clone(&self) -> Weak { self.inc_weak(); - Weak { _ptr: self._ptr } + Weak { ptr: self.ptr } } } @@ -848,7 +844,7 @@ impl Weak { pub fn new() -> Weak { unsafe { Weak { - _ptr: Shared::new(Box::into_raw(box RcBox { + ptr: Shared::new(Box::into_raw(box RcBox { strong: Cell::new(0), weak: Cell::new(1), value: uninitialized(), @@ -910,8 +906,8 @@ impl RcBoxPtr for Rc { // the contract anyway. // This allows the null check to be elided in the destructor if we // manipulated the reference count in the same function. - assume(!(*(&self._ptr as *const _ as *const *const ())).is_null()); - &(**self._ptr) + assume(!(*(&self.ptr as *const _ as *const *const ())).is_null()); + &(**self.ptr) } } } @@ -924,8 +920,8 @@ impl RcBoxPtr for Weak { // the contract anyway. // This allows the null check to be elided in the destructor if we // manipulated the reference count in the same function. - assume(!(*(&self._ptr as *const _ as *const *const ())).is_null()); - &(**self._ptr) + assume(!(*(&self.ptr as *const _ as *const *const ())).is_null()); + &(**self.ptr) } } } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index b2cbc29b1c74..a1c7a293af0b 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -390,8 +390,8 @@ impl RefCell { pub fn borrow(&self) -> Ref { match BorrowRef::new(&self.borrow) { Some(b) => Ref { - _value: unsafe { &*self.value.get() }, - _borrow: b, + value: unsafe { &*self.value.get() }, + borrow: b, }, None => panic!("RefCell already mutably borrowed"), } @@ -438,8 +438,8 @@ impl RefCell { pub fn borrow_mut(&self) -> RefMut { match BorrowRefMut::new(&self.borrow) { Some(b) => RefMut { - _value: unsafe { &mut *self.value.get() }, - _borrow: b, + value: unsafe { &mut *self.value.get() }, + borrow: b, }, None => panic!("RefCell already borrowed"), } @@ -491,7 +491,7 @@ impl PartialEq for RefCell { impl Eq for RefCell {} struct BorrowRef<'b> { - _borrow: &'b Cell, + borrow: &'b Cell, } impl<'b> BorrowRef<'b> { @@ -501,7 +501,7 @@ impl<'b> BorrowRef<'b> { WRITING => None, b => { borrow.set(b + 1); - Some(BorrowRef { _borrow: borrow }) + Some(BorrowRef { borrow: borrow }) }, } } @@ -510,9 +510,9 @@ impl<'b> BorrowRef<'b> { impl<'b> Drop for BorrowRef<'b> { #[inline] fn drop(&mut self) { - let borrow = self._borrow.get(); + let borrow = self.borrow.get(); debug_assert!(borrow != WRITING && borrow != UNUSED); - self._borrow.set(borrow - 1); + self.borrow.set(borrow - 1); } } @@ -521,10 +521,10 @@ impl<'b> Clone for BorrowRef<'b> { fn clone(&self) -> BorrowRef<'b> { // Since this Ref exists, we know the borrow flag // is not set to WRITING. - let borrow = self._borrow.get(); + let borrow = self.borrow.get(); debug_assert!(borrow != WRITING && borrow != UNUSED); - self._borrow.set(borrow + 1); - BorrowRef { _borrow: self._borrow } + self.borrow.set(borrow + 1); + BorrowRef { borrow: self.borrow } } } @@ -534,10 +534,8 @@ impl<'b> Clone for BorrowRef<'b> { /// See the [module-level documentation](index.html) for more. #[stable(feature = "rust1", since = "1.0.0")] pub struct Ref<'b, T: ?Sized + 'b> { - // FIXME #12808: strange name to try to avoid interfering with - // field accesses of the contained type via Deref - _value: &'b T, - _borrow: BorrowRef<'b>, + value: &'b T, + borrow: BorrowRef<'b>, } #[stable(feature = "rust1", since = "1.0.0")] @@ -546,7 +544,7 @@ impl<'b, T: ?Sized> Deref for Ref<'b, T> { #[inline] fn deref(&self) -> &T { - self._value + self.value } } @@ -565,8 +563,8 @@ impl<'b, T: ?Sized> Ref<'b, T> { #[inline] pub fn clone(orig: &Ref<'b, T>) -> Ref<'b, T> { Ref { - _value: orig._value, - _borrow: orig._borrow.clone(), + value: orig.value, + borrow: orig.borrow.clone(), } } @@ -594,8 +592,8 @@ impl<'b, T: ?Sized> Ref<'b, T> { where F: FnOnce(&T) -> &U { Ref { - _value: f(orig._value), - _borrow: orig._borrow, + value: f(orig.value), + borrow: orig.borrow, } } @@ -627,9 +625,9 @@ impl<'b, T: ?Sized> Ref<'b, T> { pub fn filter_map(orig: Ref<'b, T>, f: F) -> Option> where F: FnOnce(&T) -> Option<&U> { - f(orig._value).map(move |new| Ref { - _value: new, - _borrow: orig._borrow, + f(orig.value).map(move |new| Ref { + value: new, + borrow: orig.borrow, }) } } @@ -667,8 +665,8 @@ impl<'b, T: ?Sized> RefMut<'b, T> { where F: FnOnce(&mut T) -> &mut U { RefMut { - _value: f(orig._value), - _borrow: orig._borrow, + value: f(orig.value), + borrow: orig.borrow, } } @@ -706,24 +704,24 @@ impl<'b, T: ?Sized> RefMut<'b, T> { pub fn filter_map(orig: RefMut<'b, T>, f: F) -> Option> where F: FnOnce(&mut T) -> Option<&mut U> { - let RefMut { _value, _borrow } = orig; - f(_value).map(move |new| RefMut { - _value: new, - _borrow: _borrow, + let RefMut { value, borrow } = orig; + f(value).map(move |new| RefMut { + value: new, + borrow: borrow, }) } } struct BorrowRefMut<'b> { - _borrow: &'b Cell, + borrow: &'b Cell, } impl<'b> Drop for BorrowRefMut<'b> { #[inline] fn drop(&mut self) { - let borrow = self._borrow.get(); + let borrow = self.borrow.get(); debug_assert!(borrow == WRITING); - self._borrow.set(UNUSED); + self.borrow.set(UNUSED); } } @@ -733,7 +731,7 @@ impl<'b> BorrowRefMut<'b> { match borrow.get() { UNUSED => { borrow.set(WRITING); - Some(BorrowRefMut { _borrow: borrow }) + Some(BorrowRefMut { borrow: borrow }) }, _ => None, } @@ -745,10 +743,8 @@ impl<'b> BorrowRefMut<'b> { /// See the [module-level documentation](index.html) for more. #[stable(feature = "rust1", since = "1.0.0")] pub struct RefMut<'b, T: ?Sized + 'b> { - // FIXME #12808: strange name to try to avoid interfering with - // field accesses of the contained type via Deref - _value: &'b mut T, - _borrow: BorrowRefMut<'b>, + value: &'b mut T, + borrow: BorrowRefMut<'b>, } #[stable(feature = "rust1", since = "1.0.0")] @@ -757,7 +753,7 @@ impl<'b, T: ?Sized> Deref for RefMut<'b, T> { #[inline] fn deref(&self) -> &T { - self._value + self.value } } @@ -765,7 +761,7 @@ impl<'b, T: ?Sized> Deref for RefMut<'b, T> { impl<'b, T: ?Sized> DerefMut for RefMut<'b, T> { #[inline] fn deref_mut(&mut self) -> &mut T { - self._value + self.value } } From 5d56e1daed3aab8149ecbf69baf5bc1785f08627 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Tue, 5 Apr 2016 14:06:20 +0200 Subject: [PATCH 06/20] Specialize equality for [T] and comparison for [u8] Where T is a type that can be compared for equality bytewise, we can use memcmp. We can also use memcmp for PartialOrd, Ord for [u8] and by extension &str. This is an improvement for example for the comparison [u8] == [u8] that used to emit a loop that compared the slices byte by byte. One worry here could be that this introduces function calls to memcmp in contexts where it should really inline the comparison or even optimize it out, but llvm takes care of recognizing memcmp specifically. --- src/libcore/lib.rs | 1 + src/libcore/slice.rs | 151 ++++++++++++++++++++++++++++++++++++----- src/libcore/str/mod.rs | 25 +------ 3 files changed, 139 insertions(+), 38 deletions(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 648b652772ae..fa5e90562d80 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -75,6 +75,7 @@ #![feature(unwind_attributes)] #![feature(repr_simd, platform_intrinsics)] #![feature(rustc_attrs)] +#![feature(specialization)] #![feature(staged_api)] #![feature(unboxed_closures)] #![feature(question_mark)] diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index aa555b44e899..e9cf650af707 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1630,12 +1630,59 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] { } // -// Boilerplate traits +// Comparison traits // +extern { + /// Call implementation provided memcmp + /// + /// Interprets the data as u8. + /// + /// Return 0 for equal, < 0 for less than and > 0 for greater + /// than. + // FIXME(#32610): Return type should be c_int + fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32; +} + #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq<[B]> for [A] where A: PartialEq { fn eq(&self, other: &[B]) -> bool { + SlicePartialEq::equal(self, other) + } + + fn ne(&self, other: &[B]) -> bool { + SlicePartialEq::not_equal(self, other) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl Eq for [T] {} + +#[stable(feature = "rust1", since = "1.0.0")] +impl Ord for [T] { + fn cmp(&self, other: &[T]) -> Ordering { + SliceOrd::compare(self, other) + } +} + +#[stable(feature = "rust1", since = "1.0.0")] +impl PartialOrd for [T] { + fn partial_cmp(&self, other: &[T]) -> Option { + SlicePartialOrd::partial_compare(self, other) + } +} + +// intermediate trait for specialization of slice's PartialEq +trait SlicePartialEq { + fn equal(&self, other: &[B]) -> bool; + fn not_equal(&self, other: &[B]) -> bool; +} + +// Generic slice equality +impl SlicePartialEq for [A] + where A: PartialEq +{ + default fn equal(&self, other: &[B]) -> bool { if self.len() != other.len() { return false; } @@ -1648,7 +1695,8 @@ impl PartialEq<[B]> for [A] where A: PartialEq { true } - fn ne(&self, other: &[B]) -> bool { + + default fn not_equal(&self, other: &[B]) -> bool { if self.len() != other.len() { return true; } @@ -1663,12 +1711,35 @@ impl PartialEq<[B]> for [A] where A: PartialEq { } } -#[stable(feature = "rust1", since = "1.0.0")] -impl Eq for [T] {} +// Use memcmp for bytewise equality when the types allow +impl SlicePartialEq for [A] + where A: PartialEq + BytewiseEquality +{ + fn equal(&self, other: &[A]) -> bool { + if self.len() != other.len() { + return false; + } + unsafe { + let size = mem::size_of_val(self); + memcmp(self.as_ptr() as *const u8, + other.as_ptr() as *const u8, size) == 0 + } + } -#[stable(feature = "rust1", since = "1.0.0")] -impl Ord for [T] { - fn cmp(&self, other: &[T]) -> Ordering { + fn not_equal(&self, other: &[A]) -> bool { + !self.equal(other) + } +} + +// intermediate trait for specialization of slice's PartialOrd +trait SlicePartialOrd { + fn partial_compare(&self, other: &[B]) -> Option; +} + +impl SlicePartialOrd for [A] + where A: PartialOrd +{ + default fn partial_compare(&self, other: &[A]) -> Option { let l = cmp::min(self.len(), other.len()); // Slice to the loop iteration range to enable bound check @@ -1677,19 +1748,32 @@ impl Ord for [T] { let rhs = &other[..l]; for i in 0..l { - match lhs[i].cmp(&rhs[i]) { - Ordering::Equal => (), + match lhs[i].partial_cmp(&rhs[i]) { + Some(Ordering::Equal) => (), non_eq => return non_eq, } } - self.len().cmp(&other.len()) + self.len().partial_cmp(&other.len()) } } -#[stable(feature = "rust1", since = "1.0.0")] -impl PartialOrd for [T] { - fn partial_cmp(&self, other: &[T]) -> Option { +impl SlicePartialOrd for [u8] { + #[inline] + fn partial_compare(&self, other: &[u8]) -> Option { + Some(SliceOrd::compare(self, other)) + } +} + +// intermediate trait for specialization of slice's Ord +trait SliceOrd { + fn compare(&self, other: &[B]) -> Ordering; +} + +impl SliceOrd for [A] + where A: Ord +{ + default fn compare(&self, other: &[A]) -> Ordering { let l = cmp::min(self.len(), other.len()); // Slice to the loop iteration range to enable bound check @@ -1698,12 +1782,47 @@ impl PartialOrd for [T] { let rhs = &other[..l]; for i in 0..l { - match lhs[i].partial_cmp(&rhs[i]) { - Some(Ordering::Equal) => (), + match lhs[i].cmp(&rhs[i]) { + Ordering::Equal => (), non_eq => return non_eq, } } - self.len().partial_cmp(&other.len()) + self.len().cmp(&other.len()) + } +} + +// memcmp compares a sequence of unsigned bytes lexicographically. +// this matches the order we want for [u8], but no others (not even [i8]). +impl SliceOrd for [u8] { + #[inline] + fn compare(&self, other: &[u8]) -> Ordering { + let order = unsafe { + memcmp(self.as_ptr(), other.as_ptr(), + cmp::min(self.len(), other.len())) + }; + if order == 0 { + self.len().cmp(&other.len()) + } else if order < 0 { + Less + } else { + Greater + } + } +} + +/// Trait implemented for types that can be compared for equality using +/// their bytewise representation +trait BytewiseEquality { } + +macro_rules! impl_marker_for { + ($traitname:ident, $($ty:ty)*) => { + $( + impl $traitname for $ty { } + )* } } + +impl_marker_for!(BytewiseEquality, + u8 i8 u16 i16 u32 i32 u64 i64 usize isize char bool); + diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index d5a5e2b47419..305546df5be2 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1150,16 +1150,7 @@ Section: Comparing strings #[lang = "str_eq"] #[inline] fn eq_slice(a: &str, b: &str) -> bool { - a.len() == b.len() && unsafe { cmp_slice(a, b, a.len()) == 0 } -} - -/// Bytewise slice comparison. -/// NOTE: This uses the system's memcmp, which is currently dramatically -/// faster than comparing each byte in a loop. -#[inline] -unsafe fn cmp_slice(a: &str, b: &str, len: usize) -> i32 { - extern { fn memcmp(s1: *const i8, s2: *const i8, n: usize) -> i32; } - memcmp(a.as_ptr() as *const i8, b.as_ptr() as *const i8, len) + a.as_bytes() == b.as_bytes() } /* @@ -1328,8 +1319,7 @@ Section: Trait implementations */ mod traits { - use cmp::{self, Ordering, Ord, PartialEq, PartialOrd, Eq}; - use cmp::Ordering::{Less, Greater}; + use cmp::{Ord, Ordering, PartialEq, PartialOrd, Eq}; use iter::Iterator; use option::Option; use option::Option::Some; @@ -1340,16 +1330,7 @@ mod traits { impl Ord for str { #[inline] fn cmp(&self, other: &str) -> Ordering { - let cmp = unsafe { - super::cmp_slice(self, other, cmp::min(self.len(), other.len())) - }; - if cmp == 0 { - self.len().cmp(&other.len()) - } else if cmp < 0 { - Less - } else { - Greater - } + self.as_bytes().cmp(other.as_bytes()) } } From 28c4d12c031aba96acf72d30dfaa22a51fcf719e Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Tue, 5 Apr 2016 14:06:20 +0200 Subject: [PATCH 07/20] Add test for [u8]'s Ord (and fix the old test for ord) The old test for Ord used no asserts, and appeared to have a wrong test. (!). --- src/libcollectionstest/slice.rs | 42 ++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index ca2ee0c512bf..236c151891d1 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -574,18 +574,48 @@ fn test_slice_2() { assert_eq!(v[1], 3); } +macro_rules! assert_order { + (Greater, $a:expr, $b:expr) => { + assert_eq!($a.cmp($b), Greater); + assert!($a > $b); + }; + (Less, $a:expr, $b:expr) => { + assert_eq!($a.cmp($b), Less); + assert!($a < $b); + }; + (Equal, $a:expr, $b:expr) => { + assert_eq!($a.cmp($b), Equal); + assert_eq!($a, $b); + } +} + +#[test] +fn test_total_ord_u8() { + let c = &[1u8, 2, 3]; + assert_order!(Greater, &[1u8, 2, 3, 4][..], &c[..]); + let c = &[1u8, 2, 3, 4]; + assert_order!(Less, &[1u8, 2, 3][..], &c[..]); + let c = &[1u8, 2, 3, 6]; + assert_order!(Equal, &[1u8, 2, 3, 6][..], &c[..]); + let c = &[1u8, 2, 3, 4, 5, 6]; + assert_order!(Less, &[1u8, 2, 3, 4, 5, 5, 5, 5][..], &c[..]); + let c = &[1u8, 2, 3, 4]; + assert_order!(Greater, &[2u8, 2][..], &c[..]); +} + + #[test] -fn test_total_ord() { +fn test_total_ord_i32() { let c = &[1, 2, 3]; - [1, 2, 3, 4][..].cmp(c) == Greater; + assert_order!(Greater, &[1, 2, 3, 4][..], &c[..]); let c = &[1, 2, 3, 4]; - [1, 2, 3][..].cmp(c) == Less; + assert_order!(Less, &[1, 2, 3][..], &c[..]); let c = &[1, 2, 3, 6]; - [1, 2, 3, 4][..].cmp(c) == Equal; + assert_order!(Equal, &[1, 2, 3, 6][..], &c[..]); let c = &[1, 2, 3, 4, 5, 6]; - [1, 2, 3, 4, 5, 5, 5, 5][..].cmp(c) == Less; + assert_order!(Less, &[1, 2, 3, 4, 5, 5, 5, 5][..], &c[..]); let c = &[1, 2, 3, 4]; - [2, 2][..].cmp(c) == Greater; + assert_order!(Greater, &[2, 2][..], &c[..]); } #[test] From af047d9c10be73ca9f450b2e3aa2c5c62483981c Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Tue, 5 Apr 2016 14:00:17 +0100 Subject: [PATCH 08/20] Fix infinite loop in Arc::downgrade --- src/liballoc/arc.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 055029dddcdd..e1f698cb484c 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -263,6 +263,7 @@ impl Arc { loop { // check if the weak counter is currently "locked"; if so, spin. if cur == usize::MAX { + cur = this.inner().weak.load(Relaxed); continue; } From 9ba3d5e9212bb67166d137efd58fcf5d06906c2a Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Tue, 5 Apr 2016 08:38:48 -0700 Subject: [PATCH 09/20] Reinstate fast_reject for overlap checking The initial implementation of specialization did not use the `fast_reject` mechanism when checking for overlap, which caused a serious performance regression in some cases. This commit modifies the specialization graph to use simplified types for fast rejection when possible, and along the way refactors the logic for building the specialization graph. Closes #32499 --- .../traits/specialize/specialization_graph.rs | 205 +++++++++++++----- src/librustc/ty/trait_def.rs | 27 ++- 2 files changed, 162 insertions(+), 70 deletions(-) diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index eaafeb1a969b..9584c5ea193c 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -18,8 +18,9 @@ use middle::def_id::DefId; use infer; use traits::{self, ProjectionMode}; use ty::{self, TyCtxt, ImplOrTraitItem, TraitDef, TypeFoldable}; +use ty::fast_reject::{self, SimplifiedType}; use syntax::ast::Name; -use util::nodemap::DefIdMap; +use util::nodemap::{DefIdMap, FnvHashMap}; /// A per-trait graph of impls in specialization order. At the moment, this /// graph forms a tree rooted with the trait itself, with all other nodes @@ -42,7 +43,124 @@ pub struct Graph { parent: DefIdMap, // the "root" impls are found by looking up the trait's def_id. - children: DefIdMap>, + children: DefIdMap, +} + +/// Children of a given impl, grouped into blanket/non-blanket varieties as is +/// done in `TraitDef`. +struct Children { + // Impls of a trait (or specializations of a given impl). To allow for + // quicker lookup, the impls are indexed by a simplified version of their + // `Self` type: impls with a simplifiable `Self` are stored in + // `nonblanket_impls` keyed by it, while all other impls are stored in + // `blanket_impls`. + // + // A similar division is used within `TraitDef`, but the lists there collect + // together *all* the impls for a trait, and are populated prior to building + // the specialization graph. + + /// Impls of the trait. + nonblanket_impls: FnvHashMap>, + + /// Blanket impls associated with the trait. + blanket_impls: Vec, +} + +/// The result of attempting to insert an impl into a group of children. +enum InsertResult<'a, 'tcx: 'a> { + /// The impl was inserted as a new child in this group of children. + BecameNewSibling, + + /// The impl replaced an existing impl that specializes it. + Replaced(DefId), + + /// The impl is a specialization of an existing child. + ShouldRecurseOn(DefId), + + /// The impl has an unresolvable overlap with an existing child (neither + /// specializes the other). + Overlapped(Overlap<'a, 'tcx>), +} + +impl Children { + fn new() -> Children { + Children { + nonblanket_impls: FnvHashMap(), + blanket_impls: vec![], + } + } + + /// Insert an impl into this set of children without comparing to any existing impls + fn insert_blindly(&mut self, tcx: &TyCtxt, impl_def_id: DefId) { + let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap(); + if let Some(sty) = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false) { + self.nonblanket_impls.entry(sty).or_insert(vec![]).push(impl_def_id) + } else { + self.blanket_impls.push(impl_def_id) + } + } + + /// Attempt to insert an impl into this set of children, while comparing for + /// specialiation relationships. + fn insert<'a, 'tcx>(&mut self, + tcx: &'a TyCtxt<'tcx>, + impl_def_id: DefId, + simplified_self: Option) + -> InsertResult<'a, 'tcx> + { + for slot in match simplified_self { + Some(sty) => self.filtered_mut(sty), + None => self.iter_mut(), + } { + let possible_sibling = *slot; + + let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::Topmost); + let overlap = traits::overlapping_impls(&infcx, possible_sibling, impl_def_id); + + if let Some(impl_header) = overlap { + let le = specializes(tcx, impl_def_id, possible_sibling); + let ge = specializes(tcx, possible_sibling, impl_def_id); + + if le && !ge { + debug!("descending as child of TraitRef {:?}", + tcx.impl_trait_ref(possible_sibling).unwrap()); + + // the impl specializes possible_sibling + return InsertResult::ShouldRecurseOn(possible_sibling); + } else if ge && !le { + debug!("placing as parent of TraitRef {:?}", + tcx.impl_trait_ref(possible_sibling).unwrap()); + + // possible_sibling specializes the impl + *slot = impl_def_id; + return InsertResult::Replaced(possible_sibling); + } else { + // overlap, but no specialization; error out + return InsertResult::Overlapped(Overlap { + with_impl: possible_sibling, + on_trait_ref: impl_header.trait_ref.unwrap(), + in_context: infcx, + }); + } + } + } + + // no overlap with any potential siblings, so add as a new sibling + debug!("placing as new sibling"); + self.insert_blindly(tcx, impl_def_id); + InsertResult::BecameNewSibling + } + + fn iter_mut<'a>(&'a mut self) -> Box + 'a> { + let nonblanket = self.nonblanket_impls.iter_mut().flat_map(|(_, v)| v.iter_mut()); + Box::new(self.blanket_impls.iter_mut().chain(nonblanket)) + } + + fn filtered_mut<'a>(&'a mut self, sty: SimplifiedType) + -> Box + 'a> { + let nonblanket = self.nonblanket_impls.entry(sty).or_insert(vec![]).iter_mut(); + Box::new(self.blanket_impls.iter_mut().chain(nonblanket)) + } } impl Graph { @@ -78,78 +196,53 @@ impl Graph { trait_ref, impl_def_id, trait_def_id); self.parent.insert(impl_def_id, trait_def_id); - self.children.entry(trait_def_id).or_insert(vec![]).push(impl_def_id); + self.children.entry(trait_def_id).or_insert(Children::new()) + .insert_blindly(tcx, impl_def_id); return Ok(()); } let mut parent = trait_def_id; + let simplified = fast_reject::simplify_type(tcx, trait_ref.self_ty(), false); - // Ugly hack around borrowck limitations. Assigned only in the case - // where we bump downward an existing node in the graph. - let child_to_insert; - - 'descend: loop { - let mut possible_siblings = self.children.entry(parent).or_insert(vec![]); - - for slot in possible_siblings.iter_mut() { - let possible_sibling = *slot; - - let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::Topmost); - let overlap = traits::overlapping_impls(&infcx, possible_sibling, impl_def_id); - - if let Some(impl_header) = overlap { - let le = specializes(tcx, impl_def_id, possible_sibling); - let ge = specializes(tcx, possible_sibling, impl_def_id); - - if le && !ge { - debug!("descending as child of TraitRef {:?}", - tcx.impl_trait_ref(possible_sibling).unwrap()); - - // the impl specializes possible_sibling - parent = possible_sibling; - continue 'descend; - } else if ge && !le { - debug!("placing as parent of TraitRef {:?}", - tcx.impl_trait_ref(possible_sibling).unwrap()); - - // possible_sibling specializes the impl - *slot = impl_def_id; - self.parent.insert(impl_def_id, parent); - self.parent.insert(possible_sibling, impl_def_id); - // we have to defer the insertion, because we can't - // relinquish the borrow of `self.children` - child_to_insert = possible_sibling; - break 'descend; - } else { - // overlap, but no specialization; error out - return Err(Overlap { - with_impl: possible_sibling, - on_trait_ref: impl_header.trait_ref.unwrap(), - in_context: infcx, - }); - } + // Descend the specialization tree, where `parent` is the current parent node + loop { + use self::InsertResult::*; + + let insert_result = self.children.entry(parent).or_insert(Children::new()) + .insert(tcx, impl_def_id, simplified); + + match insert_result { + BecameNewSibling => { + break; + } + Replaced(new_child) => { + self.parent.insert(new_child, impl_def_id); + let mut new_children = Children::new(); + new_children.insert_blindly(tcx, new_child); + self.children.insert(impl_def_id, new_children); + break; + } + ShouldRecurseOn(new_parent) => { + parent = new_parent; + } + Overlapped(error) => { + return Err(error); } } - - // no overlap with any potential siblings, so add as a new sibling - debug!("placing as new sibling"); - self.parent.insert(impl_def_id, parent); - possible_siblings.push(impl_def_id); - return Ok(()); } - self.children.insert(impl_def_id, vec![child_to_insert]); + self.parent.insert(impl_def_id, parent); Ok(()) } /// Insert cached metadata mapping from a child impl back to its parent. - pub fn record_impl_from_cstore(&mut self, parent: DefId, child: DefId) { + pub fn record_impl_from_cstore(&mut self, tcx: &TyCtxt, parent: DefId, child: DefId) { if self.parent.insert(child, parent).is_some() { panic!("When recording an impl from the crate store, information about its parent \ was already present."); } - self.children.entry(parent).or_insert(vec![]).push(child); + self.children.entry(parent).or_insert(Children::new()).insert_blindly(tcx, child); } /// The parent of a given impl, which is the def id of the trait when the diff --git a/src/librustc/ty/trait_def.rs b/src/librustc/ty/trait_def.rs index 3ebf2ba4c849..51f330686db6 100644 --- a/src/librustc/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -15,7 +15,7 @@ use ty; use ty::fast_reject; use ty::{Ty, TyCtxt, TraitRef}; use std::borrow::{Borrow}; -use std::cell::{Cell, Ref, RefCell}; +use std::cell::{Cell, RefCell}; use syntax::ast::Name; use rustc_front::hir; use util::nodemap::FnvHashMap; @@ -43,10 +43,17 @@ pub struct TraitDef<'tcx> { /// for resolving `X::Foo` type markers. pub associated_type_names: Vec, - // Impls of this trait. To allow for quicker lookup, the impls are indexed - // by a simplified version of their Self type: impls with a simplifiable - // Self are stored in nonblanket_impls keyed by it, while all other impls - // are stored in blanket_impls. + // Impls of a trait. To allow for quicker lookup, the impls are indexed by a + // simplified version of their `Self` type: impls with a simplifiable `Self` + // are stored in `nonblanket_impls` keyed by it, while all other impls are + // stored in `blanket_impls`. + // + // A similar division is used within `specialization_graph`, but the ones + // here are (1) stored as a flat list for the trait and (2) populated prior + // to -- and used while -- determining specialization order. + // + // FIXME: solve the reentrancy issues and remove these lists in favor of the + // ones in `specialization_graph`. // // These lists are tracked by `DepNode::TraitImpls`; we don't use // a DepTrackingMap but instead have the `TraitDef` insert the @@ -184,7 +191,7 @@ impl<'tcx> TraitDef<'tcx> { // if the impl is non-local, it's placed directly into the // specialization graph using parent information drawn from metadata. self.specialization_graph.borrow_mut() - .record_impl_from_cstore(parent_impl, impl_def_id) + .record_impl_from_cstore(tcx, parent_impl, impl_def_id) } } @@ -261,14 +268,6 @@ impl<'tcx> TraitDef<'tcx> { } } } - - pub fn borrow_impl_lists<'s>(&'s self, tcx: &TyCtxt<'tcx>) - -> (Ref<'s, Vec>, - Ref<'s, FnvHashMap>>) { - self.read_trait_impls(tcx); - (self.blanket_impls.borrow(), self.nonblanket_impls.borrow()) - } - } bitflags! { From 513d9f208cc52ab71e2899db30aaead5c82c1a74 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 29 Mar 2016 19:10:39 +0300 Subject: [PATCH 10/20] remove workaround that prints error messages with TyErr now that normalize_to_error no longer creates these, it is unnecessary. --- src/librustc/traits/error_reporting.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f15b9ee44ce5..cbcac7f9aa48 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -90,12 +90,7 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let predicate = infcx.resolve_type_vars_if_possible(&obligation.predicate); - // The TyError created by normalize_to_error can end up being unified - // into all obligations: for example, if our obligation is something - // like `$X = <() as Foo<$X>>::Out` and () does not implement Foo<_>, - // then $X will be unified with TyError, but the error still needs to be - // reported. - if !infcx.tcx.sess.has_errors() || !predicate.references_error() { + if !predicate.references_error() { let mut err = struct_span_err!(infcx.tcx.sess, obligation.cause.span, E0271, "type mismatch resolving `{}`: {}", predicate, From 8a461d940cc6019bd332b1ea732d79d3216d9108 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 29 Mar 2016 20:12:31 +0300 Subject: [PATCH 11/20] suggest adding a where-clause when that can help suggest adding a where-clause when there is an unmet trait-bound that can be satisfied if some type can implement it. --- src/doc/book/closures.md | 5 +- src/doc/book/concurrency.md | 4 +- src/doc/book/traits.md | 4 +- src/doc/book/vectors.md | 4 +- src/doc/nomicon/coercions.md | 2 +- src/librustc/diagnostics.rs | 3 +- src/librustc/traits/error_reporting.rs | 83 ++++++++++++++++--- ...ed-types-ICE-when-projecting-out-of-err.rs | 2 +- .../associated-types-bound-failure.rs | 2 +- .../associated-types-for-unimpl-trait.rs | 2 +- ...ted-types-invalid-trait-ref-issue-18865.rs | 2 +- .../associated-types-no-suitable-bound.rs | 2 +- ...sociated-types-no-suitable-supertrait-2.rs | 2 +- ...associated-types-no-suitable-supertrait.rs | 4 +- .../compile-fail/associated-types-path-2.rs | 4 +- .../compile-fail/associated-types-unsized.rs | 2 +- .../compile-fail/bad-method-typaram-kind.rs | 2 +- src/test/compile-fail/bad-sized.rs | 6 +- .../builtin-superkinds-double-superkind.rs | 4 +- .../builtin-superkinds-in-metadata.rs | 2 +- .../compile-fail/builtin-superkinds-simple.rs | 2 +- .../builtin-superkinds-typaram-not-send.rs | 2 +- src/test/compile-fail/cast-rfc0401.rs | 4 +- ...bounds-cant-promote-superkind-in-struct.rs | 2 +- .../compile-fail/closure-bounds-subtype.rs | 2 +- src/test/compile-fail/cross-fn-cache-hole.rs | 2 +- .../deriving-no-inner-impl-error-message.rs | 2 +- .../deriving-span-Default-struct.rs | 2 +- .../compile-fail/destructure-trait-ref.rs | 2 +- src/test/compile-fail/dst-bad-assign-2.rs | 2 +- src/test/compile-fail/dst-bad-assign.rs | 2 +- src/test/compile-fail/dst-bad-coerce1.rs | 2 +- src/test/compile-fail/dst-bad-deep.rs | 2 +- .../dst-object-from-unsized-type.rs | 8 +- .../compile-fail/dst-sized-trait-param.rs | 4 +- .../error-should-say-copy-not-pod.rs | 2 +- .../compile-fail/extern-wrong-value-type.rs | 4 +- src/test/compile-fail/fn-trait-formatting.rs | 4 +- src/test/compile-fail/for-loop-bogosity.rs | 2 +- .../compile-fail/hrtb-conflate-regions.rs | 2 +- ...tb-higher-ranker-supertraits-transitive.rs | 2 +- .../hrtb-higher-ranker-supertraits.rs | 4 +- src/test/compile-fail/hrtb-just-for-static.rs | 2 +- .../compile-fail/hrtb-perfect-forwarding.rs | 2 +- src/test/compile-fail/ifmt-unimpl.rs | 2 +- src/test/compile-fail/impl-bounds-checking.rs | 2 +- .../compile-fail/indexing-requires-a-uint.rs | 2 +- src/test/compile-fail/integral-indexing.rs | 16 ++-- src/test/compile-fail/issue-14084.rs | 2 +- src/test/compile-fail/issue-14366.rs | 2 +- src/test/compile-fail/issue-15756.rs | 2 +- src/test/compile-fail/issue-16538.rs | 2 +- src/test/compile-fail/issue-17651.rs | 2 +- .../compile-fail/issue-17718-static-sync.rs | 2 +- src/test/compile-fail/issue-18107.rs | 2 +- src/test/compile-fail/issue-18611.rs | 2 +- src/test/compile-fail/issue-18919.rs | 2 +- src/test/compile-fail/issue-1920-1.rs | 2 +- src/test/compile-fail/issue-1920-2.rs | 2 +- src/test/compile-fail/issue-1920-3.rs | 2 +- src/test/compile-fail/issue-20005.rs | 2 +- src/test/compile-fail/issue-20162.rs | 2 +- src/test/compile-fail/issue-20605.rs | 2 +- src/test/compile-fail/issue-21160.rs | 2 +- ...issue-21659-show-relevant-trait-impls-1.rs | 2 +- ...issue-21659-show-relevant-trait-impls-2.rs | 2 +- src/test/compile-fail/issue-21763.rs | 2 +- src/test/compile-fail/issue-22034.rs | 4 +- src/test/compile-fail/issue-22645.rs | 2 +- src/test/compile-fail/issue-25076.rs | 2 +- src/test/compile-fail/issue-28098.rs | 12 +-- src/test/compile-fail/issue-5035-2.rs | 2 +- src/test/compile-fail/issue-5883.rs | 4 +- src/test/compile-fail/issue-7013.rs | 2 +- src/test/compile-fail/issue-7364.rs | 2 +- src/test/compile-fail/kindck-copy.rs | 22 ++--- .../compile-fail/kindck-impl-type-params-2.rs | 2 +- .../compile-fail/kindck-impl-type-params.rs | 8 +- src/test/compile-fail/kindck-nonsendable-1.rs | 2 +- src/test/compile-fail/kindck-send-object.rs | 4 +- src/test/compile-fail/kindck-send-object1.rs | 4 +- src/test/compile-fail/kindck-send-object2.rs | 4 +- src/test/compile-fail/kindck-send-owned.rs | 2 +- src/test/compile-fail/kindck-send-unsafe.rs | 2 +- src/test/compile-fail/map-types.rs | 2 +- src/test/compile-fail/mut-not-freeze.rs | 2 +- .../compile-fail/mutable-enum-indirect.rs | 2 +- src/test/compile-fail/no-send-res-ports.rs | 2 +- src/test/compile-fail/no_send-enum.rs | 2 +- src/test/compile-fail/no_send-rc.rs | 2 +- src/test/compile-fail/no_send-struct.rs | 2 +- src/test/compile-fail/no_share-enum.rs | 2 +- src/test/compile-fail/no_share-struct.rs | 2 +- src/test/compile-fail/not-panic-safe-3.rs | 2 +- src/test/compile-fail/not-panic-safe-5.rs | 2 +- src/test/compile-fail/not-panic-safe.rs | 2 +- src/test/compile-fail/not-sync.rs | 14 ++-- .../object-does-not-impl-trait.rs | 2 +- src/test/compile-fail/phantom-oibit.rs | 4 +- src/test/compile-fail/range-1.rs | 4 +- src/test/compile-fail/reflect-assoc.rs | 2 +- src/test/compile-fail/reflect-object-param.rs | 6 +- src/test/compile-fail/reflect.rs | 4 +- .../compile-fail/repeat-to-run-dtor-twice.rs | 2 +- src/test/compile-fail/str-idx.rs | 2 +- src/test/compile-fail/str-mut-idx.rs | 8 +- .../compile-fail/task-rng-isnt-sendable.rs | 2 +- .../trait-bounds-not-on-bare-trait.rs | 2 +- ...rait-bounds-on-structs-and-enums-in-fns.rs | 4 +- ...it-bounds-on-structs-and-enums-in-impls.rs | 2 +- ...rait-bounds-on-structs-and-enums-locals.rs | 4 +- ...rait-bounds-on-structs-and-enums-static.rs | 2 +- .../trait-bounds-on-structs-and-enums-xc.rs | 4 +- .../trait-bounds-on-structs-and-enums-xc1.rs | 4 +- .../trait-bounds-on-structs-and-enums.rs | 14 ++-- .../trait-coercion-generic-bad.rs | 2 +- .../trait-suggest-where-clause.rs | 67 +++++++++++++++ .../compile-fail/traits-negative-impls.rs | 14 ++-- .../traits-repeated-supertrait-ambig.rs | 10 +-- .../type-params-in-different-spaces-2.rs | 4 +- .../typeck-default-trait-impl-assoc-type.rs | 2 +- ...-default-trait-impl-constituent-types-2.rs | 2 +- ...ck-default-trait-impl-constituent-types.rs | 2 +- ...typeck-default-trait-impl-negation-send.rs | 2 +- ...typeck-default-trait-impl-negation-sync.rs | 6 +- .../typeck-default-trait-impl-negation.rs | 4 +- .../typeck-default-trait-impl-precedence.rs | 2 +- .../typeck-default-trait-impl-send-param.rs | 2 +- .../typeck-default-trait-impl-supertrait.rs | 4 +- ...default-trait-impl-trait-where-clause-2.rs | 2 +- ...k-default-trait-impl-trait-where-clause.rs | 2 +- .../typeck-unsafe-always-share.rs | 10 +-- .../compile-fail/ufcs-qpath-self-mismatch.rs | 2 +- .../unboxed-closure-sugar-default.rs | 2 +- .../unboxed-closure-sugar-equiv.rs | 2 +- .../unboxed-closures-fnmut-as-fn.rs | 2 +- .../unboxed-closures-unsafe-extern-fn.rs | 10 +-- .../unboxed-closures-wrong-abi.rs | 10 +-- ...boxed-closures-wrong-arg-type-extern-fn.rs | 10 +-- src/test/compile-fail/unique-unique-kind.rs | 2 +- src/test/compile-fail/unique-vec-res.rs | 4 +- src/test/compile-fail/unsized-bare-typaram.rs | 2 +- src/test/compile-fail/unsized-enum.rs | 4 +- .../unsized-inherent-impl-self-type.rs | 2 +- src/test/compile-fail/unsized-struct.rs | 4 +- .../unsized-trait-impl-self-type.rs | 2 +- .../unsized-trait-impl-trait-arg.rs | 2 +- src/test/compile-fail/unsized3.rs | 12 +-- src/test/compile-fail/unsized5.rs | 12 +-- src/test/compile-fail/unsized6.rs | 24 +++--- src/test/compile-fail/unsized7.rs | 2 +- .../compile-fail/vtable-res-trait-param.rs | 2 +- .../wf-impl-associated-type-trait.rs | 3 +- ...constraints-are-local-for-inherent-impl.rs | 2 +- ...se-constraints-are-local-for-trait-impl.rs | 2 +- .../where-clause-method-substituion.rs | 2 +- .../where-clauses-method-unsatisfied.rs | 2 +- .../compile-fail/where-clauses-unsatisfied.rs | 2 +- src/test/compile-fail/where-for-self-2.rs | 2 +- 159 files changed, 421 insertions(+), 298 deletions(-) create mode 100644 src/test/compile-fail/trait-suggest-where-clause.rs diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md index 2afe995aeea9..1b7a0da0112b 100644 --- a/src/doc/book/closures.md +++ b/src/doc/book/closures.md @@ -371,14 +371,13 @@ assert_eq!(6, answer); This gives us these long, related errors: ```text -error: the trait `core::marker::Sized` is not implemented for the type -`core::ops::Fn(i32) -> i32` [E0277] +error: the predicate `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277] fn factory() -> (Fn(i32) -> i32) { ^~~~~~~~~~~~~~~~ note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time fn factory() -> (Fn(i32) -> i32) { ^~~~~~~~~~~~~~~~ -error: the trait `core::marker::Sized` is not implemented for the type `core::ops::Fn(i32) -> i32` [E0277] +error: the predicate `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277] let f = factory(); ^ note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time diff --git a/src/doc/book/concurrency.md b/src/doc/book/concurrency.md index 87d551b68df0..8b918d3cfeff 100644 --- a/src/doc/book/concurrency.md +++ b/src/doc/book/concurrency.md @@ -231,8 +231,8 @@ fn main() { This won't work, however, and will give us the error: ```text -13:9: 13:22 error: the trait `core::marker::Send` is not - implemented for the type `alloc::rc::Rc>` +13:9: 13:22 error: the predicate `alloc::rc::Rc> : core::marker::Send` + is not satisfied ... 13:9: 13:22 note: `alloc::rc::Rc>` cannot be sent between threads safely diff --git a/src/doc/book/traits.md b/src/doc/book/traits.md index 2a164077683b..00aa33a9308c 100644 --- a/src/doc/book/traits.md +++ b/src/doc/book/traits.md @@ -154,7 +154,7 @@ print_area(5); We get a compile-time error: ```text -error: the trait `HasArea` is not implemented for the type `_` [E0277] +error: the predicate `_ : HasArea` is not satisfied [E0277] ``` ## Trait bounds on generic structs @@ -496,7 +496,7 @@ impl FooBar for Baz { If we forget to implement `Foo`, Rust will tell us: ```text -error: the trait `main::Foo` is not implemented for the type `main::Baz` [E0277] +error: the predicate `main::Baz : main::Foo` is not satisfied [E0277] ``` # Deriving diff --git a/src/doc/book/vectors.md b/src/doc/book/vectors.md index e96dddf8c82c..c98274a6649b 100644 --- a/src/doc/book/vectors.md +++ b/src/doc/book/vectors.md @@ -56,8 +56,8 @@ v[j]; Indexing with a non-`usize` type gives an error that looks like this: ```text -error: the trait `core::ops::Index` is not implemented for the type -`collections::vec::Vec<_>` [E0277] +error: the predicate `collections::vec::Vec<_> : core::ops::Index` +is not satisfied [E0277] v[j]; ^~~~ note: the type `collections::vec::Vec<_>` cannot be indexed by `i32` diff --git a/src/doc/nomicon/coercions.md b/src/doc/nomicon/coercions.md index 1d2897ce3bd1..3fb7f620eeea 100644 --- a/src/doc/nomicon/coercions.md +++ b/src/doc/nomicon/coercions.md @@ -64,7 +64,7 @@ fn main() { ``` ```text -:10:5: 10:8 error: the trait `Trait` is not implemented for the type `&mut i32` [E0277] +:10:5: 10:8 error: the predicate `&mut i32 : Trait` is not satisfied [E0277] :10 foo(t); ^~~ ``` diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 6f06efd0f9f2..51c453c784e9 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1006,8 +1006,7 @@ fn some_func(foo: T) { fn main() { // we now call the method with the i32 type, which doesn't implement // the Foo trait - some_func(5i32); // error: the trait `Foo` is not implemented for the - // type `i32` + some_func(5i32); // error: the predicate `i32 : Foo` is not satisfied } ``` diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index cbcac7f9aa48..82b5dc66f7c4 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -13,10 +13,12 @@ use super::{ FulfillmentErrorCode, MismatchedProjectionTypes, Obligation, + ObligationCause, ObligationCauseCode, OutputTypeParameterMismatch, TraitNotObjectSafe, PredicateObligation, + SelectionContext, SelectionError, ObjectSafetyViolation, MethodViolationCode, @@ -26,8 +28,9 @@ use super::{ use fmt_macros::{Parser, Piece, Position}; use middle::def_id::DefId; use infer::InferCtxt; -use ty::{self, ToPredicate, ToPolyTraitRef, TraitRef, Ty, TyCtxt, TypeFoldable}; +use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; use ty::fast_reject; +use ty::fold::{TypeFoldable, TypeFolder}; use util::nodemap::{FnvHashMap, FnvHashSet}; use std::cmp; @@ -100,9 +103,10 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, } } -fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, - trait_ref: &TraitRef<'tcx>, - span: Span) -> Option { +fn on_unimplemented_note<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, + trait_ref: ty::PolyTraitRef<'tcx>, + span: Span) -> Option { + let trait_ref = trait_ref.skip_binder(); let def_id = trait_ref.def_id; let mut report = None; for item in infcx.tcx.get_attrs(def_id).iter() { @@ -357,14 +361,20 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let trait_ref = trait_predicate.to_poly_trait_ref(); let mut err = struct_span_err!( infcx.tcx.sess, obligation.cause.span, E0277, - "the trait `{}` is not implemented for the type `{}`", - trait_ref, trait_ref.self_ty()); - - // Check if it has a custom "#[rustc_on_unimplemented]" - // error message, report with that message if it does - let custom_note = report_on_unimplemented(infcx, &trait_ref.0, - obligation.cause.span); - if let Some(s) = custom_note { + "the predicate `{}` is not satisfied", + trait_ref.to_predicate()); + + // Try to report a good error message. + + if !trait_ref.has_infer_types() && + predicate_can_apply(infcx, trait_ref) + { + err.fileline_help(obligation.cause.span, &format!( + "consider adding a `where {}` bound", + trait_ref.to_predicate() + )); + } else if let Some(s) = on_unimplemented_note(infcx, trait_ref, + obligation.cause.span) { err.fileline_note(obligation.cause.span, &s); } else { let simp = fast_reject::simplify_type(infcx.tcx, @@ -644,6 +654,55 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, } } +/// Returns whether the trait predicate may apply for *some* assignment +/// to the type parameters. +fn predicate_can_apply<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, + pred: ty::PolyTraitRef<'tcx>) + -> bool +{ + struct ParamToVarFolder<'a, 'tcx: 'a> { + infcx: &'a InferCtxt<'a, 'tcx>, + var_map: FnvHashMap, Ty<'tcx>> + } + + impl<'a, 'tcx> TypeFolder<'tcx> for ParamToVarFolder<'a, 'tcx> + { + fn tcx(&self) -> &TyCtxt<'tcx> { self.infcx.tcx } + + fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { + if let ty::TyParam(..) = ty.sty { + let infcx = self.infcx; + self.var_map.entry(ty).or_insert_with(|| infcx.next_ty_var()) + } else { + ty.super_fold_with(self) + } + } + } + + infcx.probe(|_| { + let mut selcx = SelectionContext::new(infcx); + + let cleaned_pred = pred.fold_with(&mut ParamToVarFolder { + infcx: infcx, + var_map: FnvHashMap() + }); + + let cleaned_pred = super::project::normalize( + &mut selcx, + ObligationCause::dummy(), + &cleaned_pred + ).value; + + let obligation = Obligation::new( + ObligationCause::dummy(), + cleaned_pred.to_predicate() + ); + + selcx.evaluate_obligation(&obligation) + }) +} + + fn need_type_info<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span: Span, ty: Ty<'tcx>) diff --git a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs index c5a47f3e5358..48bfa84fa866 100644 --- a/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs +++ b/src/test/compile-fail/associated-types-ICE-when-projecting-out-of-err.rs @@ -31,5 +31,5 @@ trait Add { fn ice(a: A) { let r = loop {}; r = r + a; - //~^ ERROR not implemented + //~^ ERROR E0277 } diff --git a/src/test/compile-fail/associated-types-bound-failure.rs b/src/test/compile-fail/associated-types-bound-failure.rs index adccd73beae2..cd21fb949cb8 100644 --- a/src/test/compile-fail/associated-types-bound-failure.rs +++ b/src/test/compile-fail/associated-types-bound-failure.rs @@ -24,7 +24,7 @@ pub trait GetToInt fn foo(g: G) -> isize where G : GetToInt { - ToInt::to_int(&g.get()) //~ ERROR not implemented + ToInt::to_int(&g.get()) //~ ERROR E0277 } fn bar(g: G) -> isize diff --git a/src/test/compile-fail/associated-types-for-unimpl-trait.rs b/src/test/compile-fail/associated-types-for-unimpl-trait.rs index 9c173515793f..a8aee5fd0a59 100644 --- a/src/test/compile-fail/associated-types-for-unimpl-trait.rs +++ b/src/test/compile-fail/associated-types-for-unimpl-trait.rs @@ -15,7 +15,7 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait `Get` is not implemented for the type `Self` + //~^ ERROR the predicate `Self : Get` is not satisfied } fn main() { diff --git a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs b/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs index d48cff405a63..32068633df6a 100644 --- a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs +++ b/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs @@ -18,7 +18,7 @@ trait Foo { fn f>(t: &T) { let u: >::Bar = t.get_bar(); - //~^ ERROR the trait `Foo` is not implemented for the type `T` + //~^ ERROR the predicate `T : Foo` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-bound.rs b/src/test/compile-fail/associated-types-no-suitable-bound.rs index fd60896c2988..19f0e27fa55b 100644 --- a/src/test/compile-fail/associated-types-no-suitable-bound.rs +++ b/src/test/compile-fail/associated-types-no-suitable-bound.rs @@ -19,7 +19,7 @@ struct Struct { impl Struct { fn uhoh(foo: ::Value) {} - //~^ ERROR the trait `Get` is not implemented for the type `T` + //~^ ERROR the predicate `T : Get` is not satisfied } fn main() { diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs index bda16c8a85de..63e76f7eeaa5 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs @@ -25,7 +25,7 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait `Get` is not implemented for the type `Self` + //~^ ERROR the predicate `Self : Get` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs index 0b1d6a5b71ad..38f5be37bd1e 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs @@ -25,12 +25,12 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait `Get` is not implemented for the type `Self` + //~^ ERROR the predicate `Self : Get` is not satisfied } impl Other for T { fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} - //~^ ERROR the trait `Get` is not implemented for the type `(T, U)` + //~^ ERROR the predicate `(T, U) : Get` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-path-2.rs b/src/test/compile-fail/associated-types-path-2.rs index c9374d429380..ee228899bb37 100644 --- a/src/test/compile-fail/associated-types-path-2.rs +++ b/src/test/compile-fail/associated-types-path-2.rs @@ -38,12 +38,12 @@ pub fn f1_int_uint() { pub fn f1_uint_uint() { f1(2u32, 4u32); - //~^ ERROR the trait `Foo` is not implemented + //~^ ERROR `u32 : Foo` is not satisfied } pub fn f1_uint_int() { f1(2u32, 4i32); - //~^ ERROR the trait `Foo` is not implemented + //~^ ERROR `u32 : Foo` is not satisfied } pub fn f2_int() { diff --git a/src/test/compile-fail/associated-types-unsized.rs b/src/test/compile-fail/associated-types-unsized.rs index a32d4de77557..468b40e69718 100644 --- a/src/test/compile-fail/associated-types-unsized.rs +++ b/src/test/compile-fail/associated-types-unsized.rs @@ -14,7 +14,7 @@ trait Get { } fn foo(t: T) { - let x = t.get(); //~ ERROR the trait `std::marker::Sized` is not implemented + let x = t.get(); //~ ERROR `::Value : std::marker::Sized` is not } fn main() { diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index 224187c8ac4c..4de6600f2d24 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -9,7 +9,7 @@ // except according to those terms. fn foo() { - 1.bar::(); //~ ERROR `std::marker::Send` is not implemented + 1.bar::(); //~ ERROR `T : std::marker::Send` is not satisfied } trait bar { diff --git a/src/test/compile-fail/bad-sized.rs b/src/test/compile-fail/bad-sized.rs index e9dd0585fa9e..d25d0081c566 100644 --- a/src/test/compile-fail/bad-sized.rs +++ b/src/test/compile-fail/bad-sized.rs @@ -12,7 +12,7 @@ trait Trait {} pub fn main() { let x: Vec = Vec::new(); - //~^ ERROR the trait `std::marker::Sized` is not implemented - //~| ERROR the trait `std::marker::Sized` is not implemented - //~| ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `Trait + Sized : std::marker::Sized` is not satisfied + //~| ERROR `Trait + Sized : std::marker::Sized` is not satisfied + //~| ERROR `Trait + Sized : std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/builtin-superkinds-double-superkind.rs b/src/test/compile-fail/builtin-superkinds-double-superkind.rs index e1bcc63fb2fe..03ab94e5908f 100644 --- a/src/test/compile-fail/builtin-superkinds-double-superkind.rs +++ b/src/test/compile-fail/builtin-superkinds-double-superkind.rs @@ -13,9 +13,9 @@ trait Foo : Send+Sync { } -impl Foo for (T,) { } //~ ERROR the trait `std::marker::Send` is not implemented +impl Foo for (T,) { } //~ ERROR `T : std::marker::Send` is not satisfied -impl Foo for (T,T) { } //~ ERROR the trait `std::marker::Sync` is not implemented +impl Foo for (T,T) { } //~ ERROR `T : std::marker::Sync` is not satisfied impl Foo for (T,T,T) { } // (ok) diff --git a/src/test/compile-fail/builtin-superkinds-in-metadata.rs b/src/test/compile-fail/builtin-superkinds-in-metadata.rs index 5e2ba7a3b9d4..1063280ea265 100644 --- a/src/test/compile-fail/builtin-superkinds-in-metadata.rs +++ b/src/test/compile-fail/builtin-superkinds-in-metadata.rs @@ -22,6 +22,6 @@ struct X(T); impl RequiresShare for X { } impl RequiresRequiresShareAndSend for X { } -//~^ ERROR the trait `std::marker::Send` is not implemented +//~^ ERROR `T : std::marker::Send` is not satisfied fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-simple.rs b/src/test/compile-fail/builtin-superkinds-simple.rs index 7c9c0df412a4..40625fc82aa9 100644 --- a/src/test/compile-fail/builtin-superkinds-simple.rs +++ b/src/test/compile-fail/builtin-superkinds-simple.rs @@ -14,6 +14,6 @@ trait Foo : Send { } impl Foo for std::rc::Rc { } -//~^ ERROR the trait `std::marker::Send` is not implemented +//~^ ERROR `std::rc::Rc : std::marker::Send` is not satisfied fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs index 13ad13223466..7e05c6462ffa 100644 --- a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs +++ b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs @@ -12,6 +12,6 @@ trait Foo : Send { } -impl Foo for T { } //~ ERROR the trait `std::marker::Send` is not implemented +impl Foo for T { } //~ ERROR `T : std::marker::Send` is not satisfied fn main() { } diff --git a/src/test/compile-fail/cast-rfc0401.rs b/src/test/compile-fail/cast-rfc0401.rs index 9653a1357efa..2bc4d82ef0a4 100644 --- a/src/test/compile-fail/cast-rfc0401.rs +++ b/src/test/compile-fail/cast-rfc0401.rs @@ -91,7 +91,7 @@ fn main() let _ = 42usize as *const [u8]; //~ ERROR casting let _ = v as *const [u8]; //~ ERROR cannot cast let _ = fat_v as *const Foo; - //~^ ERROR `std::marker::Sized` is not implemented for the type `[u8]` + //~^ ERROR the predicate `[u8] : std::marker::Sized` is not satisfied //~^^ HELP run `rustc --explain E0277` to see a detailed explanation //~^^^ NOTE `[u8]` does not have a constant size known at compile-time //~^^^^ NOTE required for the cast to the object type `Foo` @@ -106,7 +106,7 @@ fn main() let a : *const str = "hello"; let _ = a as *const Foo; - //~^ ERROR `std::marker::Sized` is not implemented for the type `str` + //~^ ERROR the predicate `str : std::marker::Sized` is not satisfied //~^^ HELP run `rustc --explain E0277` to see a detailed explanation //~^^^ NOTE `str` does not have a constant size known at compile-time //~^^^^ NOTE required for the cast to the object type `Foo` diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index 40085d813789..ed18ed62111c 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -13,7 +13,7 @@ struct X where F: FnOnce() + 'static + Send { } fn foo(blk: F) -> X where F: FnOnce() + 'static { - //~^ ERROR the trait `std::marker::Send` is not implemented for the type + //~^ ERROR `F : std::marker::Send` is not satisfied return X { field: blk }; } diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index c8fe4a1b8d26..b618cd07760d 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -21,7 +21,7 @@ fn give_any(f: F) where F: FnOnce() { fn give_owned(f: F) where F: FnOnce() + Send { take_any(f); - take_const_owned(f); //~ ERROR the trait `std::marker::Sync` is not implemented for the type + take_const_owned(f); //~ ERROR `F : std::marker::Sync` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/cross-fn-cache-hole.rs b/src/test/compile-fail/cross-fn-cache-hole.rs index 7d4c618de665..eb063f5bc8c3 100644 --- a/src/test/compile-fail/cross-fn-cache-hole.rs +++ b/src/test/compile-fail/cross-fn-cache-hole.rs @@ -23,7 +23,7 @@ trait Bar { } // We don't always check where clauses for sanity, but in this case // wfcheck does report an error here: -fn vacuous() //~ ERROR the trait `Bar` is not implemented for the type `i32` +fn vacuous() //~ ERROR the predicate `i32 : Bar` is not satisfied where i32: Foo { // ... the original intention was to check that we don't use that diff --git a/src/test/compile-fail/deriving-no-inner-impl-error-message.rs b/src/test/compile-fail/deriving-no-inner-impl-error-message.rs index 4fc922d32a0e..d767fc326362 100644 --- a/src/test/compile-fail/deriving-no-inner-impl-error-message.rs +++ b/src/test/compile-fail/deriving-no-inner-impl-error-message.rs @@ -18,7 +18,7 @@ struct E { #[derive(Clone)] struct C { x: NoCloneOrEq - //~^ ERROR the trait `std::clone::Clone` is not implemented for the type `NoCloneOrEq` + //~^ ERROR `NoCloneOrEq : std::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/deriving-span-Default-struct.rs b/src/test/compile-fail/deriving-span-Default-struct.rs index e70a1613dc20..6b81804e028b 100644 --- a/src/test/compile-fail/deriving-span-Default-struct.rs +++ b/src/test/compile-fail/deriving-span-Default-struct.rs @@ -17,7 +17,7 @@ struct Error; #[derive(Default)] struct Struct { - x: Error //~ ERROR `std::default::Default` is not implemented + x: Error //~ ERROR `Error : std::default::Default` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index 3c642bd8b705..3e6428c7d579 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -35,7 +35,7 @@ fn main() { // n == m let &x = &1isize as &T; //~ ERROR type `&T` cannot be dereferenced let &&x = &(&1isize as &T); //~ ERROR type `&T` cannot be dereferenced - let box x = box 1isize as Box; //~ ERROR the trait `std::marker::Sized` is not implemented + let box x = box 1isize as Box; //~ ERROR `T : std::marker::Sized` is not satisfied // n > m let &&x = &1isize as &T; diff --git a/src/test/compile-fail/dst-bad-assign-2.rs b/src/test/compile-fail/dst-bad-assign-2.rs index 110413cd3222..6e2380da6a13 100644 --- a/src/test/compile-fail/dst-bad-assign-2.rs +++ b/src/test/compile-fail/dst-bad-assign-2.rs @@ -44,5 +44,5 @@ pub fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let z: Box = Box::new(Bar1 {f: 36}); f5.ptr = *z; - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `ToBar : std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/dst-bad-assign.rs b/src/test/compile-fail/dst-bad-assign.rs index d4221adfa2ac..ab874d4e877c 100644 --- a/src/test/compile-fail/dst-bad-assign.rs +++ b/src/test/compile-fail/dst-bad-assign.rs @@ -49,5 +49,5 @@ pub fn main() { //~| found `Bar1` //~| expected trait ToBar //~| found struct `Bar1` - //~| ERROR the trait `std::marker::Sized` is not implemented for the type `ToBar` + //~| ERROR `ToBar : std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/dst-bad-coerce1.rs b/src/test/compile-fail/dst-bad-coerce1.rs index 2d87345db224..2413bbae84c0 100644 --- a/src/test/compile-fail/dst-bad-coerce1.rs +++ b/src/test/compile-fail/dst-bad-coerce1.rs @@ -28,5 +28,5 @@ pub fn main() { let f1 = Fat { ptr: Foo }; let f2: &Fat = &f1; let f3: &Fat = f2; - //~^ ERROR the trait `Bar` is not implemented for the type `Foo` + //~^ ERROR `Foo : Bar` is not satisfied } diff --git a/src/test/compile-fail/dst-bad-deep.rs b/src/test/compile-fail/dst-bad-deep.rs index 9e23b6ea44e3..0b9d99396f7c 100644 --- a/src/test/compile-fail/dst-bad-deep.rs +++ b/src/test/compile-fail/dst-bad-deep.rs @@ -21,5 +21,5 @@ pub fn main() { let f: Fat<[isize; 3]> = Fat { ptr: [5, 6, 7] }; let g: &Fat<[isize]> = &f; let h: &Fat> = &Fat { ptr: *g }; - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `[isize] : std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/dst-object-from-unsized-type.rs b/src/test/compile-fail/dst-object-from-unsized-type.rs index 68e6bc0ed765..36bd1a98ca91 100644 --- a/src/test/compile-fail/dst-object-from-unsized-type.rs +++ b/src/test/compile-fail/dst-object-from-unsized-type.rs @@ -16,22 +16,22 @@ impl Foo for [u8] {} fn test1(t: &T) { let u: &Foo = t; - //~^ ERROR `std::marker::Sized` is not implemented for the type `T` + //~^ ERROR `T : std::marker::Sized` is not satisfied } fn test2(t: &T) { let v: &Foo = t as &Foo; - //~^ ERROR `std::marker::Sized` is not implemented for the type `T` + //~^ ERROR `T : std::marker::Sized` is not satisfied } fn test3() { let _: &[&Foo] = &["hi"]; - //~^ ERROR `std::marker::Sized` is not implemented for the type `str` + //~^ ERROR `str : std::marker::Sized` is not satisfied } fn test4(x: &[u8]) { let _: &Foo = x as &Foo; - //~^ ERROR `std::marker::Sized` is not implemented for the type `[u8]` + //~^ ERROR `[u8] : std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/dst-sized-trait-param.rs b/src/test/compile-fail/dst-sized-trait-param.rs index 0241c207c9df..375008715635 100644 --- a/src/test/compile-fail/dst-sized-trait-param.rs +++ b/src/test/compile-fail/dst-sized-trait-param.rs @@ -15,9 +15,9 @@ trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized impl Foo<[isize]> for usize { } -//~^ ERROR the trait `std::marker::Sized` is not implemented for the type `[isize]` +//~^ ERROR `[isize] : std::marker::Sized` is not satisfied impl Foo for [usize] { } -//~^ ERROR the trait `std::marker::Sized` is not implemented for the type `[usize]` +//~^ ERROR `[usize] : std::marker::Sized` is not satisfied pub fn main() { } diff --git a/src/test/compile-fail/error-should-say-copy-not-pod.rs b/src/test/compile-fail/error-should-say-copy-not-pod.rs index 14fe14ae3679..8b1e2fc19663 100644 --- a/src/test/compile-fail/error-should-say-copy-not-pod.rs +++ b/src/test/compile-fail/error-should-say-copy-not-pod.rs @@ -13,5 +13,5 @@ fn check_bound(_: T) {} fn main() { - check_bound("nocopy".to_string()); //~ ERROR the trait `std::marker::Copy` is not implemented + check_bound("nocopy".to_string()); //~ ERROR : std::marker::Copy` is not satisfied } diff --git a/src/test/compile-fail/extern-wrong-value-type.rs b/src/test/compile-fail/extern-wrong-value-type.rs index 8437ff766919..89ed960c8913 100644 --- a/src/test/compile-fail/extern-wrong-value-type.rs +++ b/src/test/compile-fail/extern-wrong-value-type.rs @@ -17,6 +17,6 @@ fn main() { // extern functions are extern "C" fn let _x: extern "C" fn() = f; // OK is_fn(f); - //~^ ERROR the trait `std::ops::Fn<()>` is not implemented for the type `extern "C" fn() - //~| ERROR the trait `std::ops::FnOnce<()>` is not implemented for the type `extern "C" fn() + //~^ ERROR `extern "C" fn() {f} : std::ops::Fn<()>` is not satisfied + //~| ERROR `extern "C" fn() {f} : std::ops::FnOnce<()>` is not satisfied } diff --git a/src/test/compile-fail/fn-trait-formatting.rs b/src/test/compile-fail/fn-trait-formatting.rs index 6309beaf4b53..8cbfc520ff44 100644 --- a/src/test/compile-fail/fn-trait-formatting.rs +++ b/src/test/compile-fail/fn-trait-formatting.rs @@ -34,6 +34,6 @@ fn main() { //~| found box needs_fn(1); - //~^ ERROR `std::ops::Fn<(isize,)>` - //~| ERROR `std::ops::FnOnce<(isize,)>` + //~^ ERROR : std::ops::Fn<(isize,)>` + //~| ERROR : std::ops::FnOnce<(isize,)>` } diff --git a/src/test/compile-fail/for-loop-bogosity.rs b/src/test/compile-fail/for-loop-bogosity.rs index de4dd422d4ff..8b127ca17958 100644 --- a/src/test/compile-fail/for-loop-bogosity.rs +++ b/src/test/compile-fail/for-loop-bogosity.rs @@ -24,7 +24,7 @@ pub fn main() { x: 1, y: 2, }; - for x in bogus { //~ ERROR `std::iter::Iterator` is not implemented for the type `MyStruct` + for x in bogus { //~ ERROR `MyStruct : std::iter::Iterator` drop(x); } } diff --git a/src/test/compile-fail/hrtb-conflate-regions.rs b/src/test/compile-fail/hrtb-conflate-regions.rs index 3efe0501267e..845429d4b0c0 100644 --- a/src/test/compile-fail/hrtb-conflate-regions.rs +++ b/src/test/compile-fail/hrtb-conflate-regions.rs @@ -35,6 +35,6 @@ impl<'a> Foo<(&'a isize, &'a isize)> for SomeStruct } fn a() { want_foo1::(); } // OK -- foo wants just one region -fn b() { want_foo2::(); } //~ ERROR not implemented +fn b() { want_foo2::(); } //~ ERROR E0277 fn main() { } diff --git a/src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs b/src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs index 249256f8e01a..b55dccec2d56 100644 --- a/src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs +++ b/src/test/compile-fail/hrtb-higher-ranker-supertraits-transitive.rs @@ -54,7 +54,7 @@ fn want_qux(b: &B) where B : Qux { want_foo_for_any_tcx(b); - want_bar_for_any_ccx(b); //~ ERROR not implemented + want_bar_for_any_ccx(b); //~ ERROR E0277 } fn main() {} diff --git a/src/test/compile-fail/hrtb-higher-ranker-supertraits.rs b/src/test/compile-fail/hrtb-higher-ranker-supertraits.rs index 441ad76b6023..4c5add4aceaa 100644 --- a/src/test/compile-fail/hrtb-higher-ranker-supertraits.rs +++ b/src/test/compile-fail/hrtb-higher-ranker-supertraits.rs @@ -25,7 +25,7 @@ fn want_foo_for_some_tcx<'x,F>(f: &'x F) where F : Foo<'x> { want_foo_for_some_tcx(f); - want_foo_for_any_tcx(f); //~ ERROR not implemented + want_foo_for_any_tcx(f); //~ ERROR E0277 } fn want_foo_for_any_tcx(f: &F) @@ -42,7 +42,7 @@ fn want_bar_for_some_ccx<'x,B>(b: &B) want_foo_for_any_tcx(b); want_bar_for_some_ccx(b); - want_bar_for_any_ccx(b); //~ ERROR not implemented + want_bar_for_any_ccx(b); //~ ERROR E0277 } fn want_bar_for_any_ccx(b: &B) diff --git a/src/test/compile-fail/hrtb-just-for-static.rs b/src/test/compile-fail/hrtb-just-for-static.rs index a1ec4a739e8c..270e6b9f183a 100644 --- a/src/test/compile-fail/hrtb-just-for-static.rs +++ b/src/test/compile-fail/hrtb-just-for-static.rs @@ -31,7 +31,7 @@ fn give_any() { struct StaticInt; impl Foo<&'static isize> for StaticInt { } fn give_static() { - want_hrtb::() //~ ERROR `for<'a> Foo<&'a isize>` is not implemented + want_hrtb::() //~ ERROR `for<'a> StaticInt : Foo<&'a isize>` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/hrtb-perfect-forwarding.rs b/src/test/compile-fail/hrtb-perfect-forwarding.rs index e8ecc0608fc4..24e59e6c29e3 100644 --- a/src/test/compile-fail/hrtb-perfect-forwarding.rs +++ b/src/test/compile-fail/hrtb-perfect-forwarding.rs @@ -53,7 +53,7 @@ fn foo_hrtb_bar_not<'b,T>(mut t: T) // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where // clause only specifies `T : Bar<&'b isize>`. - foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> Bar<&'a isize>` is not implemented for the type `T` + foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> T : Bar<&'a isize>` is not satisfied } fn foo_hrtb_bar_hrtb(mut t: T) diff --git a/src/test/compile-fail/ifmt-unimpl.rs b/src/test/compile-fail/ifmt-unimpl.rs index 19e019b58bc7..dd14d0c91545 100644 --- a/src/test/compile-fail/ifmt-unimpl.rs +++ b/src/test/compile-fail/ifmt-unimpl.rs @@ -10,5 +10,5 @@ fn main() { format!("{:X}", "3"); - //~^ ERROR: the trait `std::fmt::UpperHex` is not implemented + //~^ ERROR: `str : std::fmt::UpperHex` is not satisfied } diff --git a/src/test/compile-fail/impl-bounds-checking.rs b/src/test/compile-fail/impl-bounds-checking.rs index 8c8f67e40abe..12696585a9e6 100644 --- a/src/test/compile-fail/impl-bounds-checking.rs +++ b/src/test/compile-fail/impl-bounds-checking.rs @@ -17,7 +17,7 @@ trait Getter { fn get(&self) -> T; } -impl Getter for isize { //~ ERROR the trait `Clone2` is not implemented +impl Getter for isize { //~ ERROR `isize : Clone2` is not satisfied fn get(&self) -> isize { *self } } diff --git a/src/test/compile-fail/indexing-requires-a-uint.rs b/src/test/compile-fail/indexing-requires-a-uint.rs index 8143ef84467e..f8979686038b 100644 --- a/src/test/compile-fail/indexing-requires-a-uint.rs +++ b/src/test/compile-fail/indexing-requires-a-uint.rs @@ -13,7 +13,7 @@ fn main() { fn bar(_: T) {} - [0][0u8]; //~ ERROR: the trait `std::ops::Index` is not implemented + [0][0u8]; //~ ERROR: `[_] : std::ops::Index` is not satisfied [0][0]; // should infer to be a usize diff --git a/src/test/compile-fail/integral-indexing.rs b/src/test/compile-fail/integral-indexing.rs index 047ab9d2a8fd..897aca66cbfd 100644 --- a/src/test/compile-fail/integral-indexing.rs +++ b/src/test/compile-fail/integral-indexing.rs @@ -13,14 +13,14 @@ pub fn main() { let s: String = "abcdef".to_string(); v[3_usize]; v[3]; - v[3u8]; //~ERROR the trait `std::ops::Index` is not implemented - v[3i8]; //~ERROR the trait `std::ops::Index` is not implemented - v[3u32]; //~ERROR the trait `std::ops::Index` is not implemented - v[3i32]; //~ERROR the trait `std::ops::Index` is not implemented + v[3u8]; //~ERROR : std::ops::Index` is not satisfied + v[3i8]; //~ERROR : std::ops::Index` is not satisfied + v[3u32]; //~ERROR : std::ops::Index` is not satisfied + v[3i32]; //~ERROR : std::ops::Index` is not satisfied s.as_bytes()[3_usize]; s.as_bytes()[3]; - s.as_bytes()[3u8]; //~ERROR the trait `std::ops::Index` is not implemented - s.as_bytes()[3i8]; //~ERROR the trait `std::ops::Index` is not implemented - s.as_bytes()[3u32]; //~ERROR the trait `std::ops::Index` is not implemented - s.as_bytes()[3i32]; //~ERROR the trait `std::ops::Index` is not implemented + s.as_bytes()[3u8]; //~ERROR : std::ops::Index` is not satisfied + s.as_bytes()[3i8]; //~ERROR : std::ops::Index` is not satisfied + s.as_bytes()[3u32]; //~ERROR : std::ops::Index` is not satisfied + s.as_bytes()[3i32]; //~ERROR : std::ops::Index` is not satisfied } diff --git a/src/test/compile-fail/issue-14084.rs b/src/test/compile-fail/issue-14084.rs index dfdbea5f76e0..20da46dcaa29 100644 --- a/src/test/compile-fail/issue-14084.rs +++ b/src/test/compile-fail/issue-14084.rs @@ -13,5 +13,5 @@ fn main() { () <- 0; - //~^ ERROR: the trait `std::ops::Placer<_>` is not implemented + //~^ ERROR: `() : std::ops::Placer<_>` is not satisfied } diff --git a/src/test/compile-fail/issue-14366.rs b/src/test/compile-fail/issue-14366.rs index 4019b265edde..6f4e9887dc6e 100644 --- a/src/test/compile-fail/issue-14366.rs +++ b/src/test/compile-fail/issue-14366.rs @@ -10,5 +10,5 @@ fn main() { let _x = "test" as &::std::any::Any; -//~^ ERROR the trait `std::marker::Sized` is not implemented for the type `str` +//~^ ERROR `str : std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/issue-15756.rs b/src/test/compile-fail/issue-15756.rs index eca6b02dbdc2..790000a3f923 100644 --- a/src/test/compile-fail/issue-15756.rs +++ b/src/test/compile-fail/issue-15756.rs @@ -15,7 +15,7 @@ fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>) { for &mut something -//~^ ERROR the trait `std::marker::Sized` is not implemented for the type `[T]` +//~^ ERROR `[T] : std::marker::Sized` is not satisfied in arg2 { } diff --git a/src/test/compile-fail/issue-16538.rs b/src/test/compile-fail/issue-16538.rs index 3b819916fbd5..79d2224aad6f 100644 --- a/src/test/compile-fail/issue-16538.rs +++ b/src/test/compile-fail/issue-16538.rs @@ -19,7 +19,7 @@ mod Y { } static foo: *const Y::X = Y::foo(Y::x as *const Y::X); -//~^ ERROR the trait `std::marker::Sync` is not implemented for the type +//~^ ERROR `*const usize : std::marker::Sync` is not satisfied //~| ERROR cannot refer to other statics by value, use the address-of operator or a constant instead //~| ERROR E0015 diff --git a/src/test/compile-fail/issue-17651.rs b/src/test/compile-fail/issue-17651.rs index e079ef1ec12f..edd9b6e0c066 100644 --- a/src/test/compile-fail/issue-17651.rs +++ b/src/test/compile-fail/issue-17651.rs @@ -14,5 +14,5 @@ fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. (|| Box::new(*(&[0][..])))(); - //~^ ERROR the trait `std::marker::Sized` is not implemented for the type `[_]` + //~^ ERROR `[_] : std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/issue-17718-static-sync.rs b/src/test/compile-fail/issue-17718-static-sync.rs index 4b53d84f3055..1bb3b7941352 100644 --- a/src/test/compile-fail/issue-17718-static-sync.rs +++ b/src/test/compile-fail/issue-17718-static-sync.rs @@ -17,6 +17,6 @@ impl !Sync for Foo {} static FOO: usize = 3; static BAR: Foo = Foo; -//~^ ERROR: the trait `std::marker::Sync` is not implemented +//~^ ERROR: `Foo : std::marker::Sync` is not satisfied fn main() {} diff --git a/src/test/compile-fail/issue-18107.rs b/src/test/compile-fail/issue-18107.rs index 03a165f18dec..6b40811bf04f 100644 --- a/src/test/compile-fail/issue-18107.rs +++ b/src/test/compile-fail/issue-18107.rs @@ -12,7 +12,7 @@ pub trait AbstractRenderer {} fn _create_render(_: &()) -> AbstractRenderer -//~^ ERROR: the trait `std::marker::Sized` is not implemented +//~^ ERROR: `AbstractRenderer + 'static : std::marker::Sized` is not satisfied { match 0 { _ => unimplemented!() diff --git a/src/test/compile-fail/issue-18611.rs b/src/test/compile-fail/issue-18611.rs index a662e9ca98ee..5318b18be5c7 100644 --- a/src/test/compile-fail/issue-18611.rs +++ b/src/test/compile-fail/issue-18611.rs @@ -9,7 +9,7 @@ // except according to those terms. fn add_state(op: ::State) { -//~^ ERROR the trait `HasState` is not implemented for the type `isize` +//~^ ERROR `isize : HasState` is not satisfied } trait HasState { diff --git a/src/test/compile-fail/issue-18919.rs b/src/test/compile-fail/issue-18919.rs index 11083453d051..2742162de531 100644 --- a/src/test/compile-fail/issue-18919.rs +++ b/src/test/compile-fail/issue-18919.rs @@ -11,7 +11,7 @@ type FuncType<'f> = Fn(&isize) -> isize + 'f; fn ho_func(f: Option) { - //~^ ERROR: the trait `std::marker::Sized` is not implemented for the type + //~^ ERROR: `for<'r> std::ops::Fn(&'r isize) -> isize : std::marker::Sized` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/issue-1920-1.rs b/src/test/compile-fail/issue-1920-1.rs index 8c75d4680fae..f37693d8a584 100644 --- a/src/test/compile-fail/issue-1920-1.rs +++ b/src/test/compile-fail/issue-1920-1.rs @@ -18,5 +18,5 @@ fn assert_clone() where T : Clone { } fn main() { assert_clone::(); - //~^ ERROR the trait `foo::core::clone::Clone` is not implemented for the type `foo::core:: + //~^ ERROR `foo::core::sync::atomic::AtomicBool : foo::core::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/issue-1920-2.rs b/src/test/compile-fail/issue-1920-2.rs index c73a17350648..c8d7bcaecf93 100644 --- a/src/test/compile-fail/issue-1920-2.rs +++ b/src/test/compile-fail/issue-1920-2.rs @@ -16,5 +16,5 @@ fn assert_clone() where T : Clone { } fn main() { assert_clone::(); - //~^ ERROR the trait `bar::clone::Clone` is not implemented for the type `bar::sync::atomic:: + //~^ ERROR `bar::sync::atomic::AtomicBool : bar::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/issue-1920-3.rs b/src/test/compile-fail/issue-1920-3.rs index 0ef7747c8a84..c0252deda24c 100644 --- a/src/test/compile-fail/issue-1920-3.rs +++ b/src/test/compile-fail/issue-1920-3.rs @@ -20,5 +20,5 @@ fn assert_clone() where T : Clone { } fn main() { assert_clone::(); - //~^ ERROR the trait `core::clone::Clone` is not implemented for the type `core::sync::atomic:: + //~^ ERROR `core::sync::atomic::AtomicBool : core::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/issue-20005.rs b/src/test/compile-fail/issue-20005.rs index 23b2532639bc..a54fc0a314b6 100644 --- a/src/test/compile-fail/issue-20005.rs +++ b/src/test/compile-fail/issue-20005.rs @@ -15,7 +15,7 @@ trait From { } trait To { - fn to( //~ ERROR the trait `std::marker::Sized` is not implemented + fn to( //~ ERROR `Self : std::marker::Sized` is not satisfied self ) -> >::Result where Dst: From { From::from(self) diff --git a/src/test/compile-fail/issue-20162.rs b/src/test/compile-fail/issue-20162.rs index c81bcb828248..5e60e2a36f62 100644 --- a/src/test/compile-fail/issue-20162.rs +++ b/src/test/compile-fail/issue-20162.rs @@ -13,5 +13,5 @@ struct X { x: i32 } fn main() { let mut b: Vec = vec![]; b.sort(); - //~^ ERROR the trait `std::cmp::Ord` is not implemented for the type `X` + //~^ ERROR `X : std::cmp::Ord` is not satisfied } diff --git a/src/test/compile-fail/issue-20605.rs b/src/test/compile-fail/issue-20605.rs index c0eea477775b..2634370fe902 100644 --- a/src/test/compile-fail/issue-20605.rs +++ b/src/test/compile-fail/issue-20605.rs @@ -10,7 +10,7 @@ fn changer<'a>(mut things: Box>) { for item in *things { *item = 0 } -//~^ ERROR the trait `std::marker::Sized` is not implemented for the type `std::iter::Iterator +//~^ ERROR `std::iter::Iterator : std::marker::Sized` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/issue-21160.rs b/src/test/compile-fail/issue-21160.rs index f25f87216753..7d9ae0543c75 100644 --- a/src/test/compile-fail/issue-21160.rs +++ b/src/test/compile-fail/issue-21160.rs @@ -16,6 +16,6 @@ impl Bar { #[derive(Hash)] struct Foo(Bar); -//~^ error: the trait `std::hash::Hash` is not implemented for the type `Bar` +//~^ error: `Bar : std::hash::Hash` is not satisfied fn main() {} diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs index 8ea63fdf1762..452ae5df40a9 100644 --- a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs @@ -32,7 +32,7 @@ fn main() { let f1 = Bar; f1.foo(1usize); - //~^ error: the trait `Foo` is not implemented for the type `Bar` + //~^ error: the predicate `Bar : Foo` is not satisfied //~| help: the following implementations were found: //~| help: > //~| help: > diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs index 9460ac19596e..8f52004f598b 100644 --- a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs @@ -36,7 +36,7 @@ fn main() { let f1 = Bar; f1.foo(1usize); - //~^ error: the trait `Foo` is not implemented for the type `Bar` + //~^ error: the predicate `Bar : Foo` is not satisfied //~| help: the following implementations were found: //~| help: > //~| help: > diff --git a/src/test/compile-fail/issue-21763.rs b/src/test/compile-fail/issue-21763.rs index e535567c52e3..2f0611a2086e 100644 --- a/src/test/compile-fail/issue-21763.rs +++ b/src/test/compile-fail/issue-21763.rs @@ -17,5 +17,5 @@ fn foo() {} fn main() { foo::, Rc<()>>>(); - //~^ ERROR: the trait `std::marker::Send` is not implemented for the type `std::rc::Rc<()>` + //~^ ERROR: `std::rc::Rc<()> : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/issue-22034.rs b/src/test/compile-fail/issue-22034.rs index a72839347105..29bef8c966a4 100644 --- a/src/test/compile-fail/issue-22034.rs +++ b/src/test/compile-fail/issue-22034.rs @@ -14,7 +14,7 @@ fn main() { let ptr: *mut () = 0 as *mut _; let _: &mut Fn() = unsafe { &mut *(ptr as *mut Fn()) - //~^ ERROR the trait `std::ops::Fn<()>` is not implemented - //~| ERROR the trait `std::ops::FnOnce<()>` is not implemented + //~^ ERROR `() : std::ops::Fn<()>` is not satisfied + //~| ERROR `() : std::ops::FnOnce<()>` is not satisfied }; } diff --git a/src/test/compile-fail/issue-22645.rs b/src/test/compile-fail/issue-22645.rs index aa7fa82fa29b..402b9a04496e 100644 --- a/src/test/compile-fail/issue-22645.rs +++ b/src/test/compile-fail/issue-22645.rs @@ -22,6 +22,6 @@ impl Add for Bob { fn main() { let b = Bob + 3.5; - b + 3 //~ ERROR: is not implemented + b + 3 //~ ERROR E0277 //~^ ERROR: mismatched types } diff --git a/src/test/compile-fail/issue-25076.rs b/src/test/compile-fail/issue-25076.rs index 40f3b7284961..9d0b559d13d3 100644 --- a/src/test/compile-fail/issue-25076.rs +++ b/src/test/compile-fail/issue-25076.rs @@ -17,5 +17,5 @@ fn do_fold>(init: B, f: F) {} fn bot() -> T { loop {} } fn main() { - do_fold(bot(), ()); //~ ERROR is not implemented for the type `()` + do_fold(bot(), ()); //~ ERROR `() : InOut<_>` is not satisfied } diff --git a/src/test/compile-fail/issue-28098.rs b/src/test/compile-fail/issue-28098.rs index d81abd417f11..aac282370c64 100644 --- a/src/test/compile-fail/issue-28098.rs +++ b/src/test/compile-fail/issue-28098.rs @@ -10,13 +10,13 @@ fn main() { let _ = Iterator::next(&mut ()); - //~^ ERROR the trait `std::iter::Iterator` is not implemented + //~^ ERROR `() : std::iter::Iterator` is not satisfied for _ in false {} - //~^ ERROR the trait `std::iter::Iterator` is not implemented + //~^ ERROR `bool : std::iter::Iterator` is not satisfied let _ = Iterator::next(&mut ()); - //~^ ERROR the trait `std::iter::Iterator` is not implemented + //~^ ERROR `() : std::iter::Iterator` is not satisfied other() } @@ -25,11 +25,11 @@ pub fn other() { // check errors are still reported globally let _ = Iterator::next(&mut ()); - //~^ ERROR the trait `std::iter::Iterator` is not implemented + //~^ ERROR `() : std::iter::Iterator` is not satisfied let _ = Iterator::next(&mut ()); - //~^ ERROR the trait `std::iter::Iterator` is not implemented + //~^ ERROR `() : std::iter::Iterator` is not satisfied for _ in false {} - //~^ ERROR the trait `std::iter::Iterator` is not implemented + //~^ ERROR `bool : std::iter::Iterator` is not satisfied } diff --git a/src/test/compile-fail/issue-5035-2.rs b/src/test/compile-fail/issue-5035-2.rs index a96eb0e721bd..118644ef2cb6 100644 --- a/src/test/compile-fail/issue-5035-2.rs +++ b/src/test/compile-fail/issue-5035-2.rs @@ -11,6 +11,6 @@ trait I {} type K = I+'static; -fn foo(_x: K) {} //~ ERROR: the trait `std::marker::Sized` is not implemented +fn foo(_x: K) {} //~ ERROR: `I + 'static : std::marker::Sized` is not satisfied fn main() {} diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index cc6c797c7661..0058d5af62e4 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -15,8 +15,8 @@ struct Struct { } fn new_struct(r: A+'static) - -> Struct { //~^ ERROR the trait `std::marker::Sized` is not implemented - //~^ ERROR the trait `std::marker::Sized` is not implemented + -> Struct { //~^ ERROR `A + 'static : std::marker::Sized` is not satisfied + //~^ ERROR `A + 'static : std::marker::Sized` is not satisfied Struct { r: r } } diff --git a/src/test/compile-fail/issue-7013.rs b/src/test/compile-fail/issue-7013.rs index 1293bf22b47d..c676c95ad25e 100644 --- a/src/test/compile-fail/issue-7013.rs +++ b/src/test/compile-fail/issue-7013.rs @@ -34,5 +34,5 @@ struct A { fn main() { let a = A {v: box B{v: None} as Box}; - //~^ ERROR the trait `std::marker::Send` is not implemented + //~^ ERROR `std::rc::Rc> : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/issue-7364.rs b/src/test/compile-fail/issue-7364.rs index 726f789983d3..8d4ebbe72071 100644 --- a/src/test/compile-fail/issue-7364.rs +++ b/src/test/compile-fail/issue-7364.rs @@ -16,6 +16,6 @@ use std::cell::RefCell; // Regression test for issue 7364 static boxed: Box> = box RefCell::new(0); //~^ ERROR allocations are not allowed in statics -//~| ERROR the trait `std::marker::Sync` is not implemented for the type +//~| ERROR `std::cell::RefCell : std::marker::Sync` is not satisfied fn main() { } diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index 4bc941628aad..08b4e1a45f33 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -34,14 +34,14 @@ fn test<'a,T,U:Copy>(_: &'a isize) { assert_copy::<&'a [isize]>(); // ...unless they are mutable - assert_copy::<&'static mut isize>(); //~ ERROR `std::marker::Copy` is not implemented - assert_copy::<&'a mut isize>(); //~ ERROR `std::marker::Copy` is not implemented + assert_copy::<&'static mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::<&'a mut isize>(); //~ ERROR : std::marker::Copy` is not satisfied // boxes are not ok - assert_copy::>(); //~ ERROR `std::marker::Copy` is not implemented - assert_copy::(); //~ ERROR `std::marker::Copy` is not implemented - assert_copy:: >(); //~ ERROR `std::marker::Copy` is not implemented - assert_copy::>(); //~ ERROR `std::marker::Copy` is not implemented + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy:: >(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied // borrowed object types are generally ok assert_copy::<&'a Dummy>(); @@ -49,11 +49,11 @@ fn test<'a,T,U:Copy>(_: &'a isize) { assert_copy::<&'static (Dummy+Copy)>(); // owned object types are not ok - assert_copy::>(); //~ ERROR `std::marker::Copy` is not implemented - assert_copy::>(); //~ ERROR `std::marker::Copy` is not implemented + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied // mutable object types are not ok - assert_copy::<&'a mut (Dummy+Copy)>(); //~ ERROR `std::marker::Copy` is not implemented + assert_copy::<&'a mut (Dummy+Copy)>(); //~ ERROR : std::marker::Copy` is not satisfied // unsafe ptrs are ok assert_copy::<*const isize>(); @@ -71,10 +71,10 @@ fn test<'a,T,U:Copy>(_: &'a isize) { assert_copy::(); // structs containing non-POD are not ok - assert_copy::(); //~ ERROR `std::marker::Copy` is not implemented + assert_copy::(); //~ ERROR : std::marker::Copy` is not satisfied // ref counted types are not ok - assert_copy::>(); //~ ERROR `std::marker::Copy` is not implemented + assert_copy::>(); //~ ERROR : std::marker::Copy` is not satisfied } pub fn main() { diff --git a/src/test/compile-fail/kindck-impl-type-params-2.rs b/src/test/compile-fail/kindck-impl-type-params-2.rs index c5c50789e400..cf51e9bd6081 100644 --- a/src/test/compile-fail/kindck-impl-type-params-2.rs +++ b/src/test/compile-fail/kindck-impl-type-params-2.rs @@ -21,5 +21,5 @@ fn take_param(foo: &T) { } fn main() { let x: Box<_> = box 3; take_param(&x); - //~^ ERROR the trait `std::marker::Copy` is not implemented + //~^ ERROR `Box<_> : std::marker::Copy` is not satisfied } diff --git a/src/test/compile-fail/kindck-impl-type-params.rs b/src/test/compile-fail/kindck-impl-type-params.rs index a59c243f12a5..53ad4d1163bf 100644 --- a/src/test/compile-fail/kindck-impl-type-params.rs +++ b/src/test/compile-fail/kindck-impl-type-params.rs @@ -26,13 +26,13 @@ impl Gettable for S {} fn f(val: T) { let t: S = S(marker::PhantomData); let a = &t as &Gettable; - //~^ ERROR the trait `std::marker::Send` is not implemented + //~^ ERROR : std::marker::Send` is not satisfied } fn g(val: T) { let t: S = S(marker::PhantomData); let a: &Gettable = &t; - //~^ ERROR the trait `std::marker::Send` is not implemented + //~^ ERROR : std::marker::Send` is not satisfied } fn foo<'a>() { @@ -44,7 +44,7 @@ fn foo<'a>() { fn foo2<'a>() { let t: Box> = box S(marker::PhantomData); let a = t as Box>; - //~^ ERROR the trait `std::marker::Copy` is not implemented + //~^ ERROR : std::marker::Copy` is not satisfied } fn foo3<'a>() { @@ -52,7 +52,7 @@ fn foo3<'a>() { let t: Box> = box S(marker::PhantomData); let a: Box> = t; - //~^ ERROR the trait `std::marker::Copy` is not implemented + //~^ ERROR : std::marker::Copy` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index a207b8721224..dd77c2c138f4 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -18,5 +18,5 @@ fn bar(_: F) { } fn main() { let x = Rc::new(3); bar(move|| foo(x)); - //~^ ERROR `std::marker::Send` is not implemented + //~^ ERROR : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/kindck-send-object.rs b/src/test/compile-fail/kindck-send-object.rs index 7525ff932bbd..bd0e5642b9cc 100644 --- a/src/test/compile-fail/kindck-send-object.rs +++ b/src/test/compile-fail/kindck-send-object.rs @@ -20,11 +20,11 @@ trait Message : Send { } fn object_ref_with_static_bound_not_ok() { assert_send::<&'static (Dummy+'static)>(); - //~^ ERROR the trait `std::marker::Sync` is not implemented + //~^ ERROR : std::marker::Sync` is not satisfied } fn box_object_with_no_bound_not_ok<'a>() { - assert_send::>(); //~ ERROR the trait `std::marker::Send` is not implemented + assert_send::>(); //~ ERROR : std::marker::Send` is not satisfied } fn object_with_send_bound_ok() { diff --git a/src/test/compile-fail/kindck-send-object1.rs b/src/test/compile-fail/kindck-send-object1.rs index 0e737e1b1627..da56fccde2d4 100644 --- a/src/test/compile-fail/kindck-send-object1.rs +++ b/src/test/compile-fail/kindck-send-object1.rs @@ -18,7 +18,7 @@ trait Dummy { } // careful with object types, who knows what they close over... fn test51<'a>() { assert_send::<&'a Dummy>(); - //~^ ERROR the trait `std::marker::Sync` is not implemented + //~^ ERROR : std::marker::Sync` is not satisfied } fn test52<'a>() { assert_send::<&'a (Dummy+Sync)>(); @@ -37,7 +37,7 @@ fn test61() { // them not ok fn test_71<'a>() { assert_send::>(); - //~^ ERROR the trait `std::marker::Send` is not implemented + //~^ ERROR : std::marker::Send` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/kindck-send-object2.rs b/src/test/compile-fail/kindck-send-object2.rs index 7bc86df57394..e52a6e12efc9 100644 --- a/src/test/compile-fail/kindck-send-object2.rs +++ b/src/test/compile-fail/kindck-send-object2.rs @@ -14,11 +14,11 @@ fn assert_send() { } trait Dummy { } fn test50() { - assert_send::<&'static Dummy>(); //~ ERROR the trait `std::marker::Sync` is not implemented + assert_send::<&'static Dummy>(); //~ ERROR : std::marker::Sync` is not satisfied } fn test53() { - assert_send::>(); //~ ERROR the trait `std::marker::Send` is not implemented + assert_send::>(); //~ ERROR : std::marker::Send` is not satisfied } // ...unless they are properly bounded diff --git a/src/test/compile-fail/kindck-send-owned.rs b/src/test/compile-fail/kindck-send-owned.rs index d7116930fb47..583381a1c28f 100644 --- a/src/test/compile-fail/kindck-send-owned.rs +++ b/src/test/compile-fail/kindck-send-owned.rs @@ -19,7 +19,7 @@ fn test32() { assert_send:: >(); } // but not if they own a bad thing fn test40() { - assert_send::>(); //~ ERROR `std::marker::Send` is not implemented + assert_send::>(); //~ ERROR : std::marker::Send` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/kindck-send-unsafe.rs b/src/test/compile-fail/kindck-send-unsafe.rs index bce765a986a2..c7eca74f7800 100644 --- a/src/test/compile-fail/kindck-send-unsafe.rs +++ b/src/test/compile-fail/kindck-send-unsafe.rs @@ -14,7 +14,7 @@ fn assert_send() { } fn test71<'a>() { assert_send::<*mut &'a isize>(); - //~^ ERROR the trait `core::marker::Send` is not implemented for the type + //~^ ERROR `*mut &'a isize : core::marker::Send` is not satisfied } fn main() { diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index e298a0f62cd8..b2957a71a56c 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -28,5 +28,5 @@ fn main() { let x: Box> = x; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let y: Box> = Box::new(x); - //~^ ERROR the trait `Map` is not implemented + //~^ ERROR `Box> : Map` is not satisfied } diff --git a/src/test/compile-fail/mut-not-freeze.rs b/src/test/compile-fail/mut-not-freeze.rs index a12a3615bc91..a24a91a4d540 100644 --- a/src/test/compile-fail/mut-not-freeze.rs +++ b/src/test/compile-fail/mut-not-freeze.rs @@ -15,5 +15,5 @@ fn f(_: T) {} fn main() { let x = RefCell::new(0); f(x); - //~^ ERROR `std::marker::Sync` is not implemented + //~^ ERROR `std::cell::RefCell<_> : std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/mutable-enum-indirect.rs b/src/test/compile-fail/mutable-enum-indirect.rs index a7e751e7ea95..bb2fdbc555b7 100644 --- a/src/test/compile-fail/mutable-enum-indirect.rs +++ b/src/test/compile-fail/mutable-enum-indirect.rs @@ -24,5 +24,5 @@ fn bar(_: T) {} fn main() { let x = Foo::A(NoSync); - bar(&x); //~ ERROR the trait `std::marker::Sync` is not implemented + bar(&x); //~ ERROR `NoSync : std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index 2bb0343400c2..81d174256ee2 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -33,7 +33,7 @@ fn main() { let x = foo(Port(Rc::new(()))); thread::spawn(move|| { - //~^ ERROR `std::marker::Send` is not implemented + //~^ ERROR `std::rc::Rc<()> : std::marker::Send` is not satisfied let y = x; println!("{:?}", y); }); diff --git a/src/test/compile-fail/no_send-enum.rs b/src/test/compile-fail/no_send-enum.rs index 7505bf69c831..966d932f2a41 100644 --- a/src/test/compile-fail/no_send-enum.rs +++ b/src/test/compile-fail/no_send-enum.rs @@ -24,5 +24,5 @@ fn bar(_: T) {} fn main() { let x = Foo::A(NoSend); bar(x); - //~^ ERROR `std::marker::Send` is not implemented + //~^ ERROR `NoSend : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/no_send-rc.rs b/src/test/compile-fail/no_send-rc.rs index 23926394a235..b6c7e1ad05af 100644 --- a/src/test/compile-fail/no_send-rc.rs +++ b/src/test/compile-fail/no_send-rc.rs @@ -15,5 +15,5 @@ fn bar(_: T) {} fn main() { let x = Rc::new(5); bar(x); - //~^ ERROR `std::marker::Send` is not implemented + //~^ ERROR `std::rc::Rc<_> : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/no_send-struct.rs b/src/test/compile-fail/no_send-struct.rs index 14e18558a717..037753e6c5fa 100644 --- a/src/test/compile-fail/no_send-struct.rs +++ b/src/test/compile-fail/no_send-struct.rs @@ -23,5 +23,5 @@ fn bar(_: T) {} fn main() { let x = Foo { a: 5 }; bar(x); - //~^ ERROR the trait `std::marker::Send` is not implemented + //~^ ERROR `Foo : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/no_share-enum.rs b/src/test/compile-fail/no_share-enum.rs index c9a3084a73e6..be52dd418264 100644 --- a/src/test/compile-fail/no_share-enum.rs +++ b/src/test/compile-fail/no_share-enum.rs @@ -22,5 +22,5 @@ fn bar(_: T) {} fn main() { let x = Foo::A(NoSync); bar(x); - //~^ ERROR the trait `std::marker::Sync` is not implemented + //~^ ERROR `NoSync : std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/no_share-struct.rs b/src/test/compile-fail/no_share-struct.rs index 74549286f7b5..944bcb48ab05 100644 --- a/src/test/compile-fail/no_share-struct.rs +++ b/src/test/compile-fail/no_share-struct.rs @@ -20,5 +20,5 @@ fn bar(_: T) {} fn main() { let x = Foo { a: 5 }; bar(x); - //~^ ERROR the trait `std::marker::Sync` is not implemented + //~^ ERROR `Foo : std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/not-panic-safe-3.rs b/src/test/compile-fail/not-panic-safe-3.rs index 50a69543f7d0..e5de03a08486 100644 --- a/src/test/compile-fail/not-panic-safe-3.rs +++ b/src/test/compile-fail/not-panic-safe-3.rs @@ -18,5 +18,5 @@ use std::cell::RefCell; fn assert() {} fn main() { - assert::>>(); //~ ERROR: is not implemented + assert::>>(); //~ ERROR E0277 } diff --git a/src/test/compile-fail/not-panic-safe-5.rs b/src/test/compile-fail/not-panic-safe-5.rs index 1fa76c21f853..0301c8dd935c 100644 --- a/src/test/compile-fail/not-panic-safe-5.rs +++ b/src/test/compile-fail/not-panic-safe-5.rs @@ -17,5 +17,5 @@ use std::cell::UnsafeCell; fn assert() {} fn main() { - assert::<*const UnsafeCell>(); //~ ERROR: is not implemented + assert::<*const UnsafeCell>(); //~ ERROR E0277 } diff --git a/src/test/compile-fail/not-panic-safe.rs b/src/test/compile-fail/not-panic-safe.rs index f06464c5b1ab..fd0f830a17d8 100644 --- a/src/test/compile-fail/not-panic-safe.rs +++ b/src/test/compile-fail/not-panic-safe.rs @@ -16,5 +16,5 @@ use std::panic::RecoverSafe; fn assert() {} fn main() { - assert::<&mut i32>(); //~ ERROR: RecoverSafe` is not implemented + assert::<&mut i32>(); //~ ERROR: RecoverSafe` is not satisfied } diff --git a/src/test/compile-fail/not-sync.rs b/src/test/compile-fail/not-sync.rs index c9648a18be5f..3955e3a040c5 100644 --- a/src/test/compile-fail/not-sync.rs +++ b/src/test/compile-fail/not-sync.rs @@ -16,19 +16,19 @@ fn test() {} fn main() { test::>(); - //~^ ERROR marker::Sync` is not implemented for the type `std::cell::Cell` + //~^ ERROR `std::cell::Cell : std::marker::Sync` is not satisfied test::>(); - //~^ ERROR marker::Sync` is not implemented for the type `std::cell::RefCell` + //~^ ERROR `std::cell::RefCell : std::marker::Sync` is not satisfied test::>(); - //~^ ERROR marker::Sync` is not implemented for the type `std::rc::Rc` + //~^ ERROR `std::rc::Rc : std::marker::Sync` is not satisfied test::>(); - //~^ ERROR marker::Sync` is not implemented for the type `std::rc::Weak` + //~^ ERROR `std::rc::Weak : std::marker::Sync` is not satisfied test::>(); - //~^ ERROR marker::Sync` is not implemented for the type `std::sync::mpsc::Receiver` + //~^ ERROR `std::sync::mpsc::Receiver : std::marker::Sync` is not satisfied test::>(); - //~^ ERROR marker::Sync` is not implemented for the type `std::sync::mpsc::Sender` + //~^ ERROR `std::sync::mpsc::Sender : std::marker::Sync` is not satisfied test::>(); - //~^ ERROR marker::Sync` is not implemented for the type `std::sync::mpsc::SyncSender` + //~^ ERROR `std::sync::mpsc::SyncSender : std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index efbf3782f979..6673a87e9e4e 100644 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -14,5 +14,5 @@ trait Foo {} fn take_foo(f: F) {} fn take_object(f: Box) { take_foo(f); } -//~^ ERROR the trait `Foo` is not implemented +//~^ ERROR `Box : Foo` is not satisfied fn main() {} diff --git a/src/test/compile-fail/phantom-oibit.rs b/src/test/compile-fail/phantom-oibit.rs index 92def18f8241..0006b29979ca 100644 --- a/src/test/compile-fail/phantom-oibit.rs +++ b/src/test/compile-fail/phantom-oibit.rs @@ -31,11 +31,11 @@ struct Nested(T); fn is_zen(_: T) {} fn not_sync(x: Guard) { - is_zen(x) //~ error: the trait `std::marker::Sync` is not implemented for the type `T` + is_zen(x) //~ error: `T : std::marker::Sync` is not satisfied } fn nested_not_sync(x: Nested>) { - is_zen(x) //~ error: the trait `std::marker::Sync` is not implemented for the type `T` + is_zen(x) //~ error: `T : std::marker::Sync` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/range-1.rs b/src/test/compile-fail/range-1.rs index 46d7666dabc5..25b7465a1641 100644 --- a/src/test/compile-fail/range-1.rs +++ b/src/test/compile-fail/range-1.rs @@ -22,6 +22,6 @@ pub fn main() { // Unsized type. let arr: &[_] = &[1, 2, 3]; let range = *arr..; - //~^ ERROR the trait `std::marker::Sized` is not implemented - //~| ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `[_] : std::marker::Sized` is not satisfied + //~| ERROR `[_] : std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/reflect-assoc.rs b/src/test/compile-fail/reflect-assoc.rs index 9cf0d252c2d5..7cac3f41d546 100644 --- a/src/test/compile-fail/reflect-assoc.rs +++ b/src/test/compile-fail/reflect-assoc.rs @@ -24,7 +24,7 @@ struct Struct(T); fn is_reflect() { } fn a() { - is_reflect::>>(); //~ ERROR not implemented + is_reflect::>>(); //~ ERROR E0277 } fn ok_a() { diff --git a/src/test/compile-fail/reflect-object-param.rs b/src/test/compile-fail/reflect-object-param.rs index 9f074667feb3..476b498ae649 100644 --- a/src/test/compile-fail/reflect-object-param.rs +++ b/src/test/compile-fail/reflect-object-param.rs @@ -23,7 +23,7 @@ struct Struct(T); fn is_reflect() { } fn a() { - is_reflect::(); //~ ERROR not implemented + is_reflect::(); //~ ERROR E0277 } fn ok_a() { @@ -31,7 +31,7 @@ fn ok_a() { } fn b() { - is_reflect::>>(); //~ ERROR not implemented + is_reflect::>>(); //~ ERROR E0277 } fn ok_b() { @@ -39,7 +39,7 @@ fn ok_b() { } fn c() { - is_reflect::>>>(); //~ ERROR not implemented + is_reflect::>>>(); //~ ERROR E0277 } fn main() { diff --git a/src/test/compile-fail/reflect.rs b/src/test/compile-fail/reflect.rs index 701aa5b40bc0..fdd569e2c1b3 100644 --- a/src/test/compile-fail/reflect.rs +++ b/src/test/compile-fail/reflect.rs @@ -22,7 +22,7 @@ struct Struct(T); fn is_reflect() { } fn c() { - is_reflect::>(); //~ ERROR not implemented + is_reflect::>(); //~ ERROR E0277 } fn ok_c() { @@ -30,7 +30,7 @@ fn ok_c() { } fn d() { - is_reflect::<(i32, T)>(); //~ ERROR not implemented + is_reflect::<(i32, T)>(); //~ ERROR E0277 } fn main() { diff --git a/src/test/compile-fail/repeat-to-run-dtor-twice.rs b/src/test/compile-fail/repeat-to-run-dtor-twice.rs index 0a55fe9f9427..3553d0dab312 100644 --- a/src/test/compile-fail/repeat-to-run-dtor-twice.rs +++ b/src/test/compile-fail/repeat-to-run-dtor-twice.rs @@ -25,5 +25,5 @@ impl Drop for Foo { fn main() { let a = Foo { x: 3 }; let _ = [ a; 5 ]; - //~^ ERROR the trait `std::marker::Copy` is not implemented for the type `Foo` + //~^ ERROR `Foo : std::marker::Copy` is not satisfied } diff --git a/src/test/compile-fail/str-idx.rs b/src/test/compile-fail/str-idx.rs index 6af731caaba4..61fa3cbfe69e 100644 --- a/src/test/compile-fail/str-idx.rs +++ b/src/test/compile-fail/str-idx.rs @@ -10,5 +10,5 @@ pub fn main() { let s: &str = "hello"; - let c: u8 = s[4]; //~ ERROR the trait `std::ops::Index<_>` is not implemented + let c: u8 = s[4]; //~ ERROR `str : std::ops::Index<_>` is not satisfied } diff --git a/src/test/compile-fail/str-mut-idx.rs b/src/test/compile-fail/str-mut-idx.rs index 1fbdb3fddce6..f372a17e045c 100644 --- a/src/test/compile-fail/str-mut-idx.rs +++ b/src/test/compile-fail/str-mut-idx.rs @@ -12,11 +12,11 @@ fn bot() -> T { loop {} } fn mutate(s: &mut str) { s[1..2] = bot(); - //~^ ERROR `std::marker::Sized` is not implemented for the type `str` - //~| ERROR `std::marker::Sized` is not implemented for the type `str` + //~^ ERROR `str : std::marker::Sized` is not satisfied + //~| ERROR `str : std::marker::Sized` is not satisfied s[1usize] = bot(); - //~^ ERROR `std::ops::Index` is not implemented for the type `str` - //~| ERROR `std::ops::IndexMut` is not implemented for the type `str` + //~^ ERROR `str : std::ops::Index` is not satisfied + //~| ERROR `str : std::ops::IndexMut` is not satisfied } pub fn main() {} diff --git a/src/test/compile-fail/task-rng-isnt-sendable.rs b/src/test/compile-fail/task-rng-isnt-sendable.rs index 6d1a3ee79401..a11df776e06d 100644 --- a/src/test/compile-fail/task-rng-isnt-sendable.rs +++ b/src/test/compile-fail/task-rng-isnt-sendable.rs @@ -16,5 +16,5 @@ fn test_send() {} pub fn main() { test_send::(); - //~^ ERROR `std::marker::Send` is not implemented + //~^ ERROR : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs index f70b2a904742..0a771ecf63f1 100644 --- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs +++ b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs @@ -15,7 +15,7 @@ trait Foo { // This should emit the less confusing error, not the more confusing one. fn foo(_x: Foo + Send) { - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `Foo + Send + 'static : std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs index dbfda61f5525..6a271a7b7497 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-fns.rs @@ -21,10 +21,10 @@ enum Bar { } fn explode(x: Foo) {} -//~^ ERROR not implemented +//~^ ERROR E0277 fn kaboom(y: Bar) {} -//~^ ERROR not implemented +//~^ ERROR E0277 fn main() { } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs index c647dd38ee38..77abe6f7f747 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-in-impls.rs @@ -28,7 +28,7 @@ trait PolyTrait struct Struct; impl PolyTrait> for Struct { -//~^ ERROR not implemented +//~^ ERROR E0277 } fn main() { diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs index 520691fbecc4..9e680d17fb9e 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-locals.rs @@ -18,10 +18,10 @@ struct Foo { fn main() { let foo = Foo { - //~^ ERROR not implemented + //~^ ERROR E0277 x: 3 }; let baz: Foo = loop { }; - //~^ ERROR not implemented + //~^ ERROR E0277 } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs index d93c9bafaef2..2b59fdcae353 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-static.rs @@ -17,7 +17,7 @@ struct Foo { } static X: Foo = Foo { -//~^ ERROR not implemented +//~^ ERROR E0277 x: 1, }; diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs index 5f95a7ca6e20..975de00d02a3 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc.rs @@ -15,10 +15,10 @@ extern crate trait_bounds_on_structs_and_enums_xc; use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait}; fn explode(x: Foo) {} -//~^ ERROR not implemented +//~^ ERROR E0277 fn kaboom(y: Bar) {} -//~^ ERROR not implemented +//~^ ERROR E0277 fn main() { } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs index 840787022e65..515684bcf42d 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums-xc1.rs @@ -16,10 +16,10 @@ use trait_bounds_on_structs_and_enums_xc::{Bar, Foo, Trait}; fn main() { let foo = Foo { - //~^ ERROR not implemented + //~^ ERROR E0277 x: 3 }; let bar: Bar = return; - //~^ ERROR not implemented + //~^ ERROR E0277 let _ = bar; } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs index e1b005b0c853..8dd38544d3c9 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs @@ -21,32 +21,32 @@ enum Bar { } impl Foo { -//~^ ERROR the trait `Trait` is not implemented +//~^ ERROR `T : Trait` is not satisfied fn uhoh() {} } struct Baz { - a: Foo, //~ ERROR not implemented + a: Foo, //~ ERROR E0277 } enum Boo { - Quux(Bar), //~ ERROR not implemented + Quux(Bar), //~ ERROR E0277 } struct Badness { - b: Foo, //~ ERROR not implemented + b: Foo, //~ ERROR E0277 } enum MoreBadness { - EvenMoreBadness(Bar), //~ ERROR not implemented + EvenMoreBadness(Bar), //~ ERROR E0277 } struct TupleLike( - Foo, //~ ERROR not implemented + Foo, //~ ERROR E0277 ); enum Enum { - DictionaryLike { field: Bar }, //~ ERROR not implemented + DictionaryLike { field: Bar }, //~ ERROR E0277 } fn main() { diff --git a/src/test/compile-fail/trait-coercion-generic-bad.rs b/src/test/compile-fail/trait-coercion-generic-bad.rs index b25af522b247..85c26368f9f2 100644 --- a/src/test/compile-fail/trait-coercion-generic-bad.rs +++ b/src/test/compile-fail/trait-coercion-generic-bad.rs @@ -25,6 +25,6 @@ impl Trait<&'static str> for Struct { fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let s: Box> = Box::new(Struct { person: "Fred" }); - //~^ ERROR the trait `Trait` is not implemented for the type `Struct` + //~^ ERROR `Struct : Trait` is not satisfied s.f(1); } diff --git a/src/test/compile-fail/trait-suggest-where-clause.rs b/src/test/compile-fail/trait-suggest-where-clause.rs new file mode 100644 index 000000000000..8827cccd0f36 --- /dev/null +++ b/src/test/compile-fail/trait-suggest-where-clause.rs @@ -0,0 +1,67 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; + +struct Misc(T); + +fn check() { + // suggest a where-clause, if needed + mem::size_of::(); + //~^ ERROR `U : std::marker::Sized` is not satisfied + //~| HELP E0277 + //~| HELP consider adding a `where U : std::marker::Sized` bound + //~| NOTE required by `std::mem::size_of` + + mem::size_of::>(); + //~^ ERROR `U : std::marker::Sized` is not satisfied + //~| HELP E0277 + //~| HELP consider adding a `where U : std::marker::Sized` bound + //~| NOTE required because it appears within the type `Misc` + //~| NOTE required by `std::mem::size_of` + + // ... even if T occurs as a type parameter + + >::from; + //~^ ERROR `u64 : std::convert::From` is not satisfied + //~| HELP E0277 + //~| HELP consider adding a `where u64 : std::convert::From` bound + //~| NOTE required by `std::convert::From::from` + + ::Item>>::from; + //~^ ERROR `u64 : std::convert::From<::Item>` is not satisfied + //~| HELP E0277 + //~| HELP consider adding a `where u64 : + //~| NOTE required by `std::convert::From::from` + + // ... but not if there are inference variables + + as From>::from; + //~^ ERROR `Misc<_> : std::convert::From` is not satisfied + //~| HELP E0277 + //~| NOTE required by `std::convert::From::from` + + // ... and also not if the error is not related to the type + + mem::size_of::<[T]>(); + //~^ ERROR `[T] : std::marker::Sized` is not satisfied + //~| HELP E0277 + //~| NOTE `[T]` does not have a constant size + //~| NOTE required by `std::mem::size_of` + + mem::size_of::<[&U]>(); + //~^ ERROR `[&U] : std::marker::Sized` is not satisfied + //~| HELP E0277 + //~| NOTE `[&U]` does not have a constant size + //~| NOTE required by `std::mem::size_of` +} + +fn main() { +} diff --git a/src/test/compile-fail/traits-negative-impls.rs b/src/test/compile-fail/traits-negative-impls.rs index 0eb4e230e149..4a266dd07e6b 100644 --- a/src/test/compile-fail/traits-negative-impls.rs +++ b/src/test/compile-fail/traits-negative-impls.rs @@ -31,8 +31,8 @@ fn dummy() { impl !Send for TestType {} Outer(TestType); - //~^ ERROR the trait `std::marker::Send` is not implemented for the type `dummy::TestType` - //~| ERROR the trait `std::marker::Send` is not implemented for the type `dummy::TestType` + //~^ ERROR `dummy::TestType : std::marker::Send` is not satisfied + //~| ERROR `dummy::TestType : std::marker::Send` is not satisfied } fn dummy1b() { @@ -40,7 +40,7 @@ fn dummy1b() { impl !Send for TestType {} is_send(TestType); - //~^ ERROR the trait `std::marker::Send` is not implemented for the type `dummy1b::TestType` + //~^ ERROR `dummy1b::TestType : std::marker::Send` is not satisfied } fn dummy1c() { @@ -48,7 +48,7 @@ fn dummy1c() { impl !Send for TestType {} is_send((8, TestType)); - //~^ ERROR the trait `std::marker::Send` is not implemented for the type `dummy1c::TestType` + //~^ ERROR `dummy1c::TestType : std::marker::Send` is not satisfied } fn dummy2() { @@ -56,7 +56,7 @@ fn dummy2() { impl !Send for TestType {} is_send(Box::new(TestType)); - //~^ ERROR the trait `std::marker::Send` is not implemented for the type `dummy2::TestType` + //~^ ERROR `dummy2::TestType : std::marker::Send` is not satisfied } fn dummy3() { @@ -64,7 +64,7 @@ fn dummy3() { impl !Send for TestType {} is_send(Box::new(Outer2(TestType))); - //~^ ERROR the trait `std::marker::Send` is not implemented for the type `dummy3::TestType` + //~^ ERROR `dummy3::TestType : std::marker::Send` is not satisfied } fn main() { @@ -74,5 +74,5 @@ fn main() { // This will complain about a missing Send impl because `Sync` is implement *just* // for T that are `Send`. Look at #20366 and #19950 is_sync(Outer2(TestType)); - //~^ ERROR the trait `std::marker::Send` is not implemented for the type `main::TestType` + //~^ ERROR `main::TestType : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/traits-repeated-supertrait-ambig.rs b/src/test/compile-fail/traits-repeated-supertrait-ambig.rs index d61ac6f08d99..244f75a35926 100644 --- a/src/test/compile-fail/traits-repeated-supertrait-ambig.rs +++ b/src/test/compile-fail/traits-repeated-supertrait-ambig.rs @@ -33,21 +33,21 @@ impl CompareTo for i64 { impl CompareToInts for i64 { } fn with_obj(c: &CompareToInts) -> bool { - c.same_as(22) //~ ERROR `CompareTo` is not implemented + c.same_as(22) //~ ERROR `CompareToInts : CompareTo` is not satisfied } fn with_trait(c: &C) -> bool { - c.same_as(22) //~ ERROR `CompareTo` is not implemented + c.same_as(22) //~ ERROR `C : CompareTo` is not satisfied } fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22) //~ ERROR `CompareTo` is not implemented + CompareToInts::same_as(c, 22) //~ ERROR `CompareToInts : CompareTo` is not satisfied } fn with_ufcs2(c: &C) -> bool { - CompareTo::same_as(c, 22) //~ ERROR `CompareTo` is not implemented + CompareTo::same_as(c, 22) //~ ERROR `C : CompareTo` is not satisfied } fn main() { - assert_eq!(22_i64.same_as(22), true); //~ ERROR `CompareTo` is not implemented + assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64 : CompareTo` is not satisfied } diff --git a/src/test/compile-fail/type-params-in-different-spaces-2.rs b/src/test/compile-fail/type-params-in-different-spaces-2.rs index 71e9113603a6..d07282763d85 100644 --- a/src/test/compile-fail/type-params-in-different-spaces-2.rs +++ b/src/test/compile-fail/type-params-in-different-spaces-2.rs @@ -17,13 +17,13 @@ trait Tr : Sized { trait A: Tr { fn test(u: U) -> Self { - Tr::op(u) //~ ERROR not implemented + Tr::op(u) //~ ERROR E0277 } } trait B: Tr { fn test(u: U) -> Self { - Tr::op(u) //~ ERROR not implemented + Tr::op(u) //~ ERROR E0277 } } diff --git a/src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs b/src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs index 8a9d53731c54..f8342c333a36 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-assoc-type.rs @@ -16,7 +16,7 @@ trait Trait { fn dummy(&self) { } } fn bar() { - is_send::(); //~ ERROR not implemented + is_send::(); //~ ERROR E0277 } fn is_send() { diff --git a/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs b/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs index a27f7f7ebbe0..93800d3907a6 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs @@ -26,5 +26,5 @@ fn main() { is_mytrait::(); is_mytrait::<(MyS2, MyS)>(); - //~^ ERROR the trait `MyTrait` is not implemented for the type `MyS2` + //~^ ERROR `MyS2 : MyTrait` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs b/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs index 24819bb4f08d..a49047524e66 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs @@ -29,5 +29,5 @@ fn main() { is_mytrait::(); is_mytrait::(); - //~^ ERROR the trait `MyTrait` is not implemented for the type `MyS2` + //~^ ERROR `MyS2 : MyTrait` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs b/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs index 58519e4df755..0158cbcfcda8 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs @@ -27,5 +27,5 @@ fn is_send() {} fn main() { is_send::(); is_send::(); - //~^ ERROR the trait `std::marker::Send` is not implemented for the type `MyNotSendable` + //~^ ERROR `MyNotSendable : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs b/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs index 8d174271a369..6cfc9bc5f5ec 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs @@ -43,11 +43,11 @@ fn is_sync() {} fn main() { is_sync::(); is_sync::(); - //~^ ERROR the trait `std::marker::Sync` is not implemented for the type `MyNotSync` + //~^ ERROR `MyNotSync : std::marker::Sync` is not satisfied is_sync::(); - //~^ ERROR the trait `std::marker::Sync` is not implemented for the type `std::cell::UnsafeCell` + //~^ ERROR `std::cell::UnsafeCell : std::marker::Sync` is not satisfied is_sync::(); - //~^ ERROR the trait `std::marker::Sync` is not implemented for the type `Managed` + //~^ ERROR `Managed : std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation.rs b/src/test/compile-fail/typeck-default-trait-impl-negation.rs index 4b91d0b7a736..98e617ee6659 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-negation.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-negation.rs @@ -33,10 +33,10 @@ fn is_my_unsafe_trait() {} fn main() { is_my_trait::(); is_my_trait::(); - //~^ ERROR the trait `MyTrait` is not implemented for the type `ThisImplsUnsafeTrait` + //~^ ERROR `ThisImplsUnsafeTrait : MyTrait` is not satisfied is_my_unsafe_trait::(); - //~^ ERROR the trait `MyUnsafeTrait` is not implemented for the type `ThisImplsTrait` + //~^ ERROR `ThisImplsTrait : MyUnsafeTrait` is not satisfied is_my_unsafe_trait::(); } diff --git a/src/test/compile-fail/typeck-default-trait-impl-precedence.rs b/src/test/compile-fail/typeck-default-trait-impl-precedence.rs index c67fc92313c3..109b2ed24ea1 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-precedence.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-precedence.rs @@ -27,5 +27,5 @@ impl Signed for i32 { } fn main() { is_defaulted::<&'static i32>(); is_defaulted::<&'static u32>(); - //~^ ERROR the trait `Signed` is not implemented for the type `u32` + //~^ ERROR `u32 : Signed` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-send-param.rs b/src/test/compile-fail/typeck-default-trait-impl-send-param.rs index 185e9dcb3bd9..0c548b3bd990 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-send-param.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-send-param.rs @@ -12,7 +12,7 @@ // an explicit trait bound. fn foo() { - is_send::() //~ ERROR not implemented + is_send::() //~ ERROR E0277 } fn is_send() { diff --git a/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs b/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs index c9bfdff6c0e4..81c4a3c5a519 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs @@ -24,6 +24,6 @@ fn foo() { bar::() } fn bar() { } fn main() { - foo::(); //~ ERROR the trait `NotImplemented` is not implemented for the type `i32` - bar::(); //~ ERROR the trait `NotImplemented` is not implemented for the type `i64` + foo::(); //~ ERROR `i32 : NotImplemented` is not satisfied + bar::(); //~ ERROR `i64 : NotImplemented` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs index c624ba425e47..29379d549611 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs @@ -29,7 +29,7 @@ fn bar() { } fn test() { bar::>(); - //~^ ERROR the trait `NotImplemented` is not implemented for the type `std::option::Option` + //~^ ERROR `std::option::Option : NotImplemented` is not satisfied } fn main() { diff --git a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs index c1757d124da5..a3a80e17e403 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs @@ -26,7 +26,7 @@ impl NotImplemented for i32 {} impl MyTrait for .. {} fn foo() { - //~^ ERROR the trait `NotImplemented` is not implemented for the type `std::option::Option` + //~^ ERROR `std::option::Option : NotImplemented` is not satisfied // This should probably typecheck. This is #20671. } diff --git a/src/test/compile-fail/typeck-unsafe-always-share.rs b/src/test/compile-fail/typeck-unsafe-always-share.rs index a0d236a1c518..f34bae3be3ca 100644 --- a/src/test/compile-fail/typeck-unsafe-always-share.rs +++ b/src/test/compile-fail/typeck-unsafe-always-share.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Verify that UnsafeCell is *always* sync regardless if `T` is sync. +// Verify that UnsafeCell is *always* !Sync regardless if `T` is sync. #![feature(optin_builtin_traits)] @@ -27,16 +27,16 @@ fn test(s: T) {} fn main() { let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0)}); test(us); - //~^ ERROR `std::marker::Sync` is not implemented + //~^ ERROR `std::cell::UnsafeCell> : std::marker::Sync` is not satisfied let uns = UnsafeCell::new(NoSync); test(uns); - //~^ ERROR `std::marker::Sync` is not implemented + //~^ ERROR `std::cell::UnsafeCell : std::marker::Sync` is not satisfied let ms = MySync{u: uns}; test(ms); - //~^ ERROR `std::marker::Sync` is not implemented + //~^ ERROR `std::cell::UnsafeCell : std::marker::Sync` is not satisfied test(NoSync); - //~^ ERROR `std::marker::Sync` is not implemented + //~^ ERROR `NoSync : std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs index c07374ceaf2f..792c4a8ca3c7 100644 --- a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs +++ b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs @@ -12,7 +12,7 @@ use std::ops::Add; fn main() { >::add(1, 2); - //~^ ERROR the trait `std::ops::Add` is not implemented for the type `i32` + //~^ ERROR `i32 : std::ops::Add` is not satisfied >::add(1u32, 2); //~^ ERROR mismatched types >::add(1, 2u32); diff --git a/src/test/compile-fail/unboxed-closure-sugar-default.rs b/src/test/compile-fail/unboxed-closure-sugar-default.rs index 831db98941c6..849f7e0573cf 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-default.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-default.rs @@ -29,7 +29,7 @@ fn test<'a,'b>() { // In angle version, we supply something other than the default eq::< Foo<(isize,),isize,Output=()>, Foo(isize) >(); - //~^ ERROR not implemented + //~^ ERROR E0277 // Supply default explicitly. eq::< Foo<(isize,),(isize,),Output=()>, Foo(isize) >(); diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs index dc5576aee650..0cf44a2ca61c 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs @@ -52,7 +52,7 @@ fn test<'a,'b>() { // Errors expected: eq::< Foo<(),Output=()>, Foo(char) >(); - //~^^ ERROR not implemented + //~^^ ERROR E0277 } fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs index 93498ac7f835..b25b33188067 100644 --- a/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs +++ b/src/test/compile-fail/unboxed-closures-fnmut-as-fn.rs @@ -36,5 +36,5 @@ fn call_itisize>(f: &F, x: isize) -> isize { fn main() { let x = call_it(&S, 22); - //~^ ERROR not implemented + //~^ ERROR E0277 } diff --git a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs b/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs index 361df93a7166..cba7ad82ee16 100644 --- a/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs +++ b/src/test/compile-fail/unboxed-closures-unsafe-extern-fn.rs @@ -22,19 +22,19 @@ fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } fn a() { let x = call_it(&square, 22); - //~^ ERROR not implemented - //~| ERROR not implemented + //~^ ERROR E0277 + //~| ERROR E0277 } fn b() { let y = call_it_mut(&mut square, 22); - //~^ ERROR not implemented - //~| ERROR not implemented + //~^ ERROR E0277 + //~| ERROR E0277 } fn c() { let z = call_it_once(square, 22); - //~^ ERROR not implemented + //~^ ERROR E0277 } fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-wrong-abi.rs b/src/test/compile-fail/unboxed-closures-wrong-abi.rs index ca15d1bb5eef..dd891bc473ce 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-abi.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-abi.rs @@ -22,19 +22,19 @@ fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } fn a() { let x = call_it(&square, 22); - //~^ ERROR not implemented - //~| ERROR not implemented + //~^ ERROR E0277 + //~| ERROR E0277 } fn b() { let y = call_it_mut(&mut square, 22); - //~^ ERROR not implemented - //~| ERROR not implemented + //~^ ERROR E0277 + //~| ERROR E0277 } fn c() { let z = call_it_once(square, 22); - //~^ ERROR not implemented + //~^ ERROR E0277 } fn main() { } diff --git a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs b/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs index b960362aad7c..f9edd5df6739 100644 --- a/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs +++ b/src/test/compile-fail/unboxed-closures-wrong-arg-type-extern-fn.rs @@ -23,19 +23,19 @@ fn call_it_onceisize>(_: F, _: isize) -> isize { 0 } fn a() { let x = call_it(&square, 22); - //~^ ERROR not implemented - //~| ERROR not implemented + //~^ ERROR E0277 + //~| ERROR E0277 } fn b() { let y = call_it_mut(&mut square, 22); - //~^ ERROR not implemented - //~| ERROR not implemented + //~^ ERROR E0277 + //~| ERROR E0277 } fn c() { let z = call_it_once(square, 22); - //~^ ERROR not implemented + //~^ ERROR E0277 } fn main() { } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index 82aa49aa7061..c0a27e98faff 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -17,5 +17,5 @@ fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let i = Box::new(Rc::new(100)); f(i); - //~^ ERROR `std::marker::Send` is not implemented + //~^ ERROR `std::rc::Rc<_> : std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index ed606dae55f2..ae7674640604 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -35,8 +35,8 @@ fn main() { let r1 = vec!(Box::new(r { i: i1 })); let r2 = vec!(Box::new(r { i: i2 })); f(clone(&r1), clone(&r2)); - //~^ ERROR the trait `std::clone::Clone` is not implemented for the type - //~^^ ERROR the trait `std::clone::Clone` is not implemented for the type + //~^ ERROR `r<'_> : std::clone::Clone` is not satisfied + //~^^ ERROR `r<'_> : std::clone::Clone` is not satisfied println!("{:?}", (r2, i1.get())); println!("{:?}", (r1, i2.get())); } diff --git a/src/test/compile-fail/unsized-bare-typaram.rs b/src/test/compile-fail/unsized-bare-typaram.rs index 1885049f1693..49642ac1490c 100644 --- a/src/test/compile-fail/unsized-bare-typaram.rs +++ b/src/test/compile-fail/unsized-bare-typaram.rs @@ -9,5 +9,5 @@ // except according to those terms. fn bar() { } -fn foo() { bar::() } //~ ERROR the trait `std::marker::Sized` is not implemented +fn foo() { bar::() } //~ ERROR `T : std::marker::Sized` is not satisfied fn main() { } diff --git a/src/test/compile-fail/unsized-enum.rs b/src/test/compile-fail/unsized-enum.rs index dad492eb2435..bd5b705511d4 100644 --- a/src/test/compile-fail/unsized-enum.rs +++ b/src/test/compile-fail/unsized-enum.rs @@ -15,14 +15,14 @@ fn not_sized() { } enum Foo { FooSome(U), FooNone } fn foo1() { not_sized::>() } // Hunky dory. fn foo2() { not_sized::>() } -//~^ ERROR the trait `std::marker::Sized` is not implemented +//~^ ERROR `T : std::marker::Sized` is not satisfied // // Not OK: `T` is not sized. enum Bar { BarSome(U), BarNone } fn bar1() { not_sized::>() } fn bar2() { is_sized::>() } -//~^ ERROR the trait `std::marker::Sized` is not implemented +//~^ ERROR `T : std::marker::Sized` is not satisfied // // Not OK: `Bar` is not sized, but it should be. diff --git a/src/test/compile-fail/unsized-inherent-impl-self-type.rs b/src/test/compile-fail/unsized-inherent-impl-self-type.rs index a03c76b12dd8..4d0774f2ce44 100644 --- a/src/test/compile-fail/unsized-inherent-impl-self-type.rs +++ b/src/test/compile-fail/unsized-inherent-impl-self-type.rs @@ -14,7 +14,7 @@ struct S5(Y); -impl S5 { //~ ERROR not implemented +impl S5 { //~ ERROR E0277 } fn main() { } diff --git a/src/test/compile-fail/unsized-struct.rs b/src/test/compile-fail/unsized-struct.rs index c317850be1a6..94f15033cb70 100644 --- a/src/test/compile-fail/unsized-struct.rs +++ b/src/test/compile-fail/unsized-struct.rs @@ -15,14 +15,14 @@ fn not_sized() { } struct Foo { data: T } fn foo1() { not_sized::>() } // Hunky dory. fn foo2() { not_sized::>() } -//~^ ERROR the trait `std::marker::Sized` is not implemented +//~^ ERROR `T : std::marker::Sized` is not satisfied // // Not OK: `T` is not sized. struct Bar { data: T } fn bar1() { not_sized::>() } fn bar2() { is_sized::>() } -//~^ ERROR the trait `std::marker::Sized` is not implemented +//~^ ERROR `T : std::marker::Sized` is not satisfied // // Not OK: `Bar` is not sized, but it should be. diff --git a/src/test/compile-fail/unsized-trait-impl-self-type.rs b/src/test/compile-fail/unsized-trait-impl-self-type.rs index 08df1d9b7b8f..c919bdf924f6 100644 --- a/src/test/compile-fail/unsized-trait-impl-self-type.rs +++ b/src/test/compile-fail/unsized-trait-impl-self-type.rs @@ -17,7 +17,7 @@ trait T3 { struct S5(Y); -impl T3 for S5 { //~ ERROR not implemented +impl T3 for S5 { //~ ERROR E0277 } fn main() { } diff --git a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs index 9cae2b567992..bd420d940d51 100644 --- a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs +++ b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs @@ -16,7 +16,7 @@ trait T2 { } struct S4(Box); impl T2 for S4 { - //~^ ERROR `std::marker::Sized` is not implemented for the type `X` + //~^ ERROR `X : std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index acce00bd87ef..061f0695df7d 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -15,7 +15,7 @@ use std::marker; // Unbounded. fn f1(x: &X) { f2::(x); - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `X : std::marker::Sized` is not satisfied } fn f2(x: &X) { } @@ -26,7 +26,7 @@ trait T { } fn f3(x: &X) { f4::(x); - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `X : std::marker::Sized` is not satisfied } fn f4(x: &X) { } @@ -40,7 +40,7 @@ fn f5(x: &Y) {} fn f6(x: &X) {} fn f7(x1: &E, x2: &E) { f5(x1); - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `X : std::marker::Sized` is not satisfied f6(x2); // ok } @@ -52,19 +52,19 @@ struct S { fn f8(x1: &S, x2: &S) { f5(x1); - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `X : std::marker::Sized` is not satisfied f6(x2); // ok } // Test some tuples. fn f9(x1: Box>, x2: Box>) { f5(&(*x1, 34)); - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `X : std::marker::Sized` is not satisfied } fn f10(x1: Box>, x2: Box>) { f5(&(32, *x2)); - //~^ ERROR the trait `std::marker::Sized` is not implemented + //~^ ERROR `X : std::marker::Sized` is not satisfied } pub fn main() { diff --git a/src/test/compile-fail/unsized5.rs b/src/test/compile-fail/unsized5.rs index 463ce2515ff8..1abc45d5df81 100644 --- a/src/test/compile-fail/unsized5.rs +++ b/src/test/compile-fail/unsized5.rs @@ -11,27 +11,27 @@ // Test `?Sized` types not allowed in fields (except the last one). struct S1 { - f1: X, //~ ERROR `std::marker::Sized` is not implemented + f1: X, //~ ERROR `X : std::marker::Sized` is not satisfied f2: isize, } struct S2 { f: isize, - g: X, //~ ERROR `std::marker::Sized` is not implemented + g: X, //~ ERROR `X : std::marker::Sized` is not satisfied h: isize, } struct S3 { - f: str, //~ ERROR `std::marker::Sized` is not implemented + f: str, //~ ERROR `str : std::marker::Sized` is not satisfied g: [usize] } struct S4 { - f: [u8], //~ ERROR `std::marker::Sized` is not implemented + f: [u8], //~ ERROR `[u8] : std::marker::Sized` is not satisfied g: usize } enum E { - V1(X, isize), //~ERROR `std::marker::Sized` is not implemented + V1(X, isize), //~ERROR `X : std::marker::Sized` is not satisfied } enum F { - V2{f1: X, f: isize}, //~ERROR `std::marker::Sized` is not implemented + V2{f1: X, f: isize}, //~ERROR `X : std::marker::Sized` is not satisfied } pub fn main() { diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index 4b55cdf25e58..7545794bd23e 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -15,27 +15,27 @@ trait T {} fn f1(x: &X) { let _: X; // <-- this is OK, no bindings created, no initializer. let _: (isize, (X, isize)); // same - let y: X; //~ERROR the trait `std::marker::Sized` is not implemented - let y: (isize, (X, isize)); //~ERROR the trait `std::marker::Sized` is not implemented + let y: X; //~ERROR `X : std::marker::Sized` is not satisfied + let y: (isize, (X, isize)); //~ERROR `X : std::marker::Sized` is not satisfied } fn f2(x: &X) { - let y: X; //~ERROR the trait `std::marker::Sized` is not implemented - let y: (isize, (X, isize)); //~ERROR the trait `std::marker::Sized` is not implemented + let y: X; //~ERROR `X : std::marker::Sized` is not satisfied + let y: (isize, (X, isize)); //~ERROR `X : std::marker::Sized` is not satisfied } fn f3(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; //~ERROR the trait `std::marker::Sized` is not implemented - let y = *x2; //~ERROR the trait `std::marker::Sized` is not implemented - let (y, z) = (*x3, 4); //~ERROR the trait `std::marker::Sized` is not implemented + let y: X = *x1; //~ERROR `X : std::marker::Sized` is not satisfied + let y = *x2; //~ERROR `X : std::marker::Sized` is not satisfied + let (y, z) = (*x3, 4); //~ERROR `X : std::marker::Sized` is not satisfied } fn f4(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; //~ERROR the trait `std::marker::Sized` is not implemented - let y = *x2; //~ERROR the trait `std::marker::Sized` is not implemented - let (y, z) = (*x3, 4); //~ERROR the trait `std::marker::Sized` is not implemented + let y: X = *x1; //~ERROR `X : std::marker::Sized` is not satisfied + let y = *x2; //~ERROR `X : std::marker::Sized` is not satisfied + let (y, z) = (*x3, 4); //~ERROR `X : std::marker::Sized` is not satisfied } -fn g1(x: X) {} //~ERROR the trait `std::marker::Sized` is not implemented -fn g2(x: X) {} //~ERROR the trait `std::marker::Sized` is not implemented +fn g1(x: X) {} //~ERROR `X : std::marker::Sized` is not satisfied +fn g2(x: X) {} //~ERROR `X : std::marker::Sized` is not satisfied pub fn main() { } diff --git a/src/test/compile-fail/unsized7.rs b/src/test/compile-fail/unsized7.rs index defa57414f40..5aa1f1336796 100644 --- a/src/test/compile-fail/unsized7.rs +++ b/src/test/compile-fail/unsized7.rs @@ -20,7 +20,7 @@ trait T1 { struct S3(Box); impl T1 for S3 { - //~^ ERROR `std::marker::Sized` is not implemented for the type `X` + //~^ ERROR `X : std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs index 654272f5bc6e..e32cb32a74d6 100644 --- a/src/test/compile-fail/vtable-res-trait-param.rs +++ b/src/test/compile-fail/vtable-res-trait-param.rs @@ -24,7 +24,7 @@ impl TraitB for isize { fn call_it(b: B) -> isize { let y = 4; - b.gimme_an_a(y) //~ ERROR the trait `TraitA` is not implemented + b.gimme_an_a(y) //~ ERROR `_ : TraitA` is not satisfied } fn main() { diff --git a/src/test/compile-fail/wf-impl-associated-type-trait.rs b/src/test/compile-fail/wf-impl-associated-type-trait.rs index ba31de98e7f9..b797c9780acb 100644 --- a/src/test/compile-fail/wf-impl-associated-type-trait.rs +++ b/src/test/compile-fail/wf-impl-associated-type-trait.rs @@ -25,9 +25,8 @@ pub trait Foo { impl Foo for T { type Bar = MySet; - //~^ ERROR the trait `MyHash` is not implemented for the type `T` + //~^ ERROR the predicate `T : MyHash` is not satisfied } #[rustc_error] fn main() { } - diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs index 354407bc0020..42e9fa2614cc 100644 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs +++ b/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs @@ -21,7 +21,7 @@ impl Foo { fn fails_copy(self) { require_copy(self.x); - //~^ ERROR the trait `std::marker::Copy` is not implemented for the type `T` + //~^ ERROR the predicate `T : std::marker::Copy` is not satisfied } } diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs index b747a555b5e7..889cf85221b7 100644 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs +++ b/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs @@ -26,7 +26,7 @@ impl Foo for Bar { fn fails_copy(self) { require_copy(self.x); - //~^ ERROR the trait `std::marker::Copy` is not implemented for the type `T` + //~^ ERROR the predicate `T : std::marker::Copy` is not satisfied } } diff --git a/src/test/compile-fail/where-clause-method-substituion.rs b/src/test/compile-fail/where-clause-method-substituion.rs index bf614e6eb512..0f682582c3eb 100644 --- a/src/test/compile-fail/where-clause-method-substituion.rs +++ b/src/test/compile-fail/where-clause-method-substituion.rs @@ -28,5 +28,5 @@ impl Bar for isize { fn main() { 1.method::(); - //~^ ERROR the trait `Foo` is not implemented for the type `X` + //~^ ERROR the predicate `X : Foo` is not satisfied } diff --git a/src/test/compile-fail/where-clauses-method-unsatisfied.rs b/src/test/compile-fail/where-clauses-method-unsatisfied.rs index c4d7d8207e74..34ff872ac15f 100644 --- a/src/test/compile-fail/where-clauses-method-unsatisfied.rs +++ b/src/test/compile-fail/where-clauses-method-unsatisfied.rs @@ -26,5 +26,5 @@ impl Foo { fn main() { let x = Foo { value: Bar }; x.equals(&x); - //~^ ERROR the trait `std::cmp::Eq` is not implemented for the type `Bar` + //~^ ERROR `Bar : std::cmp::Eq` is not satisfied } diff --git a/src/test/compile-fail/where-clauses-unsatisfied.rs b/src/test/compile-fail/where-clauses-unsatisfied.rs index d1d0eb13d68d..0410d7c05839 100644 --- a/src/test/compile-fail/where-clauses-unsatisfied.rs +++ b/src/test/compile-fail/where-clauses-unsatisfied.rs @@ -15,5 +15,5 @@ struct Struct; fn main() { drop(equal(&Struct, &Struct)) - //~^ ERROR the trait `std::cmp::Eq` is not implemented + //~^ ERROR the predicate `Struct : std::cmp::Eq` is not satisfied } diff --git a/src/test/compile-fail/where-for-self-2.rs b/src/test/compile-fail/where-for-self-2.rs index cd5240198b38..1baaed3dd378 100644 --- a/src/test/compile-fail/where-for-self-2.rs +++ b/src/test/compile-fail/where-for-self-2.rs @@ -29,5 +29,5 @@ fn foo(x: &T) fn main() { foo(&X); - //~^ error: `for<'a> Bar` is not implemented + //~^ error: `for<'a> &'a _ : Bar` is not satisfied } From 728d20f7cc84a67ea85aaa1257234b4750bdcc1c Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Thu, 31 Mar 2016 21:42:23 +0300 Subject: [PATCH 12/20] improve error message --- src/doc/book/closures.md | 4 ++-- src/doc/book/concurrency.md | 2 +- src/doc/book/traits.md | 4 ++-- src/doc/book/vectors.md | 2 +- src/doc/nomicon/coercions.md | 2 +- src/librustc/diagnostics.rs | 2 +- src/librustc/traits/error_reporting.rs | 2 +- src/test/compile-fail/associated-types-for-unimpl-trait.rs | 2 +- .../associated-types-invalid-trait-ref-issue-18865.rs | 2 +- src/test/compile-fail/associated-types-no-suitable-bound.rs | 2 +- .../compile-fail/associated-types-no-suitable-supertrait-2.rs | 2 +- .../compile-fail/associated-types-no-suitable-supertrait.rs | 4 ++-- src/test/compile-fail/cast-rfc0401.rs | 4 ++-- src/test/compile-fail/cross-fn-cache-hole.rs | 2 +- .../compile-fail/issue-21659-show-relevant-trait-impls-1.rs | 2 +- .../compile-fail/issue-21659-show-relevant-trait-impls-2.rs | 2 +- src/test/compile-fail/wf-impl-associated-type-trait.rs | 2 +- .../where-clause-constraints-are-local-for-inherent-impl.rs | 2 +- .../where-clause-constraints-are-local-for-trait-impl.rs | 2 +- src/test/compile-fail/where-clause-method-substituion.rs | 2 +- src/test/compile-fail/where-clauses-unsatisfied.rs | 2 +- 21 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md index 1b7a0da0112b..a8135ad38493 100644 --- a/src/doc/book/closures.md +++ b/src/doc/book/closures.md @@ -371,13 +371,13 @@ assert_eq!(6, answer); This gives us these long, related errors: ```text -error: the predicate `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277] +error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277] fn factory() -> (Fn(i32) -> i32) { ^~~~~~~~~~~~~~~~ note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time fn factory() -> (Fn(i32) -> i32) { ^~~~~~~~~~~~~~~~ -error: the predicate `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277] +error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277] let f = factory(); ^ note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time diff --git a/src/doc/book/concurrency.md b/src/doc/book/concurrency.md index 8b918d3cfeff..ac55972524f9 100644 --- a/src/doc/book/concurrency.md +++ b/src/doc/book/concurrency.md @@ -231,7 +231,7 @@ fn main() { This won't work, however, and will give us the error: ```text -13:9: 13:22 error: the predicate `alloc::rc::Rc> : core::marker::Send` +13:9: 13:22 error: the trait bound `alloc::rc::Rc> : core::marker::Send` is not satisfied ... 13:9: 13:22 note: `alloc::rc::Rc>` diff --git a/src/doc/book/traits.md b/src/doc/book/traits.md index 00aa33a9308c..b3b419792456 100644 --- a/src/doc/book/traits.md +++ b/src/doc/book/traits.md @@ -154,7 +154,7 @@ print_area(5); We get a compile-time error: ```text -error: the predicate `_ : HasArea` is not satisfied [E0277] +error: the trait bound `_ : HasArea` is not satisfied [E0277] ``` ## Trait bounds on generic structs @@ -496,7 +496,7 @@ impl FooBar for Baz { If we forget to implement `Foo`, Rust will tell us: ```text -error: the predicate `main::Baz : main::Foo` is not satisfied [E0277] +error: the trait bound `main::Baz : main::Foo` is not satisfied [E0277] ``` # Deriving diff --git a/src/doc/book/vectors.md b/src/doc/book/vectors.md index c98274a6649b..75e961e4c4a8 100644 --- a/src/doc/book/vectors.md +++ b/src/doc/book/vectors.md @@ -56,7 +56,7 @@ v[j]; Indexing with a non-`usize` type gives an error that looks like this: ```text -error: the predicate `collections::vec::Vec<_> : core::ops::Index` +error: the trait bound `collections::vec::Vec<_> : core::ops::Index` is not satisfied [E0277] v[j]; ^~~~ diff --git a/src/doc/nomicon/coercions.md b/src/doc/nomicon/coercions.md index 3fb7f620eeea..6a9ebd6edf8f 100644 --- a/src/doc/nomicon/coercions.md +++ b/src/doc/nomicon/coercions.md @@ -64,7 +64,7 @@ fn main() { ``` ```text -:10:5: 10:8 error: the predicate `&mut i32 : Trait` is not satisfied [E0277] +:10:5: 10:8 error: the trait bound `&mut i32 : Trait` is not satisfied [E0277] :10 foo(t); ^~~ ``` diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 51c453c784e9..4abb1c8b98af 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1006,7 +1006,7 @@ fn some_func(foo: T) { fn main() { // we now call the method with the i32 type, which doesn't implement // the Foo trait - some_func(5i32); // error: the predicate `i32 : Foo` is not satisfied + some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied } ``` diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 82b5dc66f7c4..dfe3f91c7b15 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -361,7 +361,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let trait_ref = trait_predicate.to_poly_trait_ref(); let mut err = struct_span_err!( infcx.tcx.sess, obligation.cause.span, E0277, - "the predicate `{}` is not satisfied", + "the trait bound `{}` is not satisfied", trait_ref.to_predicate()); // Try to report a good error message. diff --git a/src/test/compile-fail/associated-types-for-unimpl-trait.rs b/src/test/compile-fail/associated-types-for-unimpl-trait.rs index a8aee5fd0a59..9fa24850e037 100644 --- a/src/test/compile-fail/associated-types-for-unimpl-trait.rs +++ b/src/test/compile-fail/associated-types-for-unimpl-trait.rs @@ -15,7 +15,7 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the predicate `Self : Get` is not satisfied + //~^ ERROR the trait bound `Self : Get` is not satisfied } fn main() { diff --git a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs b/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs index 32068633df6a..18d9ea52ff25 100644 --- a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs +++ b/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs @@ -18,7 +18,7 @@ trait Foo { fn f>(t: &T) { let u: >::Bar = t.get_bar(); - //~^ ERROR the predicate `T : Foo` is not satisfied + //~^ ERROR the trait bound `T : Foo` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-bound.rs b/src/test/compile-fail/associated-types-no-suitable-bound.rs index 19f0e27fa55b..0aafd193c90d 100644 --- a/src/test/compile-fail/associated-types-no-suitable-bound.rs +++ b/src/test/compile-fail/associated-types-no-suitable-bound.rs @@ -19,7 +19,7 @@ struct Struct { impl Struct { fn uhoh(foo: ::Value) {} - //~^ ERROR the predicate `T : Get` is not satisfied + //~^ ERROR the trait bound `T : Get` is not satisfied } fn main() { diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs index 63e76f7eeaa5..225ee0857013 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs @@ -25,7 +25,7 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the predicate `Self : Get` is not satisfied + //~^ ERROR the trait bound `Self : Get` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs index 38f5be37bd1e..fe519beef672 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs @@ -25,12 +25,12 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the predicate `Self : Get` is not satisfied + //~^ ERROR the trait bound `Self : Get` is not satisfied } impl Other for T { fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} - //~^ ERROR the predicate `(T, U) : Get` is not satisfied + //~^ ERROR the trait bound `(T, U) : Get` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/cast-rfc0401.rs b/src/test/compile-fail/cast-rfc0401.rs index 2bc4d82ef0a4..c032fb43402f 100644 --- a/src/test/compile-fail/cast-rfc0401.rs +++ b/src/test/compile-fail/cast-rfc0401.rs @@ -91,7 +91,7 @@ fn main() let _ = 42usize as *const [u8]; //~ ERROR casting let _ = v as *const [u8]; //~ ERROR cannot cast let _ = fat_v as *const Foo; - //~^ ERROR the predicate `[u8] : std::marker::Sized` is not satisfied + //~^ ERROR the trait bound `[u8] : std::marker::Sized` is not satisfied //~^^ HELP run `rustc --explain E0277` to see a detailed explanation //~^^^ NOTE `[u8]` does not have a constant size known at compile-time //~^^^^ NOTE required for the cast to the object type `Foo` @@ -106,7 +106,7 @@ fn main() let a : *const str = "hello"; let _ = a as *const Foo; - //~^ ERROR the predicate `str : std::marker::Sized` is not satisfied + //~^ ERROR the trait bound `str : std::marker::Sized` is not satisfied //~^^ HELP run `rustc --explain E0277` to see a detailed explanation //~^^^ NOTE `str` does not have a constant size known at compile-time //~^^^^ NOTE required for the cast to the object type `Foo` diff --git a/src/test/compile-fail/cross-fn-cache-hole.rs b/src/test/compile-fail/cross-fn-cache-hole.rs index eb063f5bc8c3..0a3ce03f27bf 100644 --- a/src/test/compile-fail/cross-fn-cache-hole.rs +++ b/src/test/compile-fail/cross-fn-cache-hole.rs @@ -23,7 +23,7 @@ trait Bar { } // We don't always check where clauses for sanity, but in this case // wfcheck does report an error here: -fn vacuous() //~ ERROR the predicate `i32 : Bar` is not satisfied +fn vacuous() //~ ERROR the trait bound `i32 : Bar` is not satisfied where i32: Foo { // ... the original intention was to check that we don't use that diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs index 452ae5df40a9..7bc4adfa85d0 100644 --- a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs @@ -32,7 +32,7 @@ fn main() { let f1 = Bar; f1.foo(1usize); - //~^ error: the predicate `Bar : Foo` is not satisfied + //~^ error: the trait bound `Bar : Foo` is not satisfied //~| help: the following implementations were found: //~| help: > //~| help: > diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs index 8f52004f598b..f4e536144720 100644 --- a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs @@ -36,7 +36,7 @@ fn main() { let f1 = Bar; f1.foo(1usize); - //~^ error: the predicate `Bar : Foo` is not satisfied + //~^ error: the trait bound `Bar : Foo` is not satisfied //~| help: the following implementations were found: //~| help: > //~| help: > diff --git a/src/test/compile-fail/wf-impl-associated-type-trait.rs b/src/test/compile-fail/wf-impl-associated-type-trait.rs index b797c9780acb..2fee2604a8a8 100644 --- a/src/test/compile-fail/wf-impl-associated-type-trait.rs +++ b/src/test/compile-fail/wf-impl-associated-type-trait.rs @@ -25,7 +25,7 @@ pub trait Foo { impl Foo for T { type Bar = MySet; - //~^ ERROR the predicate `T : MyHash` is not satisfied + //~^ ERROR the trait bound `T : MyHash` is not satisfied } #[rustc_error] diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs index 42e9fa2614cc..4b85f2275a75 100644 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs +++ b/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs @@ -21,7 +21,7 @@ impl Foo { fn fails_copy(self) { require_copy(self.x); - //~^ ERROR the predicate `T : std::marker::Copy` is not satisfied + //~^ ERROR the trait bound `T : std::marker::Copy` is not satisfied } } diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs index 889cf85221b7..f55586982bee 100644 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs +++ b/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs @@ -26,7 +26,7 @@ impl Foo for Bar { fn fails_copy(self) { require_copy(self.x); - //~^ ERROR the predicate `T : std::marker::Copy` is not satisfied + //~^ ERROR the trait bound `T : std::marker::Copy` is not satisfied } } diff --git a/src/test/compile-fail/where-clause-method-substituion.rs b/src/test/compile-fail/where-clause-method-substituion.rs index 0f682582c3eb..9f217f29bd18 100644 --- a/src/test/compile-fail/where-clause-method-substituion.rs +++ b/src/test/compile-fail/where-clause-method-substituion.rs @@ -28,5 +28,5 @@ impl Bar for isize { fn main() { 1.method::(); - //~^ ERROR the predicate `X : Foo` is not satisfied + //~^ ERROR the trait bound `X : Foo` is not satisfied } diff --git a/src/test/compile-fail/where-clauses-unsatisfied.rs b/src/test/compile-fail/where-clauses-unsatisfied.rs index 0410d7c05839..38470bc3de67 100644 --- a/src/test/compile-fail/where-clauses-unsatisfied.rs +++ b/src/test/compile-fail/where-clauses-unsatisfied.rs @@ -15,5 +15,5 @@ struct Struct; fn main() { drop(equal(&Struct, &Struct)) - //~^ ERROR the predicate `Struct : std::cmp::Eq` is not satisfied + //~^ ERROR the trait bound `Struct : std::cmp::Eq` is not satisfied } From 31247e5a0b38e2853cec47d30d0a48b2e54dd136 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Thu, 31 Mar 2016 21:42:36 +0300 Subject: [PATCH 13/20] remove obsolete tests the meaning of these tests had changed completely over the years and now they are only a maintenance burden. --- src/test/compile-fail/mut-not-freeze.rs | 19 ---------- src/test/compile-fail/unique-unique-kind.rs | 21 ----------- src/test/compile-fail/unique-vec-res.rs | 42 --------------------- 3 files changed, 82 deletions(-) delete mode 100644 src/test/compile-fail/mut-not-freeze.rs delete mode 100644 src/test/compile-fail/unique-unique-kind.rs delete mode 100644 src/test/compile-fail/unique-vec-res.rs diff --git a/src/test/compile-fail/mut-not-freeze.rs b/src/test/compile-fail/mut-not-freeze.rs deleted file mode 100644 index a24a91a4d540..000000000000 --- a/src/test/compile-fail/mut-not-freeze.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cell::RefCell; - -fn f(_: T) {} - -fn main() { - let x = RefCell::new(0); - f(x); - //~^ ERROR `std::cell::RefCell<_> : std::marker::Sync` is not satisfied -} diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs deleted file mode 100644 index c0a27e98faff..000000000000 --- a/src/test/compile-fail/unique-unique-kind.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::rc::Rc; - -fn f(__isize: T) { -} - -fn main() { - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - let i = Box::new(Rc::new(100)); - f(i); - //~^ ERROR `std::rc::Rc<_> : std::marker::Send` is not satisfied -} diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs deleted file mode 100644 index ae7674640604..000000000000 --- a/src/test/compile-fail/unique-vec-res.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cell::Cell; - -#[derive(Debug)] -struct r<'a> { - i: &'a Cell, -} - -impl<'a> Drop for r<'a> { - fn drop(&mut self) { - unsafe { - self.i.set(self.i.get() + 1); - } - } -} - -fn f(__isize: Vec , _j: Vec ) { -} - -fn clone(t: &T) -> T { t.clone() } - -fn main() { - let i1 = &Cell::new(0); - let i2 = &Cell::new(1); - // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. - let r1 = vec!(Box::new(r { i: i1 })); - let r2 = vec!(Box::new(r { i: i2 })); - f(clone(&r1), clone(&r2)); - //~^ ERROR `r<'_> : std::clone::Clone` is not satisfied - //~^^ ERROR `r<'_> : std::clone::Clone` is not satisfied - println!("{:?}", (r2, i1.get())); - println!("{:?}", (r1, i2.get())); -} From b23648fe4aa46e9a2bf72c6f68590e799c4cdb07 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 5 Apr 2016 22:56:23 +0300 Subject: [PATCH 14/20] improve the printing of substs and trait-refs --- src/librustc/util/ppaux.rs | 194 ++++++++++-------- .../associated-types-for-unimpl-trait.rs | 2 +- ...ted-types-invalid-trait-ref-issue-18865.rs | 2 +- .../associated-types-no-suitable-bound.rs | 2 +- ...sociated-types-no-suitable-supertrait-2.rs | 2 +- ...associated-types-no-suitable-supertrait.rs | 4 +- .../compile-fail/associated-types-path-2.rs | 4 +- .../compile-fail/associated-types-unsized.rs | 2 +- .../compile-fail/bad-method-typaram-kind.rs | 2 +- src/test/compile-fail/bad-sized.rs | 6 +- .../builtin-superkinds-double-superkind.rs | 4 +- .../builtin-superkinds-in-metadata.rs | 2 +- .../compile-fail/builtin-superkinds-simple.rs | 2 +- .../builtin-superkinds-typaram-not-send.rs | 2 +- src/test/compile-fail/cast-rfc0401.rs | 4 +- ...bounds-cant-promote-superkind-in-struct.rs | 2 +- .../compile-fail/closure-bounds-subtype.rs | 2 +- src/test/compile-fail/cross-fn-cache-hole.rs | 2 +- .../deriving-no-inner-impl-error-message.rs | 2 +- .../deriving-span-Default-struct.rs | 2 +- .../compile-fail/destructure-trait-ref.rs | 2 +- src/test/compile-fail/dst-bad-assign-2.rs | 2 +- src/test/compile-fail/dst-bad-assign.rs | 2 +- src/test/compile-fail/dst-bad-coerce1.rs | 2 +- src/test/compile-fail/dst-bad-deep.rs | 2 +- .../dst-object-from-unsized-type.rs | 8 +- .../compile-fail/dst-sized-trait-param.rs | 4 +- .../compile-fail/extern-wrong-value-type.rs | 4 +- src/test/compile-fail/for-loop-bogosity.rs | 2 +- src/test/compile-fail/hrtb-just-for-static.rs | 2 +- .../compile-fail/hrtb-perfect-forwarding.rs | 2 +- src/test/compile-fail/ifmt-unimpl.rs | 2 +- src/test/compile-fail/impl-bounds-checking.rs | 2 +- .../compile-fail/indexing-requires-a-uint.rs | 2 +- src/test/compile-fail/issue-14084.rs | 2 +- src/test/compile-fail/issue-14366.rs | 2 +- src/test/compile-fail/issue-14853.rs | 2 +- src/test/compile-fail/issue-15756.rs | 2 +- src/test/compile-fail/issue-16538.rs | 2 +- src/test/compile-fail/issue-17651.rs | 2 +- .../compile-fail/issue-17718-static-sync.rs | 2 +- src/test/compile-fail/issue-17959.rs | 2 +- src/test/compile-fail/issue-18107.rs | 2 +- src/test/compile-fail/issue-18611.rs | 2 +- src/test/compile-fail/issue-18919.rs | 2 +- src/test/compile-fail/issue-1920-1.rs | 2 +- src/test/compile-fail/issue-1920-2.rs | 2 +- src/test/compile-fail/issue-1920-3.rs | 2 +- src/test/compile-fail/issue-20005.rs | 2 +- src/test/compile-fail/issue-20162.rs | 2 +- src/test/compile-fail/issue-20605.rs | 2 +- src/test/compile-fail/issue-21160.rs | 2 +- ...issue-21659-show-relevant-trait-impls-1.rs | 2 +- ...issue-21659-show-relevant-trait-impls-2.rs | 2 +- src/test/compile-fail/issue-21763.rs | 2 +- src/test/compile-fail/issue-22034.rs | 4 +- src/test/compile-fail/issue-25076.rs | 2 +- src/test/compile-fail/issue-2611-4.rs | 2 +- src/test/compile-fail/issue-28098.rs | 12 +- src/test/compile-fail/issue-29147.rs | 2 +- src/test/compile-fail/issue-5035-2.rs | 2 +- src/test/compile-fail/issue-5883.rs | 4 +- src/test/compile-fail/issue-7013.rs | 2 +- src/test/compile-fail/issue-7364.rs | 2 +- .../compile-fail/kindck-impl-type-params-2.rs | 2 +- src/test/compile-fail/kindck-send-unsafe.rs | 2 +- src/test/compile-fail/map-types.rs | 2 +- .../compile-fail/mutable-enum-indirect.rs | 2 +- src/test/compile-fail/no-send-res-ports.rs | 2 +- src/test/compile-fail/no_send-enum.rs | 2 +- src/test/compile-fail/no_send-rc.rs | 2 +- src/test/compile-fail/no_send-struct.rs | 2 +- src/test/compile-fail/no_share-enum.rs | 2 +- src/test/compile-fail/no_share-struct.rs | 2 +- src/test/compile-fail/not-sync.rs | 14 +- .../object-does-not-impl-trait.rs | 2 +- src/test/compile-fail/phantom-oibit.rs | 4 +- src/test/compile-fail/range-1.rs | 4 +- .../reject-specialized-drops-8142.rs | 2 +- .../compile-fail/repeat-to-run-dtor-twice.rs | 2 +- src/test/compile-fail/str-idx.rs | 2 +- src/test/compile-fail/str-mut-idx.rs | 8 +- src/test/compile-fail/substs-verbose.rs | 47 +++++ .../trait-bounds-impl-comparison-1.rs | 12 +- .../trait-bounds-impl-comparison-2.rs | 2 +- .../trait-bounds-not-on-bare-trait.rs | 2 +- .../trait-bounds-on-structs-and-enums.rs | 2 +- .../trait-coercion-generic-bad.rs | 2 +- .../trait-suggest-where-clause.rs | 22 +- .../compile-fail/traits-negative-impls.rs | 14 +- .../traits-repeated-supertrait-ambig.rs | 10 +- ...-default-trait-impl-constituent-types-2.rs | 2 +- ...ck-default-trait-impl-constituent-types.rs | 2 +- ...typeck-default-trait-impl-negation-send.rs | 2 +- ...typeck-default-trait-impl-negation-sync.rs | 6 +- .../typeck-default-trait-impl-negation.rs | 4 +- .../typeck-default-trait-impl-precedence.rs | 2 +- .../typeck-default-trait-impl-supertrait.rs | 4 +- ...default-trait-impl-trait-where-clause-2.rs | 2 +- ...k-default-trait-impl-trait-where-clause.rs | 2 +- .../typeck-unsafe-always-share.rs | 8 +- .../compile-fail/ufcs-qpath-self-mismatch.rs | 2 +- src/test/compile-fail/unsized-bare-typaram.rs | 2 +- src/test/compile-fail/unsized-enum.rs | 4 +- src/test/compile-fail/unsized-struct.rs | 4 +- .../unsized-trait-impl-trait-arg.rs | 2 +- src/test/compile-fail/unsized3.rs | 12 +- src/test/compile-fail/unsized5.rs | 12 +- src/test/compile-fail/unsized6.rs | 24 +-- src/test/compile-fail/unsized7.rs | 2 +- .../compile-fail/vtable-res-trait-param.rs | 2 +- .../wf-impl-associated-type-trait.rs | 2 +- ...constraints-are-local-for-inherent-impl.rs | 2 +- ...se-constraints-are-local-for-trait-impl.rs | 2 +- .../where-clause-method-substituion.rs | 2 +- .../where-clauses-method-unsatisfied.rs | 2 +- .../compile-fail/where-clauses-unsatisfied.rs | 2 +- src/test/compile-fail/where-for-self-2.rs | 2 +- 118 files changed, 350 insertions(+), 291 deletions(-) create mode 100644 src/test/compile-fail/substs-verbose.rs diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 20f16a1d255c..b75f7965d1a0 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -19,6 +19,7 @@ use ty::TyClosure; use ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; use ty::{self, Ty, TyCtxt, TypeFoldable}; +use std::cell::Cell; use std::fmt; use syntax::abi::Abi; use syntax::parse::token; @@ -67,6 +68,45 @@ pub enum Ns { Value } +fn number_of_supplied_defaults<'tcx, GG>(tcx: &ty::TyCtxt<'tcx>, + substs: &subst::Substs, + space: subst::ParamSpace, + get_generics: GG) + -> usize + where GG: FnOnce(&TyCtxt<'tcx>) -> ty::Generics<'tcx> +{ + let generics = get_generics(tcx); + + let has_self = substs.self_ty().is_some(); + let ty_params = generics.types.get_slice(space); + let tps = substs.types.get_slice(space); + if ty_params.last().map_or(false, |def| def.default.is_some()) { + let substs = tcx.lift(&substs); + ty_params.iter().zip(tps).rev().take_while(|&(def, &actual)| { + match def.default { + Some(default) => { + if !has_self && default.has_self_ty() { + // In an object type, there is no `Self`, and + // thus if the default value references Self, + // the user will be required to give an + // explicit value. We can't even do the + // substitution below to check without causing + // an ICE. (#18956). + false + } else { + let default = tcx.lift(&default); + substs.and_then(|substs| default.subst(tcx, substs)) + == Some(actual) + } + } + None => false + } + }).count() + } else { + 0 + } +} + pub fn parameterized(f: &mut fmt::Formatter, substs: &subst::Substs, did: DefId, @@ -80,8 +120,8 @@ pub fn parameterized(f: &mut fmt::Formatter, write!(f, "<{} as ", self_ty)?; } - let (fn_trait_kind, verbose, last_name) = ty::tls::with(|tcx| { - let (did, last_name) = if ns == Ns::Value { + let (fn_trait_kind, verbose, item_name) = ty::tls::with(|tcx| { + let (did, item_name) = if ns == Ns::Value { // Try to get the impl/trait parent, if this is an // associated value item (method or constant). tcx.trait_of_item(did).or_else(|| tcx.impl_of_method(did)) @@ -90,97 +130,64 @@ pub fn parameterized(f: &mut fmt::Formatter, (did, None) }; write!(f, "{}", tcx.item_path_str(did))?; - Ok((tcx.lang_items.fn_trait_kind(did), tcx.sess.verbose(), last_name)) + Ok((tcx.lang_items.fn_trait_kind(did), tcx.sess.verbose(), item_name)) })?; - let mut empty = true; - let mut start_or_continue = |f: &mut fmt::Formatter, start: &str, cont: &str| { - if empty { - empty = false; - write!(f, "{}", start) - } else { - write!(f, "{}", cont) - } - }; - - if verbose { - for region in &substs.regions { - start_or_continue(f, "<", ", ")?; - write!(f, "{:?}", region)?; - } - for &ty in &substs.types { - start_or_continue(f, "<", ", ")?; - write!(f, "{}", ty)?; - } - for projection in projections { - start_or_continue(f, "<", ", ")?; - write!(f, "{}={}", - projection.projection_ty.item_name, - projection.ty)?; - } - return start_or_continue(f, "", ">"); - } - - if fn_trait_kind.is_some() && projections.len() == 1 { + if !verbose && fn_trait_kind.is_some() && projections.len() == 1 { let projection_ty = projections[0].ty; if let TyTuple(ref args) = substs.types.get_slice(subst::TypeSpace)[0].sty { return fn_sig(f, args, false, ty::FnConverging(projection_ty)); } } - for &r in &substs.regions { - start_or_continue(f, "<", ", ")?; - let s = r.to_string(); - if s.is_empty() { - // This happens when the value of the region - // parameter is not easily serialized. This may be - // because the user omitted it in the first place, - // or because it refers to some block in the code, - // etc. I'm not sure how best to serialize this. - write!(f, "'_")?; + let empty = Cell::new(true); + let start_or_continue = |f: &mut fmt::Formatter, start: &str, cont: &str| { + if empty.get() { + empty.set(false); + write!(f, "{}", start) } else { - write!(f, "{}", s)?; + write!(f, "{}", cont) } + }; + let print_region = |f: &mut fmt::Formatter, region: &ty::Region| -> _ { + if verbose { + write!(f, "{:?}", region) + } else { + let s = region.to_string(); + if s.is_empty() { + // This happens when the value of the region + // parameter is not easily serialized. This may be + // because the user omitted it in the first place, + // or because it refers to some block in the code, + // etc. I'm not sure how best to serialize this. + write!(f, "'_") + } else { + write!(f, "{}", s) + } + } + }; + + for region in substs.regions.get_slice(subst::TypeSpace) { + start_or_continue(f, "<", ", ")?; + print_region(f, region)?; } - // It is important to execute this conditionally, only if -Z - // verbose is false. Otherwise, debug logs can sometimes cause - // ICEs trying to fetch the generics early in the pipeline. This - // is kind of a hacky workaround in that -Z verbose is required to - // avoid those ICEs. + let num_supplied_defaults = if verbose { + 0 + } else { + // It is important to execute this conditionally, only if -Z + // verbose is false. Otherwise, debug logs can sometimes cause + // ICEs trying to fetch the generics early in the pipeline. This + // is kind of a hacky workaround in that -Z verbose is required to + // avoid those ICEs. + ty::tls::with(|tcx| { + number_of_supplied_defaults(tcx, substs, subst::TypeSpace, get_generics) + }) + }; + let tps = substs.types.get_slice(subst::TypeSpace); - let num_defaults = ty::tls::with(|tcx| { - let generics = get_generics(tcx); - - let has_self = substs.self_ty().is_some(); - let ty_params = generics.types.get_slice(subst::TypeSpace); - if ty_params.last().map_or(false, |def| def.default.is_some()) { - let substs = tcx.lift(&substs); - ty_params.iter().zip(tps).rev().take_while(|&(def, &actual)| { - match def.default { - Some(default) => { - if !has_self && default.has_self_ty() { - // In an object type, there is no `Self`, and - // thus if the default value references Self, - // the user will be required to give an - // explicit value. We can't even do the - // substitution below to check without causing - // an ICE. (#18956). - false - } else { - let default = tcx.lift(&default); - substs.and_then(|substs| default.subst(tcx, substs)) == Some(actual) - } - } - None => false - } - }).count() - } else { - 0 - } - }); - for &ty in &tps[..tps.len() - num_defaults] { + for &ty in &tps[..tps.len() - num_supplied_defaults] { start_or_continue(f, "<", ", ")?; write!(f, "{}", ty)?; } @@ -196,21 +203,28 @@ pub fn parameterized(f: &mut fmt::Formatter, // For values, also print their name and type parameters. if ns == Ns::Value { + empty.set(true); + if substs.self_ty().is_some() { write!(f, ">")?; } - if let Some(name) = last_name { - write!(f, "::{}", name)?; + if let Some(item_name) = item_name { + write!(f, "::{}", item_name)?; } - let tps = substs.types.get_slice(subst::FnSpace); - if !tps.is_empty() { - write!(f, "::<{}", tps[0])?; - for ty in &tps[1..] { - write!(f, ", {}", ty)?; - } - write!(f, ">")?; + + for region in substs.regions.get_slice(subst::FnSpace) { + start_or_continue(f, "::<", ", ")?; + print_region(f, region)?; + } + + // FIXME: consider being smart with defaults here too + for ty in substs.types.get_slice(subst::FnSpace) { + start_or_continue(f, "::<", ", ")?; + write!(f, "{}", ty)?; } + + start_or_continue(f, "", ">")?; } Ok(()) @@ -997,9 +1011,7 @@ impl<'tcx> fmt::Debug for ty::TraitPredicate<'tcx> { impl<'tcx> fmt::Display for ty::TraitPredicate<'tcx> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{} : {}", - self.trait_ref.self_ty(), - self.trait_ref) + write!(f, "{}: {}", self.trait_ref.self_ty(), self.trait_ref) } } diff --git a/src/test/compile-fail/associated-types-for-unimpl-trait.rs b/src/test/compile-fail/associated-types-for-unimpl-trait.rs index 9fa24850e037..a6fcb9cff13e 100644 --- a/src/test/compile-fail/associated-types-for-unimpl-trait.rs +++ b/src/test/compile-fail/associated-types-for-unimpl-trait.rs @@ -15,7 +15,7 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait bound `Self : Get` is not satisfied + //~^ ERROR the trait bound `Self: Get` is not satisfied } fn main() { diff --git a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs b/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs index 18d9ea52ff25..83726a1676d2 100644 --- a/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs +++ b/src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs @@ -18,7 +18,7 @@ trait Foo { fn f>(t: &T) { let u: >::Bar = t.get_bar(); - //~^ ERROR the trait bound `T : Foo` is not satisfied + //~^ ERROR the trait bound `T: Foo` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-bound.rs b/src/test/compile-fail/associated-types-no-suitable-bound.rs index 0aafd193c90d..baf56ffec869 100644 --- a/src/test/compile-fail/associated-types-no-suitable-bound.rs +++ b/src/test/compile-fail/associated-types-no-suitable-bound.rs @@ -19,7 +19,7 @@ struct Struct { impl Struct { fn uhoh(foo: ::Value) {} - //~^ ERROR the trait bound `T : Get` is not satisfied + //~^ ERROR the trait bound `T: Get` is not satisfied } fn main() { diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs index 225ee0857013..e0f0f3c47ae5 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait-2.rs @@ -25,7 +25,7 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait bound `Self : Get` is not satisfied + //~^ ERROR the trait bound `Self: Get` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs index fe519beef672..ec38595e8fe0 100644 --- a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs +++ b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs @@ -25,12 +25,12 @@ trait Get { trait Other { fn uhoh(&self, foo: U, bar: ::Value) {} - //~^ ERROR the trait bound `Self : Get` is not satisfied + //~^ ERROR the trait bound `Self: Get` is not satisfied } impl Other for T { fn uhoh(&self, foo: U, bar: <(T, U) as Get>::Value) {} - //~^ ERROR the trait bound `(T, U) : Get` is not satisfied + //~^ ERROR the trait bound `(T, U): Get` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/associated-types-path-2.rs b/src/test/compile-fail/associated-types-path-2.rs index ee228899bb37..0c077e37e43b 100644 --- a/src/test/compile-fail/associated-types-path-2.rs +++ b/src/test/compile-fail/associated-types-path-2.rs @@ -38,12 +38,12 @@ pub fn f1_int_uint() { pub fn f1_uint_uint() { f1(2u32, 4u32); - //~^ ERROR `u32 : Foo` is not satisfied + //~^ ERROR `u32: Foo` is not satisfied } pub fn f1_uint_int() { f1(2u32, 4i32); - //~^ ERROR `u32 : Foo` is not satisfied + //~^ ERROR `u32: Foo` is not satisfied } pub fn f2_int() { diff --git a/src/test/compile-fail/associated-types-unsized.rs b/src/test/compile-fail/associated-types-unsized.rs index 468b40e69718..f18270229641 100644 --- a/src/test/compile-fail/associated-types-unsized.rs +++ b/src/test/compile-fail/associated-types-unsized.rs @@ -14,7 +14,7 @@ trait Get { } fn foo(t: T) { - let x = t.get(); //~ ERROR `::Value : std::marker::Sized` is not + let x = t.get(); //~ ERROR `::Value: std::marker::Sized` is not } fn main() { diff --git a/src/test/compile-fail/bad-method-typaram-kind.rs b/src/test/compile-fail/bad-method-typaram-kind.rs index 4de6600f2d24..5be90f050183 100644 --- a/src/test/compile-fail/bad-method-typaram-kind.rs +++ b/src/test/compile-fail/bad-method-typaram-kind.rs @@ -9,7 +9,7 @@ // except according to those terms. fn foo() { - 1.bar::(); //~ ERROR `T : std::marker::Send` is not satisfied + 1.bar::(); //~ ERROR `T: std::marker::Send` is not satisfied } trait bar { diff --git a/src/test/compile-fail/bad-sized.rs b/src/test/compile-fail/bad-sized.rs index d25d0081c566..f62404e60e69 100644 --- a/src/test/compile-fail/bad-sized.rs +++ b/src/test/compile-fail/bad-sized.rs @@ -12,7 +12,7 @@ trait Trait {} pub fn main() { let x: Vec = Vec::new(); - //~^ ERROR `Trait + Sized : std::marker::Sized` is not satisfied - //~| ERROR `Trait + Sized : std::marker::Sized` is not satisfied - //~| ERROR `Trait + Sized : std::marker::Sized` is not satisfied + //~^ ERROR `Trait + Sized: std::marker::Sized` is not satisfied + //~| ERROR `Trait + Sized: std::marker::Sized` is not satisfied + //~| ERROR `Trait + Sized: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/builtin-superkinds-double-superkind.rs b/src/test/compile-fail/builtin-superkinds-double-superkind.rs index 03ab94e5908f..8d5d8e8dc9b7 100644 --- a/src/test/compile-fail/builtin-superkinds-double-superkind.rs +++ b/src/test/compile-fail/builtin-superkinds-double-superkind.rs @@ -13,9 +13,9 @@ trait Foo : Send+Sync { } -impl Foo for (T,) { } //~ ERROR `T : std::marker::Send` is not satisfied +impl Foo for (T,) { } //~ ERROR `T: std::marker::Send` is not satisfied -impl Foo for (T,T) { } //~ ERROR `T : std::marker::Sync` is not satisfied +impl Foo for (T,T) { } //~ ERROR `T: std::marker::Sync` is not satisfied impl Foo for (T,T,T) { } // (ok) diff --git a/src/test/compile-fail/builtin-superkinds-in-metadata.rs b/src/test/compile-fail/builtin-superkinds-in-metadata.rs index 1063280ea265..de2084c4e818 100644 --- a/src/test/compile-fail/builtin-superkinds-in-metadata.rs +++ b/src/test/compile-fail/builtin-superkinds-in-metadata.rs @@ -22,6 +22,6 @@ struct X(T); impl RequiresShare for X { } impl RequiresRequiresShareAndSend for X { } -//~^ ERROR `T : std::marker::Send` is not satisfied +//~^ ERROR `T: std::marker::Send` is not satisfied fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-simple.rs b/src/test/compile-fail/builtin-superkinds-simple.rs index 40625fc82aa9..6dc5f39cb30d 100644 --- a/src/test/compile-fail/builtin-superkinds-simple.rs +++ b/src/test/compile-fail/builtin-superkinds-simple.rs @@ -14,6 +14,6 @@ trait Foo : Send { } impl Foo for std::rc::Rc { } -//~^ ERROR `std::rc::Rc : std::marker::Send` is not satisfied +//~^ ERROR `std::rc::Rc: std::marker::Send` is not satisfied fn main() { } diff --git a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs index 7e05c6462ffa..d4bb8de13d05 100644 --- a/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs +++ b/src/test/compile-fail/builtin-superkinds-typaram-not-send.rs @@ -12,6 +12,6 @@ trait Foo : Send { } -impl Foo for T { } //~ ERROR `T : std::marker::Send` is not satisfied +impl Foo for T { } //~ ERROR `T: std::marker::Send` is not satisfied fn main() { } diff --git a/src/test/compile-fail/cast-rfc0401.rs b/src/test/compile-fail/cast-rfc0401.rs index c032fb43402f..dcd49e34bb26 100644 --- a/src/test/compile-fail/cast-rfc0401.rs +++ b/src/test/compile-fail/cast-rfc0401.rs @@ -91,7 +91,7 @@ fn main() let _ = 42usize as *const [u8]; //~ ERROR casting let _ = v as *const [u8]; //~ ERROR cannot cast let _ = fat_v as *const Foo; - //~^ ERROR the trait bound `[u8] : std::marker::Sized` is not satisfied + //~^ ERROR the trait bound `[u8]: std::marker::Sized` is not satisfied //~^^ HELP run `rustc --explain E0277` to see a detailed explanation //~^^^ NOTE `[u8]` does not have a constant size known at compile-time //~^^^^ NOTE required for the cast to the object type `Foo` @@ -106,7 +106,7 @@ fn main() let a : *const str = "hello"; let _ = a as *const Foo; - //~^ ERROR the trait bound `str : std::marker::Sized` is not satisfied + //~^ ERROR the trait bound `str: std::marker::Sized` is not satisfied //~^^ HELP run `rustc --explain E0277` to see a detailed explanation //~^^^ NOTE `str` does not have a constant size known at compile-time //~^^^^ NOTE required for the cast to the object type `Foo` diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index ed18ed62111c..b9224e7be7f1 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -13,7 +13,7 @@ struct X where F: FnOnce() + 'static + Send { } fn foo(blk: F) -> X where F: FnOnce() + 'static { - //~^ ERROR `F : std::marker::Send` is not satisfied + //~^ ERROR `F: std::marker::Send` is not satisfied return X { field: blk }; } diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index b618cd07760d..d3339c4845ab 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -21,7 +21,7 @@ fn give_any(f: F) where F: FnOnce() { fn give_owned(f: F) where F: FnOnce() + Send { take_any(f); - take_const_owned(f); //~ ERROR `F : std::marker::Sync` is not satisfied + take_const_owned(f); //~ ERROR `F: std::marker::Sync` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/cross-fn-cache-hole.rs b/src/test/compile-fail/cross-fn-cache-hole.rs index 0a3ce03f27bf..b034fedb805e 100644 --- a/src/test/compile-fail/cross-fn-cache-hole.rs +++ b/src/test/compile-fail/cross-fn-cache-hole.rs @@ -23,7 +23,7 @@ trait Bar { } // We don't always check where clauses for sanity, but in this case // wfcheck does report an error here: -fn vacuous() //~ ERROR the trait bound `i32 : Bar` is not satisfied +fn vacuous() //~ ERROR the trait bound `i32: Bar` is not satisfied where i32: Foo { // ... the original intention was to check that we don't use that diff --git a/src/test/compile-fail/deriving-no-inner-impl-error-message.rs b/src/test/compile-fail/deriving-no-inner-impl-error-message.rs index d767fc326362..129c859b9195 100644 --- a/src/test/compile-fail/deriving-no-inner-impl-error-message.rs +++ b/src/test/compile-fail/deriving-no-inner-impl-error-message.rs @@ -18,7 +18,7 @@ struct E { #[derive(Clone)] struct C { x: NoCloneOrEq - //~^ ERROR `NoCloneOrEq : std::clone::Clone` is not satisfied + //~^ ERROR `NoCloneOrEq: std::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/deriving-span-Default-struct.rs b/src/test/compile-fail/deriving-span-Default-struct.rs index 6b81804e028b..56fb38611735 100644 --- a/src/test/compile-fail/deriving-span-Default-struct.rs +++ b/src/test/compile-fail/deriving-span-Default-struct.rs @@ -17,7 +17,7 @@ struct Error; #[derive(Default)] struct Struct { - x: Error //~ ERROR `Error : std::default::Default` is not satisfied + x: Error //~ ERROR `Error: std::default::Default` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/destructure-trait-ref.rs b/src/test/compile-fail/destructure-trait-ref.rs index 3e6428c7d579..68d979571024 100644 --- a/src/test/compile-fail/destructure-trait-ref.rs +++ b/src/test/compile-fail/destructure-trait-ref.rs @@ -35,7 +35,7 @@ fn main() { // n == m let &x = &1isize as &T; //~ ERROR type `&T` cannot be dereferenced let &&x = &(&1isize as &T); //~ ERROR type `&T` cannot be dereferenced - let box x = box 1isize as Box; //~ ERROR `T : std::marker::Sized` is not satisfied + let box x = box 1isize as Box; //~ ERROR `T: std::marker::Sized` is not satisfied // n > m let &&x = &1isize as &T; diff --git a/src/test/compile-fail/dst-bad-assign-2.rs b/src/test/compile-fail/dst-bad-assign-2.rs index 6e2380da6a13..241fabf053c0 100644 --- a/src/test/compile-fail/dst-bad-assign-2.rs +++ b/src/test/compile-fail/dst-bad-assign-2.rs @@ -44,5 +44,5 @@ pub fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let z: Box = Box::new(Bar1 {f: 36}); f5.ptr = *z; - //~^ ERROR `ToBar : std::marker::Sized` is not satisfied + //~^ ERROR `ToBar: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/dst-bad-assign.rs b/src/test/compile-fail/dst-bad-assign.rs index ab874d4e877c..2d21d0ebc760 100644 --- a/src/test/compile-fail/dst-bad-assign.rs +++ b/src/test/compile-fail/dst-bad-assign.rs @@ -49,5 +49,5 @@ pub fn main() { //~| found `Bar1` //~| expected trait ToBar //~| found struct `Bar1` - //~| ERROR `ToBar : std::marker::Sized` is not satisfied + //~| ERROR `ToBar: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/dst-bad-coerce1.rs b/src/test/compile-fail/dst-bad-coerce1.rs index 2413bbae84c0..9a3ea54a3a45 100644 --- a/src/test/compile-fail/dst-bad-coerce1.rs +++ b/src/test/compile-fail/dst-bad-coerce1.rs @@ -28,5 +28,5 @@ pub fn main() { let f1 = Fat { ptr: Foo }; let f2: &Fat = &f1; let f3: &Fat = f2; - //~^ ERROR `Foo : Bar` is not satisfied + //~^ ERROR `Foo: Bar` is not satisfied } diff --git a/src/test/compile-fail/dst-bad-deep.rs b/src/test/compile-fail/dst-bad-deep.rs index 0b9d99396f7c..f508364d7511 100644 --- a/src/test/compile-fail/dst-bad-deep.rs +++ b/src/test/compile-fail/dst-bad-deep.rs @@ -21,5 +21,5 @@ pub fn main() { let f: Fat<[isize; 3]> = Fat { ptr: [5, 6, 7] }; let g: &Fat<[isize]> = &f; let h: &Fat> = &Fat { ptr: *g }; - //~^ ERROR `[isize] : std::marker::Sized` is not satisfied + //~^ ERROR `[isize]: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/dst-object-from-unsized-type.rs b/src/test/compile-fail/dst-object-from-unsized-type.rs index 36bd1a98ca91..8fafd78d4079 100644 --- a/src/test/compile-fail/dst-object-from-unsized-type.rs +++ b/src/test/compile-fail/dst-object-from-unsized-type.rs @@ -16,22 +16,22 @@ impl Foo for [u8] {} fn test1(t: &T) { let u: &Foo = t; - //~^ ERROR `T : std::marker::Sized` is not satisfied + //~^ ERROR `T: std::marker::Sized` is not satisfied } fn test2(t: &T) { let v: &Foo = t as &Foo; - //~^ ERROR `T : std::marker::Sized` is not satisfied + //~^ ERROR `T: std::marker::Sized` is not satisfied } fn test3() { let _: &[&Foo] = &["hi"]; - //~^ ERROR `str : std::marker::Sized` is not satisfied + //~^ ERROR `str: std::marker::Sized` is not satisfied } fn test4(x: &[u8]) { let _: &Foo = x as &Foo; - //~^ ERROR `[u8] : std::marker::Sized` is not satisfied + //~^ ERROR `[u8]: std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/dst-sized-trait-param.rs b/src/test/compile-fail/dst-sized-trait-param.rs index 375008715635..bd5fd3ee3b71 100644 --- a/src/test/compile-fail/dst-sized-trait-param.rs +++ b/src/test/compile-fail/dst-sized-trait-param.rs @@ -15,9 +15,9 @@ trait Foo : Sized { fn take(self, x: &T) { } } // Note: T is sized impl Foo<[isize]> for usize { } -//~^ ERROR `[isize] : std::marker::Sized` is not satisfied +//~^ ERROR `[isize]: std::marker::Sized` is not satisfied impl Foo for [usize] { } -//~^ ERROR `[usize] : std::marker::Sized` is not satisfied +//~^ ERROR `[usize]: std::marker::Sized` is not satisfied pub fn main() { } diff --git a/src/test/compile-fail/extern-wrong-value-type.rs b/src/test/compile-fail/extern-wrong-value-type.rs index 89ed960c8913..576368aef312 100644 --- a/src/test/compile-fail/extern-wrong-value-type.rs +++ b/src/test/compile-fail/extern-wrong-value-type.rs @@ -17,6 +17,6 @@ fn main() { // extern functions are extern "C" fn let _x: extern "C" fn() = f; // OK is_fn(f); - //~^ ERROR `extern "C" fn() {f} : std::ops::Fn<()>` is not satisfied - //~| ERROR `extern "C" fn() {f} : std::ops::FnOnce<()>` is not satisfied + //~^ ERROR `extern "C" fn() {f}: std::ops::Fn<()>` is not satisfied + //~| ERROR `extern "C" fn() {f}: std::ops::FnOnce<()>` is not satisfied } diff --git a/src/test/compile-fail/for-loop-bogosity.rs b/src/test/compile-fail/for-loop-bogosity.rs index 8b127ca17958..96ad184fd355 100644 --- a/src/test/compile-fail/for-loop-bogosity.rs +++ b/src/test/compile-fail/for-loop-bogosity.rs @@ -24,7 +24,7 @@ pub fn main() { x: 1, y: 2, }; - for x in bogus { //~ ERROR `MyStruct : std::iter::Iterator` + for x in bogus { //~ ERROR `MyStruct: std::iter::Iterator` is not satisfied drop(x); } } diff --git a/src/test/compile-fail/hrtb-just-for-static.rs b/src/test/compile-fail/hrtb-just-for-static.rs index 270e6b9f183a..aec950f992cf 100644 --- a/src/test/compile-fail/hrtb-just-for-static.rs +++ b/src/test/compile-fail/hrtb-just-for-static.rs @@ -31,7 +31,7 @@ fn give_any() { struct StaticInt; impl Foo<&'static isize> for StaticInt { } fn give_static() { - want_hrtb::() //~ ERROR `for<'a> StaticInt : Foo<&'a isize>` is not satisfied + want_hrtb::() //~ ERROR `for<'a> StaticInt: Foo<&'a isize>` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/hrtb-perfect-forwarding.rs b/src/test/compile-fail/hrtb-perfect-forwarding.rs index 24e59e6c29e3..fcfbeefced06 100644 --- a/src/test/compile-fail/hrtb-perfect-forwarding.rs +++ b/src/test/compile-fail/hrtb-perfect-forwarding.rs @@ -53,7 +53,7 @@ fn foo_hrtb_bar_not<'b,T>(mut t: T) // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where // clause only specifies `T : Bar<&'b isize>`. - foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> T : Bar<&'a isize>` is not satisfied + foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> T: Bar<&'a isize>` is not satisfied } fn foo_hrtb_bar_hrtb(mut t: T) diff --git a/src/test/compile-fail/ifmt-unimpl.rs b/src/test/compile-fail/ifmt-unimpl.rs index dd14d0c91545..9b9bae92c33c 100644 --- a/src/test/compile-fail/ifmt-unimpl.rs +++ b/src/test/compile-fail/ifmt-unimpl.rs @@ -10,5 +10,5 @@ fn main() { format!("{:X}", "3"); - //~^ ERROR: `str : std::fmt::UpperHex` is not satisfied + //~^ ERROR: `str: std::fmt::UpperHex` is not satisfied } diff --git a/src/test/compile-fail/impl-bounds-checking.rs b/src/test/compile-fail/impl-bounds-checking.rs index 12696585a9e6..f90365b71ae5 100644 --- a/src/test/compile-fail/impl-bounds-checking.rs +++ b/src/test/compile-fail/impl-bounds-checking.rs @@ -17,7 +17,7 @@ trait Getter { fn get(&self) -> T; } -impl Getter for isize { //~ ERROR `isize : Clone2` is not satisfied +impl Getter for isize { //~ ERROR `isize: Clone2` is not satisfied fn get(&self) -> isize { *self } } diff --git a/src/test/compile-fail/indexing-requires-a-uint.rs b/src/test/compile-fail/indexing-requires-a-uint.rs index f8979686038b..354d7b936485 100644 --- a/src/test/compile-fail/indexing-requires-a-uint.rs +++ b/src/test/compile-fail/indexing-requires-a-uint.rs @@ -13,7 +13,7 @@ fn main() { fn bar(_: T) {} - [0][0u8]; //~ ERROR: `[_] : std::ops::Index` is not satisfied + [0][0u8]; //~ ERROR: `[_]: std::ops::Index` is not satisfied [0][0]; // should infer to be a usize diff --git a/src/test/compile-fail/issue-14084.rs b/src/test/compile-fail/issue-14084.rs index 20da46dcaa29..446514c8dd45 100644 --- a/src/test/compile-fail/issue-14084.rs +++ b/src/test/compile-fail/issue-14084.rs @@ -13,5 +13,5 @@ fn main() { () <- 0; - //~^ ERROR: `() : std::ops::Placer<_>` is not satisfied + //~^ ERROR: `(): std::ops::Placer<_>` is not satisfied } diff --git a/src/test/compile-fail/issue-14366.rs b/src/test/compile-fail/issue-14366.rs index 6f4e9887dc6e..84452accc9a4 100644 --- a/src/test/compile-fail/issue-14366.rs +++ b/src/test/compile-fail/issue-14366.rs @@ -10,5 +10,5 @@ fn main() { let _x = "test" as &::std::any::Any; -//~^ ERROR `str : std::marker::Sized` is not satisfied +//~^ ERROR `str: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/issue-14853.rs b/src/test/compile-fail/issue-14853.rs index c6c1a0fd1778..c4d882670329 100644 --- a/src/test/compile-fail/issue-14853.rs +++ b/src/test/compile-fail/issue-14853.rs @@ -20,7 +20,7 @@ struct X { data: u32 } impl Something for X { fn yay(_:Option, thing: &[T]) { - //~^ ERROR the requirement `T : Str` appears on the impl method + //~^ ERROR the requirement `T: Str` appears on the impl method } } diff --git a/src/test/compile-fail/issue-15756.rs b/src/test/compile-fail/issue-15756.rs index 790000a3f923..41349d7d7443 100644 --- a/src/test/compile-fail/issue-15756.rs +++ b/src/test/compile-fail/issue-15756.rs @@ -15,7 +15,7 @@ fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>) { for &mut something -//~^ ERROR `[T] : std::marker::Sized` is not satisfied +//~^ ERROR `[T]: std::marker::Sized` is not satisfied in arg2 { } diff --git a/src/test/compile-fail/issue-16538.rs b/src/test/compile-fail/issue-16538.rs index 79d2224aad6f..6c41450796c7 100644 --- a/src/test/compile-fail/issue-16538.rs +++ b/src/test/compile-fail/issue-16538.rs @@ -19,7 +19,7 @@ mod Y { } static foo: *const Y::X = Y::foo(Y::x as *const Y::X); -//~^ ERROR `*const usize : std::marker::Sync` is not satisfied +//~^ ERROR `*const usize: std::marker::Sync` is not satisfied //~| ERROR cannot refer to other statics by value, use the address-of operator or a constant instead //~| ERROR E0015 diff --git a/src/test/compile-fail/issue-17651.rs b/src/test/compile-fail/issue-17651.rs index edd9b6e0c066..0fe01ece558e 100644 --- a/src/test/compile-fail/issue-17651.rs +++ b/src/test/compile-fail/issue-17651.rs @@ -14,5 +14,5 @@ fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. (|| Box::new(*(&[0][..])))(); - //~^ ERROR `[_] : std::marker::Sized` is not satisfied + //~^ ERROR `[_]: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/issue-17718-static-sync.rs b/src/test/compile-fail/issue-17718-static-sync.rs index 1bb3b7941352..790329cd2e42 100644 --- a/src/test/compile-fail/issue-17718-static-sync.rs +++ b/src/test/compile-fail/issue-17718-static-sync.rs @@ -17,6 +17,6 @@ impl !Sync for Foo {} static FOO: usize = 3; static BAR: Foo = Foo; -//~^ ERROR: `Foo : std::marker::Sync` is not satisfied +//~^ ERROR: `Foo: std::marker::Sync` is not satisfied fn main() {} diff --git a/src/test/compile-fail/issue-17959.rs b/src/test/compile-fail/issue-17959.rs index 56a66ecc8aa4..23be4d353611 100644 --- a/src/test/compile-fail/issue-17959.rs +++ b/src/test/compile-fail/issue-17959.rs @@ -19,7 +19,7 @@ struct G { } impl Drop for G { -//~^ ERROR: The requirement `T : core::marker::Sized` is added only by the Drop impl. [E0367] +//~^ ERROR: The requirement `T: core::marker::Sized` is added only by the Drop impl. [E0367] fn drop(&mut self) { if !self._ptr.is_null() { } diff --git a/src/test/compile-fail/issue-18107.rs b/src/test/compile-fail/issue-18107.rs index 6b40811bf04f..33d68c121bf2 100644 --- a/src/test/compile-fail/issue-18107.rs +++ b/src/test/compile-fail/issue-18107.rs @@ -12,7 +12,7 @@ pub trait AbstractRenderer {} fn _create_render(_: &()) -> AbstractRenderer -//~^ ERROR: `AbstractRenderer + 'static : std::marker::Sized` is not satisfied +//~^ ERROR: `AbstractRenderer + 'static: std::marker::Sized` is not satisfied { match 0 { _ => unimplemented!() diff --git a/src/test/compile-fail/issue-18611.rs b/src/test/compile-fail/issue-18611.rs index 5318b18be5c7..a3ad76e1be06 100644 --- a/src/test/compile-fail/issue-18611.rs +++ b/src/test/compile-fail/issue-18611.rs @@ -9,7 +9,7 @@ // except according to those terms. fn add_state(op: ::State) { -//~^ ERROR `isize : HasState` is not satisfied +//~^ ERROR `isize: HasState` is not satisfied } trait HasState { diff --git a/src/test/compile-fail/issue-18919.rs b/src/test/compile-fail/issue-18919.rs index 2742162de531..3e21360721b6 100644 --- a/src/test/compile-fail/issue-18919.rs +++ b/src/test/compile-fail/issue-18919.rs @@ -11,7 +11,7 @@ type FuncType<'f> = Fn(&isize) -> isize + 'f; fn ho_func(f: Option) { - //~^ ERROR: `for<'r> std::ops::Fn(&'r isize) -> isize : std::marker::Sized` is not satisfied + //~^ ERROR: `for<'r> std::ops::Fn(&'r isize) -> isize: std::marker::Sized` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/issue-1920-1.rs b/src/test/compile-fail/issue-1920-1.rs index f37693d8a584..8fbe4432204a 100644 --- a/src/test/compile-fail/issue-1920-1.rs +++ b/src/test/compile-fail/issue-1920-1.rs @@ -18,5 +18,5 @@ fn assert_clone() where T : Clone { } fn main() { assert_clone::(); - //~^ ERROR `foo::core::sync::atomic::AtomicBool : foo::core::clone::Clone` is not satisfied + //~^ ERROR `foo::core::sync::atomic::AtomicBool: foo::core::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/issue-1920-2.rs b/src/test/compile-fail/issue-1920-2.rs index c8d7bcaecf93..02c925f336ea 100644 --- a/src/test/compile-fail/issue-1920-2.rs +++ b/src/test/compile-fail/issue-1920-2.rs @@ -16,5 +16,5 @@ fn assert_clone() where T : Clone { } fn main() { assert_clone::(); - //~^ ERROR `bar::sync::atomic::AtomicBool : bar::clone::Clone` is not satisfied + //~^ ERROR `bar::sync::atomic::AtomicBool: bar::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/issue-1920-3.rs b/src/test/compile-fail/issue-1920-3.rs index c0252deda24c..dfec48e0a83c 100644 --- a/src/test/compile-fail/issue-1920-3.rs +++ b/src/test/compile-fail/issue-1920-3.rs @@ -20,5 +20,5 @@ fn assert_clone() where T : Clone { } fn main() { assert_clone::(); - //~^ ERROR `core::sync::atomic::AtomicBool : core::clone::Clone` is not satisfied + //~^ ERROR `core::sync::atomic::AtomicBool: core::clone::Clone` is not satisfied } diff --git a/src/test/compile-fail/issue-20005.rs b/src/test/compile-fail/issue-20005.rs index a54fc0a314b6..b02757fb5a31 100644 --- a/src/test/compile-fail/issue-20005.rs +++ b/src/test/compile-fail/issue-20005.rs @@ -15,7 +15,7 @@ trait From { } trait To { - fn to( //~ ERROR `Self : std::marker::Sized` is not satisfied + fn to( //~ ERROR `Self: std::marker::Sized` is not satisfied self ) -> >::Result where Dst: From { From::from(self) diff --git a/src/test/compile-fail/issue-20162.rs b/src/test/compile-fail/issue-20162.rs index 5e60e2a36f62..b2f3a2da5161 100644 --- a/src/test/compile-fail/issue-20162.rs +++ b/src/test/compile-fail/issue-20162.rs @@ -13,5 +13,5 @@ struct X { x: i32 } fn main() { let mut b: Vec = vec![]; b.sort(); - //~^ ERROR `X : std::cmp::Ord` is not satisfied + //~^ ERROR `X: std::cmp::Ord` is not satisfied } diff --git a/src/test/compile-fail/issue-20605.rs b/src/test/compile-fail/issue-20605.rs index 2634370fe902..b7c544c78483 100644 --- a/src/test/compile-fail/issue-20605.rs +++ b/src/test/compile-fail/issue-20605.rs @@ -10,7 +10,7 @@ fn changer<'a>(mut things: Box>) { for item in *things { *item = 0 } -//~^ ERROR `std::iter::Iterator : std::marker::Sized` is not satisfied +//~^ ERROR `std::iter::Iterator: std::marker::Sized` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/issue-21160.rs b/src/test/compile-fail/issue-21160.rs index 7d9ae0543c75..0de0ab2269bf 100644 --- a/src/test/compile-fail/issue-21160.rs +++ b/src/test/compile-fail/issue-21160.rs @@ -16,6 +16,6 @@ impl Bar { #[derive(Hash)] struct Foo(Bar); -//~^ error: `Bar : std::hash::Hash` is not satisfied +//~^ error: `Bar: std::hash::Hash` is not satisfied fn main() {} diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs index 7bc4adfa85d0..e880a8b212bb 100644 --- a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-1.rs @@ -32,7 +32,7 @@ fn main() { let f1 = Bar; f1.foo(1usize); - //~^ error: the trait bound `Bar : Foo` is not satisfied + //~^ error: the trait bound `Bar: Foo` is not satisfied //~| help: the following implementations were found: //~| help: > //~| help: > diff --git a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs index f4e536144720..2c5b18a8113f 100644 --- a/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs +++ b/src/test/compile-fail/issue-21659-show-relevant-trait-impls-2.rs @@ -36,7 +36,7 @@ fn main() { let f1 = Bar; f1.foo(1usize); - //~^ error: the trait bound `Bar : Foo` is not satisfied + //~^ error: the trait bound `Bar: Foo` is not satisfied //~| help: the following implementations were found: //~| help: > //~| help: > diff --git a/src/test/compile-fail/issue-21763.rs b/src/test/compile-fail/issue-21763.rs index 2f0611a2086e..cb0baee0a878 100644 --- a/src/test/compile-fail/issue-21763.rs +++ b/src/test/compile-fail/issue-21763.rs @@ -17,5 +17,5 @@ fn foo() {} fn main() { foo::, Rc<()>>>(); - //~^ ERROR: `std::rc::Rc<()> : std::marker::Send` is not satisfied + //~^ ERROR: `std::rc::Rc<()>: std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/issue-22034.rs b/src/test/compile-fail/issue-22034.rs index 29bef8c966a4..3e0ab6d89212 100644 --- a/src/test/compile-fail/issue-22034.rs +++ b/src/test/compile-fail/issue-22034.rs @@ -14,7 +14,7 @@ fn main() { let ptr: *mut () = 0 as *mut _; let _: &mut Fn() = unsafe { &mut *(ptr as *mut Fn()) - //~^ ERROR `() : std::ops::Fn<()>` is not satisfied - //~| ERROR `() : std::ops::FnOnce<()>` is not satisfied + //~^ ERROR `(): std::ops::Fn<()>` is not satisfied + //~| ERROR `(): std::ops::FnOnce<()>` is not satisfied }; } diff --git a/src/test/compile-fail/issue-25076.rs b/src/test/compile-fail/issue-25076.rs index 9d0b559d13d3..1c255b4e6314 100644 --- a/src/test/compile-fail/issue-25076.rs +++ b/src/test/compile-fail/issue-25076.rs @@ -17,5 +17,5 @@ fn do_fold>(init: B, f: F) {} fn bot() -> T { loop {} } fn main() { - do_fold(bot(), ()); //~ ERROR `() : InOut<_>` is not satisfied + do_fold(bot(), ()); //~ ERROR `(): InOut<_>` is not satisfied } diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index 49f024399c7e..16d7ea468466 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -21,7 +21,7 @@ struct E { impl A for E { fn b(&self, _x: F) -> F { panic!() } - //~^ ERROR `F : std::marker::Sync` appears on the impl method + //~^ ERROR `F: std::marker::Sync` appears on the impl method } fn main() {} diff --git a/src/test/compile-fail/issue-28098.rs b/src/test/compile-fail/issue-28098.rs index aac282370c64..5dded2b1e169 100644 --- a/src/test/compile-fail/issue-28098.rs +++ b/src/test/compile-fail/issue-28098.rs @@ -10,13 +10,13 @@ fn main() { let _ = Iterator::next(&mut ()); - //~^ ERROR `() : std::iter::Iterator` is not satisfied + //~^ ERROR `(): std::iter::Iterator` is not satisfied for _ in false {} - //~^ ERROR `bool : std::iter::Iterator` is not satisfied + //~^ ERROR `bool: std::iter::Iterator` is not satisfied let _ = Iterator::next(&mut ()); - //~^ ERROR `() : std::iter::Iterator` is not satisfied + //~^ ERROR `(): std::iter::Iterator` is not satisfied other() } @@ -25,11 +25,11 @@ pub fn other() { // check errors are still reported globally let _ = Iterator::next(&mut ()); - //~^ ERROR `() : std::iter::Iterator` is not satisfied + //~^ ERROR `(): std::iter::Iterator` is not satisfied let _ = Iterator::next(&mut ()); - //~^ ERROR `() : std::iter::Iterator` is not satisfied + //~^ ERROR `(): std::iter::Iterator` is not satisfied for _ in false {} - //~^ ERROR `bool : std::iter::Iterator` is not satisfied + //~^ ERROR `bool: std::iter::Iterator` is not satisfied } diff --git a/src/test/compile-fail/issue-29147.rs b/src/test/compile-fail/issue-29147.rs index 64bfa232f3ff..0ecaa409412a 100644 --- a/src/test/compile-fail/issue-29147.rs +++ b/src/test/compile-fail/issue-29147.rs @@ -28,5 +28,5 @@ impl Foo for S5 { fn xxx(&self) {} } impl Foo for S5 { fn xxx(&self) {} } fn main() { - let _ = >::xxx; //~ ERROR cannot resolve `S5<_> : Foo` + let _ = >::xxx; //~ ERROR cannot resolve `S5<_>: Foo` } diff --git a/src/test/compile-fail/issue-5035-2.rs b/src/test/compile-fail/issue-5035-2.rs index 118644ef2cb6..83ff95cc2ea4 100644 --- a/src/test/compile-fail/issue-5035-2.rs +++ b/src/test/compile-fail/issue-5035-2.rs @@ -11,6 +11,6 @@ trait I {} type K = I+'static; -fn foo(_x: K) {} //~ ERROR: `I + 'static : std::marker::Sized` is not satisfied +fn foo(_x: K) {} //~ ERROR: `I + 'static: std::marker::Sized` is not satisfied fn main() {} diff --git a/src/test/compile-fail/issue-5883.rs b/src/test/compile-fail/issue-5883.rs index 0058d5af62e4..019a7bdc734d 100644 --- a/src/test/compile-fail/issue-5883.rs +++ b/src/test/compile-fail/issue-5883.rs @@ -15,8 +15,8 @@ struct Struct { } fn new_struct(r: A+'static) - -> Struct { //~^ ERROR `A + 'static : std::marker::Sized` is not satisfied - //~^ ERROR `A + 'static : std::marker::Sized` is not satisfied + -> Struct { //~^ ERROR `A + 'static: std::marker::Sized` is not satisfied + //~^ ERROR `A + 'static: std::marker::Sized` is not satisfied Struct { r: r } } diff --git a/src/test/compile-fail/issue-7013.rs b/src/test/compile-fail/issue-7013.rs index c676c95ad25e..95bbd4eccf4f 100644 --- a/src/test/compile-fail/issue-7013.rs +++ b/src/test/compile-fail/issue-7013.rs @@ -34,5 +34,5 @@ struct A { fn main() { let a = A {v: box B{v: None} as Box}; - //~^ ERROR `std::rc::Rc> : std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc>: std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/issue-7364.rs b/src/test/compile-fail/issue-7364.rs index 8d4ebbe72071..16b407baad17 100644 --- a/src/test/compile-fail/issue-7364.rs +++ b/src/test/compile-fail/issue-7364.rs @@ -16,6 +16,6 @@ use std::cell::RefCell; // Regression test for issue 7364 static boxed: Box> = box RefCell::new(0); //~^ ERROR allocations are not allowed in statics -//~| ERROR `std::cell::RefCell : std::marker::Sync` is not satisfied +//~| ERROR `std::cell::RefCell: std::marker::Sync` is not satisfied fn main() { } diff --git a/src/test/compile-fail/kindck-impl-type-params-2.rs b/src/test/compile-fail/kindck-impl-type-params-2.rs index cf51e9bd6081..1cf970e150d7 100644 --- a/src/test/compile-fail/kindck-impl-type-params-2.rs +++ b/src/test/compile-fail/kindck-impl-type-params-2.rs @@ -21,5 +21,5 @@ fn take_param(foo: &T) { } fn main() { let x: Box<_> = box 3; take_param(&x); - //~^ ERROR `Box<_> : std::marker::Copy` is not satisfied + //~^ ERROR `Box<_>: std::marker::Copy` is not satisfied } diff --git a/src/test/compile-fail/kindck-send-unsafe.rs b/src/test/compile-fail/kindck-send-unsafe.rs index c7eca74f7800..ecee2e0a4c63 100644 --- a/src/test/compile-fail/kindck-send-unsafe.rs +++ b/src/test/compile-fail/kindck-send-unsafe.rs @@ -14,7 +14,7 @@ fn assert_send() { } fn test71<'a>() { assert_send::<*mut &'a isize>(); - //~^ ERROR `*mut &'a isize : core::marker::Send` is not satisfied + //~^ ERROR `*mut &'a isize: core::marker::Send` is not satisfied } fn main() { diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index b2957a71a56c..a419c6480e6a 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -28,5 +28,5 @@ fn main() { let x: Box> = x; // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let y: Box> = Box::new(x); - //~^ ERROR `Box> : Map` is not satisfied + //~^ ERROR `Box>: Map` is not satisfied } diff --git a/src/test/compile-fail/mutable-enum-indirect.rs b/src/test/compile-fail/mutable-enum-indirect.rs index bb2fdbc555b7..cafcabe6279b 100644 --- a/src/test/compile-fail/mutable-enum-indirect.rs +++ b/src/test/compile-fail/mutable-enum-indirect.rs @@ -24,5 +24,5 @@ fn bar(_: T) {} fn main() { let x = Foo::A(NoSync); - bar(&x); //~ ERROR `NoSync : std::marker::Sync` is not satisfied + bar(&x); //~ ERROR `NoSync: std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index 81d174256ee2..334952cefa6e 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -33,7 +33,7 @@ fn main() { let x = foo(Port(Rc::new(()))); thread::spawn(move|| { - //~^ ERROR `std::rc::Rc<()> : std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc<()>: std::marker::Send` is not satisfied let y = x; println!("{:?}", y); }); diff --git a/src/test/compile-fail/no_send-enum.rs b/src/test/compile-fail/no_send-enum.rs index 966d932f2a41..902710e96e27 100644 --- a/src/test/compile-fail/no_send-enum.rs +++ b/src/test/compile-fail/no_send-enum.rs @@ -24,5 +24,5 @@ fn bar(_: T) {} fn main() { let x = Foo::A(NoSend); bar(x); - //~^ ERROR `NoSend : std::marker::Send` is not satisfied + //~^ ERROR `NoSend: std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/no_send-rc.rs b/src/test/compile-fail/no_send-rc.rs index b6c7e1ad05af..69f6fcdc4afa 100644 --- a/src/test/compile-fail/no_send-rc.rs +++ b/src/test/compile-fail/no_send-rc.rs @@ -15,5 +15,5 @@ fn bar(_: T) {} fn main() { let x = Rc::new(5); bar(x); - //~^ ERROR `std::rc::Rc<_> : std::marker::Send` is not satisfied + //~^ ERROR `std::rc::Rc<_>: std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/no_send-struct.rs b/src/test/compile-fail/no_send-struct.rs index 037753e6c5fa..b2ca4f9f5db1 100644 --- a/src/test/compile-fail/no_send-struct.rs +++ b/src/test/compile-fail/no_send-struct.rs @@ -23,5 +23,5 @@ fn bar(_: T) {} fn main() { let x = Foo { a: 5 }; bar(x); - //~^ ERROR `Foo : std::marker::Send` is not satisfied + //~^ ERROR `Foo: std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/no_share-enum.rs b/src/test/compile-fail/no_share-enum.rs index be52dd418264..ae9a25a95b4e 100644 --- a/src/test/compile-fail/no_share-enum.rs +++ b/src/test/compile-fail/no_share-enum.rs @@ -22,5 +22,5 @@ fn bar(_: T) {} fn main() { let x = Foo::A(NoSync); bar(x); - //~^ ERROR `NoSync : std::marker::Sync` is not satisfied + //~^ ERROR `NoSync: std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/no_share-struct.rs b/src/test/compile-fail/no_share-struct.rs index 944bcb48ab05..d64d37a2f6c3 100644 --- a/src/test/compile-fail/no_share-struct.rs +++ b/src/test/compile-fail/no_share-struct.rs @@ -20,5 +20,5 @@ fn bar(_: T) {} fn main() { let x = Foo { a: 5 }; bar(x); - //~^ ERROR `Foo : std::marker::Sync` is not satisfied + //~^ ERROR `Foo: std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/not-sync.rs b/src/test/compile-fail/not-sync.rs index 3955e3a040c5..aa7a83a7baac 100644 --- a/src/test/compile-fail/not-sync.rs +++ b/src/test/compile-fail/not-sync.rs @@ -16,19 +16,19 @@ fn test() {} fn main() { test::>(); - //~^ ERROR `std::cell::Cell : std::marker::Sync` is not satisfied + //~^ ERROR `std::cell::Cell: std::marker::Sync` is not satisfied test::>(); - //~^ ERROR `std::cell::RefCell : std::marker::Sync` is not satisfied + //~^ ERROR `std::cell::RefCell: std::marker::Sync` is not satisfied test::>(); - //~^ ERROR `std::rc::Rc : std::marker::Sync` is not satisfied + //~^ ERROR `std::rc::Rc: std::marker::Sync` is not satisfied test::>(); - //~^ ERROR `std::rc::Weak : std::marker::Sync` is not satisfied + //~^ ERROR `std::rc::Weak: std::marker::Sync` is not satisfied test::>(); - //~^ ERROR `std::sync::mpsc::Receiver : std::marker::Sync` is not satisfied + //~^ ERROR `std::sync::mpsc::Receiver: std::marker::Sync` is not satisfied test::>(); - //~^ ERROR `std::sync::mpsc::Sender : std::marker::Sync` is not satisfied + //~^ ERROR `std::sync::mpsc::Sender: std::marker::Sync` is not satisfied test::>(); - //~^ ERROR `std::sync::mpsc::SyncSender : std::marker::Sync` is not satisfied + //~^ ERROR `std::sync::mpsc::SyncSender: std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index 6673a87e9e4e..6fa261dea71c 100644 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -14,5 +14,5 @@ trait Foo {} fn take_foo(f: F) {} fn take_object(f: Box) { take_foo(f); } -//~^ ERROR `Box : Foo` is not satisfied +//~^ ERROR `Box: Foo` is not satisfied fn main() {} diff --git a/src/test/compile-fail/phantom-oibit.rs b/src/test/compile-fail/phantom-oibit.rs index 0006b29979ca..c84927ea2663 100644 --- a/src/test/compile-fail/phantom-oibit.rs +++ b/src/test/compile-fail/phantom-oibit.rs @@ -31,11 +31,11 @@ struct Nested(T); fn is_zen(_: T) {} fn not_sync(x: Guard) { - is_zen(x) //~ error: `T : std::marker::Sync` is not satisfied + is_zen(x) //~ error: `T: std::marker::Sync` is not satisfied } fn nested_not_sync(x: Nested>) { - is_zen(x) //~ error: `T : std::marker::Sync` is not satisfied + is_zen(x) //~ error: `T: std::marker::Sync` is not satisfied } fn main() {} diff --git a/src/test/compile-fail/range-1.rs b/src/test/compile-fail/range-1.rs index 25b7465a1641..895d2450cfed 100644 --- a/src/test/compile-fail/range-1.rs +++ b/src/test/compile-fail/range-1.rs @@ -22,6 +22,6 @@ pub fn main() { // Unsized type. let arr: &[_] = &[1, 2, 3]; let range = *arr..; - //~^ ERROR `[_] : std::marker::Sized` is not satisfied - //~| ERROR `[_] : std::marker::Sized` is not satisfied + //~^ ERROR `[_]: std::marker::Sized` is not satisfied + //~| ERROR `[_]: std::marker::Sized` is not satisfied } diff --git a/src/test/compile-fail/reject-specialized-drops-8142.rs b/src/test/compile-fail/reject-specialized-drops-8142.rs index b12e26fddf6d..adc870224037 100644 --- a/src/test/compile-fail/reject-specialized-drops-8142.rs +++ b/src/test/compile-fail/reject-specialized-drops-8142.rs @@ -47,7 +47,7 @@ impl Drop for P { fn drop(&mut self) { } } // REJECT //~^ ERROR Implementations of Drop cannot be specialized impl Drop for Q { fn drop(&mut self) { } } // REJECT -//~^ ERROR The requirement `Adds_bnd : Bound` is added only by the Drop impl. +//~^ ERROR The requirement `Adds_bnd: Bound` is added only by the Drop impl. impl<'rbnd,Adds_rbnd:'rbnd> Drop for R { fn drop(&mut self) { } } // REJECT //~^ ERROR The requirement `Adds_rbnd : 'rbnd` is added only by the Drop impl. diff --git a/src/test/compile-fail/repeat-to-run-dtor-twice.rs b/src/test/compile-fail/repeat-to-run-dtor-twice.rs index 3553d0dab312..88441594a7e9 100644 --- a/src/test/compile-fail/repeat-to-run-dtor-twice.rs +++ b/src/test/compile-fail/repeat-to-run-dtor-twice.rs @@ -25,5 +25,5 @@ impl Drop for Foo { fn main() { let a = Foo { x: 3 }; let _ = [ a; 5 ]; - //~^ ERROR `Foo : std::marker::Copy` is not satisfied + //~^ ERROR `Foo: std::marker::Copy` is not satisfied } diff --git a/src/test/compile-fail/str-idx.rs b/src/test/compile-fail/str-idx.rs index 61fa3cbfe69e..b972a09b5c49 100644 --- a/src/test/compile-fail/str-idx.rs +++ b/src/test/compile-fail/str-idx.rs @@ -10,5 +10,5 @@ pub fn main() { let s: &str = "hello"; - let c: u8 = s[4]; //~ ERROR `str : std::ops::Index<_>` is not satisfied + let c: u8 = s[4]; //~ ERROR `str: std::ops::Index<_>` is not satisfied } diff --git a/src/test/compile-fail/str-mut-idx.rs b/src/test/compile-fail/str-mut-idx.rs index f372a17e045c..8851e5e07973 100644 --- a/src/test/compile-fail/str-mut-idx.rs +++ b/src/test/compile-fail/str-mut-idx.rs @@ -12,11 +12,11 @@ fn bot() -> T { loop {} } fn mutate(s: &mut str) { s[1..2] = bot(); - //~^ ERROR `str : std::marker::Sized` is not satisfied - //~| ERROR `str : std::marker::Sized` is not satisfied + //~^ ERROR `str: std::marker::Sized` is not satisfied + //~| ERROR `str: std::marker::Sized` is not satisfied s[1usize] = bot(); - //~^ ERROR `str : std::ops::Index` is not satisfied - //~| ERROR `str : std::ops::IndexMut` is not satisfied + //~^ ERROR `str: std::ops::Index` is not satisfied + //~| ERROR `str: std::ops::IndexMut` is not satisfied } pub fn main() {} diff --git a/src/test/compile-fail/substs-verbose.rs b/src/test/compile-fail/substs-verbose.rs new file mode 100644 index 000000000000..0ee7e67bebb1 --- /dev/null +++ b/src/test/compile-fail/substs-verbose.rs @@ -0,0 +1,47 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// compile-flags: -Z verbose + +// TODO nikomatsakis: test with both verbose and without + +trait Foo<'b, 'c, S=u32> { + fn bar<'a, T>() where T: 'a {} + fn baz() {} +} + +impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} + +fn main() {} + +fn foo<'z>() where &'z (): Sized { + let x: () = >::bar::<'static, char>; + //~^ ERROR mismatched types + //~| expected `()` + //~| found `fn() {>::bar::}` + + let x: () = >::bar::<'static, char>; + //~^ ERROR mismatched types + //~| expected `()` + //~| found `fn() {>::bar::}` + + let x: () = >::baz; + //~^ ERROR mismatched types + //~| expected `()` + //~| found `fn() {>::baz}` + + let x: () = foo::<'static>; + //~^ ERROR mismatched types + //~| expected `()` + //~| found `fn() {foo::}` + + >::bar; + //~^ ERROR `str: std::marker::Sized` is not satisfied +} diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs index fd0c2ddb5025..3fffb2e19f28 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-1.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-1.rs @@ -34,15 +34,15 @@ trait Foo { impl Foo for isize { // invalid bound for T, was defined as Eq in trait fn test_error1_fn(&self) {} - //~^ ERROR the requirement `T : std::cmp::Ord` appears on the impl + //~^ ERROR the requirement `T: std::cmp::Ord` appears on the impl // invalid bound for T, was defined as Eq + Ord in trait fn test_error2_fn(&self) {} - //~^ ERROR the requirement `T : B` appears on the impl + //~^ ERROR the requirement `T: B` appears on the impl // invalid bound for T, was defined as Eq + Ord in trait fn test_error3_fn(&self) {} - //~^ ERROR the requirement `T : B` appears on the impl + //~^ ERROR the requirement `T: B` appears on the impl // multiple bounds, same order as in trait fn test3_fn(&self) {} @@ -52,16 +52,16 @@ impl Foo for isize { // parameters in impls must be equal or more general than in the defining trait fn test_error5_fn(&self) {} - //~^ ERROR the requirement `T : B` appears on the impl + //~^ ERROR the requirement `T: B` appears on the impl // bound `std::cmp::Eq` not enforced by this implementation, but this is OK fn test6_fn(&self) {} fn test_error7_fn(&self) {} - //~^ ERROR the requirement `T : std::cmp::Eq` appears on the impl + //~^ ERROR the requirement `T: std::cmp::Eq` appears on the impl fn test_error8_fn(&self) {} - //~^ ERROR the requirement `T : C` appears on the impl + //~^ ERROR the requirement `T: C` appears on the impl } trait Getter { diff --git a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs index 01910939a80e..8d587b29ba98 100644 --- a/src/test/compile-fail/trait-bounds-impl-comparison-2.rs +++ b/src/test/compile-fail/trait-bounds-impl-comparison-2.rs @@ -21,7 +21,7 @@ trait IteratorUtil: Sized impl> IteratorUtil for T { fn zip>(self, other: U) -> ZipIterator { - //~^ ERROR the requirement `U : Iterator` appears on the impl method + //~^ ERROR the requirement `U: Iterator` appears on the impl method ZipIterator{a: self, b: other} } } diff --git a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs index 0a771ecf63f1..fd46d1a62962 100644 --- a/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs +++ b/src/test/compile-fail/trait-bounds-not-on-bare-trait.rs @@ -15,7 +15,7 @@ trait Foo { // This should emit the less confusing error, not the more confusing one. fn foo(_x: Foo + Send) { - //~^ ERROR `Foo + Send + 'static : std::marker::Sized` is not satisfied + //~^ ERROR `Foo + Send + 'static: std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs index 8dd38544d3c9..24e2418e8d45 100644 --- a/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs +++ b/src/test/compile-fail/trait-bounds-on-structs-and-enums.rs @@ -21,7 +21,7 @@ enum Bar { } impl Foo { -//~^ ERROR `T : Trait` is not satisfied +//~^ ERROR `T: Trait` is not satisfied fn uhoh() {} } diff --git a/src/test/compile-fail/trait-coercion-generic-bad.rs b/src/test/compile-fail/trait-coercion-generic-bad.rs index 85c26368f9f2..dd64085f6f66 100644 --- a/src/test/compile-fail/trait-coercion-generic-bad.rs +++ b/src/test/compile-fail/trait-coercion-generic-bad.rs @@ -25,6 +25,6 @@ impl Trait<&'static str> for Struct { fn main() { // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let s: Box> = Box::new(Struct { person: "Fred" }); - //~^ ERROR `Struct : Trait` is not satisfied + //~^ ERROR `Struct: Trait` is not satisfied s.f(1); } diff --git a/src/test/compile-fail/trait-suggest-where-clause.rs b/src/test/compile-fail/trait-suggest-where-clause.rs index 8827cccd0f36..6950bce7304c 100644 --- a/src/test/compile-fail/trait-suggest-where-clause.rs +++ b/src/test/compile-fail/trait-suggest-where-clause.rs @@ -15,49 +15,49 @@ struct Misc(T); fn check() { // suggest a where-clause, if needed mem::size_of::(); - //~^ ERROR `U : std::marker::Sized` is not satisfied + //~^ ERROR `U: std::marker::Sized` is not satisfied //~| HELP E0277 - //~| HELP consider adding a `where U : std::marker::Sized` bound + //~| HELP consider adding a `where U: std::marker::Sized` bound //~| NOTE required by `std::mem::size_of` mem::size_of::>(); - //~^ ERROR `U : std::marker::Sized` is not satisfied + //~^ ERROR `U: std::marker::Sized` is not satisfied //~| HELP E0277 - //~| HELP consider adding a `where U : std::marker::Sized` bound + //~| HELP consider adding a `where U: std::marker::Sized` bound //~| NOTE required because it appears within the type `Misc` //~| NOTE required by `std::mem::size_of` // ... even if T occurs as a type parameter >::from; - //~^ ERROR `u64 : std::convert::From` is not satisfied + //~^ ERROR `u64: std::convert::From` is not satisfied //~| HELP E0277 - //~| HELP consider adding a `where u64 : std::convert::From` bound + //~| HELP consider adding a `where u64: std::convert::From` bound //~| NOTE required by `std::convert::From::from` ::Item>>::from; - //~^ ERROR `u64 : std::convert::From<::Item>` is not satisfied + //~^ ERROR `u64: std::convert::From<::Item>` is not satisfied //~| HELP E0277 - //~| HELP consider adding a `where u64 : + //~| HELP consider adding a `where u64: //~| NOTE required by `std::convert::From::from` // ... but not if there are inference variables as From>::from; - //~^ ERROR `Misc<_> : std::convert::From` is not satisfied + //~^ ERROR `Misc<_>: std::convert::From` is not satisfied //~| HELP E0277 //~| NOTE required by `std::convert::From::from` // ... and also not if the error is not related to the type mem::size_of::<[T]>(); - //~^ ERROR `[T] : std::marker::Sized` is not satisfied + //~^ ERROR `[T]: std::marker::Sized` is not satisfied //~| HELP E0277 //~| NOTE `[T]` does not have a constant size //~| NOTE required by `std::mem::size_of` mem::size_of::<[&U]>(); - //~^ ERROR `[&U] : std::marker::Sized` is not satisfied + //~^ ERROR `[&U]: std::marker::Sized` is not satisfied //~| HELP E0277 //~| NOTE `[&U]` does not have a constant size //~| NOTE required by `std::mem::size_of` diff --git a/src/test/compile-fail/traits-negative-impls.rs b/src/test/compile-fail/traits-negative-impls.rs index 4a266dd07e6b..8014f92e1734 100644 --- a/src/test/compile-fail/traits-negative-impls.rs +++ b/src/test/compile-fail/traits-negative-impls.rs @@ -31,8 +31,8 @@ fn dummy() { impl !Send for TestType {} Outer(TestType); - //~^ ERROR `dummy::TestType : std::marker::Send` is not satisfied - //~| ERROR `dummy::TestType : std::marker::Send` is not satisfied + //~^ ERROR `dummy::TestType: std::marker::Send` is not satisfied + //~| ERROR `dummy::TestType: std::marker::Send` is not satisfied } fn dummy1b() { @@ -40,7 +40,7 @@ fn dummy1b() { impl !Send for TestType {} is_send(TestType); - //~^ ERROR `dummy1b::TestType : std::marker::Send` is not satisfied + //~^ ERROR `dummy1b::TestType: std::marker::Send` is not satisfied } fn dummy1c() { @@ -48,7 +48,7 @@ fn dummy1c() { impl !Send for TestType {} is_send((8, TestType)); - //~^ ERROR `dummy1c::TestType : std::marker::Send` is not satisfied + //~^ ERROR `dummy1c::TestType: std::marker::Send` is not satisfied } fn dummy2() { @@ -56,7 +56,7 @@ fn dummy2() { impl !Send for TestType {} is_send(Box::new(TestType)); - //~^ ERROR `dummy2::TestType : std::marker::Send` is not satisfied + //~^ ERROR `dummy2::TestType: std::marker::Send` is not satisfied } fn dummy3() { @@ -64,7 +64,7 @@ fn dummy3() { impl !Send for TestType {} is_send(Box::new(Outer2(TestType))); - //~^ ERROR `dummy3::TestType : std::marker::Send` is not satisfied + //~^ ERROR `dummy3::TestType: std::marker::Send` is not satisfied } fn main() { @@ -74,5 +74,5 @@ fn main() { // This will complain about a missing Send impl because `Sync` is implement *just* // for T that are `Send`. Look at #20366 and #19950 is_sync(Outer2(TestType)); - //~^ ERROR `main::TestType : std::marker::Send` is not satisfied + //~^ ERROR `main::TestType: std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/traits-repeated-supertrait-ambig.rs b/src/test/compile-fail/traits-repeated-supertrait-ambig.rs index 244f75a35926..3fc0d638dd6f 100644 --- a/src/test/compile-fail/traits-repeated-supertrait-ambig.rs +++ b/src/test/compile-fail/traits-repeated-supertrait-ambig.rs @@ -33,21 +33,21 @@ impl CompareTo for i64 { impl CompareToInts for i64 { } fn with_obj(c: &CompareToInts) -> bool { - c.same_as(22) //~ ERROR `CompareToInts : CompareTo` is not satisfied + c.same_as(22) //~ ERROR `CompareToInts: CompareTo` is not satisfied } fn with_trait(c: &C) -> bool { - c.same_as(22) //~ ERROR `C : CompareTo` is not satisfied + c.same_as(22) //~ ERROR `C: CompareTo` is not satisfied } fn with_ufcs1(c: &C) -> bool { - CompareToInts::same_as(c, 22) //~ ERROR `CompareToInts : CompareTo` is not satisfied + CompareToInts::same_as(c, 22) //~ ERROR `CompareToInts: CompareTo` is not satisfied } fn with_ufcs2(c: &C) -> bool { - CompareTo::same_as(c, 22) //~ ERROR `C : CompareTo` is not satisfied + CompareTo::same_as(c, 22) //~ ERROR `C: CompareTo` is not satisfied } fn main() { - assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64 : CompareTo` is not satisfied + assert_eq!(22_i64.same_as(22), true); //~ ERROR `i64: CompareTo` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs b/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs index 93800d3907a6..8a46d6c76c30 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs @@ -26,5 +26,5 @@ fn main() { is_mytrait::(); is_mytrait::<(MyS2, MyS)>(); - //~^ ERROR `MyS2 : MyTrait` is not satisfied + //~^ ERROR `MyS2: MyTrait` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs b/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs index a49047524e66..3d7746b369cc 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs @@ -29,5 +29,5 @@ fn main() { is_mytrait::(); is_mytrait::(); - //~^ ERROR `MyS2 : MyTrait` is not satisfied + //~^ ERROR `MyS2: MyTrait` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs b/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs index 0158cbcfcda8..853718f1e77d 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-negation-send.rs @@ -27,5 +27,5 @@ fn is_send() {} fn main() { is_send::(); is_send::(); - //~^ ERROR `MyNotSendable : std::marker::Send` is not satisfied + //~^ ERROR `MyNotSendable: std::marker::Send` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs b/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs index 6cfc9bc5f5ec..cdf787a60ad4 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-negation-sync.rs @@ -43,11 +43,11 @@ fn is_sync() {} fn main() { is_sync::(); is_sync::(); - //~^ ERROR `MyNotSync : std::marker::Sync` is not satisfied + //~^ ERROR `MyNotSync: std::marker::Sync` is not satisfied is_sync::(); - //~^ ERROR `std::cell::UnsafeCell : std::marker::Sync` is not satisfied + //~^ ERROR `std::cell::UnsafeCell: std::marker::Sync` is not satisfied is_sync::(); - //~^ ERROR `Managed : std::marker::Sync` is not satisfied + //~^ ERROR `Managed: std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-negation.rs b/src/test/compile-fail/typeck-default-trait-impl-negation.rs index 98e617ee6659..8c2658b89a50 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-negation.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-negation.rs @@ -33,10 +33,10 @@ fn is_my_unsafe_trait() {} fn main() { is_my_trait::(); is_my_trait::(); - //~^ ERROR `ThisImplsUnsafeTrait : MyTrait` is not satisfied + //~^ ERROR `ThisImplsUnsafeTrait: MyTrait` is not satisfied is_my_unsafe_trait::(); - //~^ ERROR `ThisImplsTrait : MyUnsafeTrait` is not satisfied + //~^ ERROR `ThisImplsTrait: MyUnsafeTrait` is not satisfied is_my_unsafe_trait::(); } diff --git a/src/test/compile-fail/typeck-default-trait-impl-precedence.rs b/src/test/compile-fail/typeck-default-trait-impl-precedence.rs index 109b2ed24ea1..66c7a1c75ffe 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-precedence.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-precedence.rs @@ -27,5 +27,5 @@ impl Signed for i32 { } fn main() { is_defaulted::<&'static i32>(); is_defaulted::<&'static u32>(); - //~^ ERROR `u32 : Signed` is not satisfied + //~^ ERROR `u32: Signed` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs b/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs index 81c4a3c5a519..0b071a9acd09 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-supertrait.rs @@ -24,6 +24,6 @@ fn foo() { bar::() } fn bar() { } fn main() { - foo::(); //~ ERROR `i32 : NotImplemented` is not satisfied - bar::(); //~ ERROR `i64 : NotImplemented` is not satisfied + foo::(); //~ ERROR `i32: NotImplemented` is not satisfied + bar::(); //~ ERROR `i64: NotImplemented` is not satisfied } diff --git a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs index 29379d549611..3085f45a83dd 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause-2.rs @@ -29,7 +29,7 @@ fn bar() { } fn test() { bar::>(); - //~^ ERROR `std::option::Option : NotImplemented` is not satisfied + //~^ ERROR `std::option::Option: NotImplemented` is not satisfied } fn main() { diff --git a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs index a3a80e17e403..47e87c09d12b 100644 --- a/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs +++ b/src/test/compile-fail/typeck-default-trait-impl-trait-where-clause.rs @@ -26,7 +26,7 @@ impl NotImplemented for i32 {} impl MyTrait for .. {} fn foo() { - //~^ ERROR `std::option::Option : NotImplemented` is not satisfied + //~^ ERROR `std::option::Option: NotImplemented` is not satisfied // This should probably typecheck. This is #20671. } diff --git a/src/test/compile-fail/typeck-unsafe-always-share.rs b/src/test/compile-fail/typeck-unsafe-always-share.rs index f34bae3be3ca..6047f6770a7b 100644 --- a/src/test/compile-fail/typeck-unsafe-always-share.rs +++ b/src/test/compile-fail/typeck-unsafe-always-share.rs @@ -27,16 +27,16 @@ fn test(s: T) {} fn main() { let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0)}); test(us); - //~^ ERROR `std::cell::UnsafeCell> : std::marker::Sync` is not satisfied + //~^ ERROR `std::cell::UnsafeCell>: std::marker::Sync` is not satisfied let uns = UnsafeCell::new(NoSync); test(uns); - //~^ ERROR `std::cell::UnsafeCell : std::marker::Sync` is not satisfied + //~^ ERROR `std::cell::UnsafeCell: std::marker::Sync` is not satisfied let ms = MySync{u: uns}; test(ms); - //~^ ERROR `std::cell::UnsafeCell : std::marker::Sync` is not satisfied + //~^ ERROR `std::cell::UnsafeCell: std::marker::Sync` is not satisfied test(NoSync); - //~^ ERROR `NoSync : std::marker::Sync` is not satisfied + //~^ ERROR `NoSync: std::marker::Sync` is not satisfied } diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs index 792c4a8ca3c7..94a98b1582af 100644 --- a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs +++ b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs @@ -12,7 +12,7 @@ use std::ops::Add; fn main() { >::add(1, 2); - //~^ ERROR `i32 : std::ops::Add` is not satisfied + //~^ ERROR `i32: std::ops::Add` is not satisfied >::add(1u32, 2); //~^ ERROR mismatched types >::add(1, 2u32); diff --git a/src/test/compile-fail/unsized-bare-typaram.rs b/src/test/compile-fail/unsized-bare-typaram.rs index 49642ac1490c..3dcc7d248d72 100644 --- a/src/test/compile-fail/unsized-bare-typaram.rs +++ b/src/test/compile-fail/unsized-bare-typaram.rs @@ -9,5 +9,5 @@ // except according to those terms. fn bar() { } -fn foo() { bar::() } //~ ERROR `T : std::marker::Sized` is not satisfied +fn foo() { bar::() } //~ ERROR `T: std::marker::Sized` is not satisfied fn main() { } diff --git a/src/test/compile-fail/unsized-enum.rs b/src/test/compile-fail/unsized-enum.rs index bd5b705511d4..61b2b01b3558 100644 --- a/src/test/compile-fail/unsized-enum.rs +++ b/src/test/compile-fail/unsized-enum.rs @@ -15,14 +15,14 @@ fn not_sized() { } enum Foo { FooSome(U), FooNone } fn foo1() { not_sized::>() } // Hunky dory. fn foo2() { not_sized::>() } -//~^ ERROR `T : std::marker::Sized` is not satisfied +//~^ ERROR `T: std::marker::Sized` is not satisfied // // Not OK: `T` is not sized. enum Bar { BarSome(U), BarNone } fn bar1() { not_sized::>() } fn bar2() { is_sized::>() } -//~^ ERROR `T : std::marker::Sized` is not satisfied +//~^ ERROR `T: std::marker::Sized` is not satisfied // // Not OK: `Bar` is not sized, but it should be. diff --git a/src/test/compile-fail/unsized-struct.rs b/src/test/compile-fail/unsized-struct.rs index 94f15033cb70..bbefb2fcecd8 100644 --- a/src/test/compile-fail/unsized-struct.rs +++ b/src/test/compile-fail/unsized-struct.rs @@ -15,14 +15,14 @@ fn not_sized() { } struct Foo { data: T } fn foo1() { not_sized::>() } // Hunky dory. fn foo2() { not_sized::>() } -//~^ ERROR `T : std::marker::Sized` is not satisfied +//~^ ERROR `T: std::marker::Sized` is not satisfied // // Not OK: `T` is not sized. struct Bar { data: T } fn bar1() { not_sized::>() } fn bar2() { is_sized::>() } -//~^ ERROR `T : std::marker::Sized` is not satisfied +//~^ ERROR `T: std::marker::Sized` is not satisfied // // Not OK: `Bar` is not sized, but it should be. diff --git a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs index bd420d940d51..ad5e4c2daef9 100644 --- a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs +++ b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs @@ -16,7 +16,7 @@ trait T2 { } struct S4(Box); impl T2 for S4 { - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index 061f0695df7d..f88165c02e98 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -15,7 +15,7 @@ use std::marker; // Unbounded. fn f1(x: &X) { f2::(x); - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied } fn f2(x: &X) { } @@ -26,7 +26,7 @@ trait T { } fn f3(x: &X) { f4::(x); - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied } fn f4(x: &X) { } @@ -40,7 +40,7 @@ fn f5(x: &Y) {} fn f6(x: &X) {} fn f7(x1: &E, x2: &E) { f5(x1); - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied f6(x2); // ok } @@ -52,19 +52,19 @@ struct S { fn f8(x1: &S, x2: &S) { f5(x1); - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied f6(x2); // ok } // Test some tuples. fn f9(x1: Box>, x2: Box>) { f5(&(*x1, 34)); - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied } fn f10(x1: Box>, x2: Box>) { f5(&(32, *x2)); - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied } pub fn main() { diff --git a/src/test/compile-fail/unsized5.rs b/src/test/compile-fail/unsized5.rs index 1abc45d5df81..3e6c9cc4061e 100644 --- a/src/test/compile-fail/unsized5.rs +++ b/src/test/compile-fail/unsized5.rs @@ -11,27 +11,27 @@ // Test `?Sized` types not allowed in fields (except the last one). struct S1 { - f1: X, //~ ERROR `X : std::marker::Sized` is not satisfied + f1: X, //~ ERROR `X: std::marker::Sized` is not satisfied f2: isize, } struct S2 { f: isize, - g: X, //~ ERROR `X : std::marker::Sized` is not satisfied + g: X, //~ ERROR `X: std::marker::Sized` is not satisfied h: isize, } struct S3 { - f: str, //~ ERROR `str : std::marker::Sized` is not satisfied + f: str, //~ ERROR `str: std::marker::Sized` is not satisfied g: [usize] } struct S4 { - f: [u8], //~ ERROR `[u8] : std::marker::Sized` is not satisfied + f: [u8], //~ ERROR `[u8]: std::marker::Sized` is not satisfied g: usize } enum E { - V1(X, isize), //~ERROR `X : std::marker::Sized` is not satisfied + V1(X, isize), //~ERROR `X: std::marker::Sized` is not satisfied } enum F { - V2{f1: X, f: isize}, //~ERROR `X : std::marker::Sized` is not satisfied + V2{f1: X, f: isize}, //~ERROR `X: std::marker::Sized` is not satisfied } pub fn main() { diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index 7545794bd23e..663cb0a17161 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -15,27 +15,27 @@ trait T {} fn f1(x: &X) { let _: X; // <-- this is OK, no bindings created, no initializer. let _: (isize, (X, isize)); // same - let y: X; //~ERROR `X : std::marker::Sized` is not satisfied - let y: (isize, (X, isize)); //~ERROR `X : std::marker::Sized` is not satisfied + let y: X; //~ERROR `X: std::marker::Sized` is not satisfied + let y: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfied } fn f2(x: &X) { - let y: X; //~ERROR `X : std::marker::Sized` is not satisfied - let y: (isize, (X, isize)); //~ERROR `X : std::marker::Sized` is not satisfied + let y: X; //~ERROR `X: std::marker::Sized` is not satisfied + let y: (isize, (X, isize)); //~ERROR `X: std::marker::Sized` is not satisfied } fn f3(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; //~ERROR `X : std::marker::Sized` is not satisfied - let y = *x2; //~ERROR `X : std::marker::Sized` is not satisfied - let (y, z) = (*x3, 4); //~ERROR `X : std::marker::Sized` is not satisfied + let y: X = *x1; //~ERROR `X: std::marker::Sized` is not satisfied + let y = *x2; //~ERROR `X: std::marker::Sized` is not satisfied + let (y, z) = (*x3, 4); //~ERROR `X: std::marker::Sized` is not satisfied } fn f4(x1: Box, x2: Box, x3: Box) { - let y: X = *x1; //~ERROR `X : std::marker::Sized` is not satisfied - let y = *x2; //~ERROR `X : std::marker::Sized` is not satisfied - let (y, z) = (*x3, 4); //~ERROR `X : std::marker::Sized` is not satisfied + let y: X = *x1; //~ERROR `X: std::marker::Sized` is not satisfied + let y = *x2; //~ERROR `X: std::marker::Sized` is not satisfied + let (y, z) = (*x3, 4); //~ERROR `X: std::marker::Sized` is not satisfied } -fn g1(x: X) {} //~ERROR `X : std::marker::Sized` is not satisfied -fn g2(x: X) {} //~ERROR `X : std::marker::Sized` is not satisfied +fn g1(x: X) {} //~ERROR `X: std::marker::Sized` is not satisfied +fn g2(x: X) {} //~ERROR `X: std::marker::Sized` is not satisfied pub fn main() { } diff --git a/src/test/compile-fail/unsized7.rs b/src/test/compile-fail/unsized7.rs index 5aa1f1336796..25868c594feb 100644 --- a/src/test/compile-fail/unsized7.rs +++ b/src/test/compile-fail/unsized7.rs @@ -20,7 +20,7 @@ trait T1 { struct S3(Box); impl T1 for S3 { - //~^ ERROR `X : std::marker::Sized` is not satisfied + //~^ ERROR `X: std::marker::Sized` is not satisfied } fn main() { } diff --git a/src/test/compile-fail/vtable-res-trait-param.rs b/src/test/compile-fail/vtable-res-trait-param.rs index e32cb32a74d6..eb0baff0005d 100644 --- a/src/test/compile-fail/vtable-res-trait-param.rs +++ b/src/test/compile-fail/vtable-res-trait-param.rs @@ -24,7 +24,7 @@ impl TraitB for isize { fn call_it(b: B) -> isize { let y = 4; - b.gimme_an_a(y) //~ ERROR `_ : TraitA` is not satisfied + b.gimme_an_a(y) //~ ERROR `_: TraitA` is not satisfied } fn main() { diff --git a/src/test/compile-fail/wf-impl-associated-type-trait.rs b/src/test/compile-fail/wf-impl-associated-type-trait.rs index 2fee2604a8a8..1e82f609d2a7 100644 --- a/src/test/compile-fail/wf-impl-associated-type-trait.rs +++ b/src/test/compile-fail/wf-impl-associated-type-trait.rs @@ -25,7 +25,7 @@ pub trait Foo { impl Foo for T { type Bar = MySet; - //~^ ERROR the trait bound `T : MyHash` is not satisfied + //~^ ERROR the trait bound `T: MyHash` is not satisfied } #[rustc_error] diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs index 4b85f2275a75..458ee6694247 100644 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs +++ b/src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs @@ -21,7 +21,7 @@ impl Foo { fn fails_copy(self) { require_copy(self.x); - //~^ ERROR the trait bound `T : std::marker::Copy` is not satisfied + //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied } } diff --git a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs b/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs index f55586982bee..b3f99f2ae253 100644 --- a/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs +++ b/src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs @@ -26,7 +26,7 @@ impl Foo for Bar { fn fails_copy(self) { require_copy(self.x); - //~^ ERROR the trait bound `T : std::marker::Copy` is not satisfied + //~^ ERROR the trait bound `T: std::marker::Copy` is not satisfied } } diff --git a/src/test/compile-fail/where-clause-method-substituion.rs b/src/test/compile-fail/where-clause-method-substituion.rs index 9f217f29bd18..05a58daf9068 100644 --- a/src/test/compile-fail/where-clause-method-substituion.rs +++ b/src/test/compile-fail/where-clause-method-substituion.rs @@ -28,5 +28,5 @@ impl Bar for isize { fn main() { 1.method::(); - //~^ ERROR the trait bound `X : Foo` is not satisfied + //~^ ERROR the trait bound `X: Foo` is not satisfied } diff --git a/src/test/compile-fail/where-clauses-method-unsatisfied.rs b/src/test/compile-fail/where-clauses-method-unsatisfied.rs index 34ff872ac15f..1ac03330afd1 100644 --- a/src/test/compile-fail/where-clauses-method-unsatisfied.rs +++ b/src/test/compile-fail/where-clauses-method-unsatisfied.rs @@ -26,5 +26,5 @@ impl Foo { fn main() { let x = Foo { value: Bar }; x.equals(&x); - //~^ ERROR `Bar : std::cmp::Eq` is not satisfied + //~^ ERROR `Bar: std::cmp::Eq` is not satisfied } diff --git a/src/test/compile-fail/where-clauses-unsatisfied.rs b/src/test/compile-fail/where-clauses-unsatisfied.rs index 38470bc3de67..278a8db4e1ad 100644 --- a/src/test/compile-fail/where-clauses-unsatisfied.rs +++ b/src/test/compile-fail/where-clauses-unsatisfied.rs @@ -15,5 +15,5 @@ struct Struct; fn main() { drop(equal(&Struct, &Struct)) - //~^ ERROR the trait bound `Struct : std::cmp::Eq` is not satisfied + //~^ ERROR the trait bound `Struct: std::cmp::Eq` is not satisfied } diff --git a/src/test/compile-fail/where-for-self-2.rs b/src/test/compile-fail/where-for-self-2.rs index 1baaed3dd378..bf8fc2921733 100644 --- a/src/test/compile-fail/where-for-self-2.rs +++ b/src/test/compile-fail/where-for-self-2.rs @@ -29,5 +29,5 @@ fn foo(x: &T) fn main() { foo(&X); - //~^ error: `for<'a> &'a _ : Bar` is not satisfied + //~^ error: `for<'a> &'a _: Bar` is not satisfied } From 832b7075b6c2e4ed37978d00a7c629e468f3dab1 Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Tue, 5 Apr 2016 23:19:29 +0300 Subject: [PATCH 15/20] clean the note-reporting code in report_selection_error --- src/librustc/traits/error_reporting.rs | 101 +++++++++++++++---------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index dfe3f91c7b15..5b5bea012ead 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -174,6 +174,53 @@ fn on_unimplemented_note<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, report } +fn find_similar_impl_candidates<'a, 'tcx>( + infcx: &InferCtxt<'a, 'tcx>, + trait_ref: ty::PolyTraitRef<'tcx>) + -> Vec> +{ + let simp = fast_reject::simplify_type(infcx.tcx, + trait_ref.skip_binder().self_ty(), + true); + let mut impl_candidates = Vec::new(); + let trait_def = infcx.tcx.lookup_trait_def(trait_ref.def_id()); + + match simp { + Some(simp) => trait_def.for_each_impl(infcx.tcx, |def_id| { + let imp = infcx.tcx.impl_trait_ref(def_id).unwrap(); + let imp_simp = fast_reject::simplify_type(infcx.tcx, + imp.self_ty(), + true); + if let Some(imp_simp) = imp_simp { + if simp != imp_simp { + return; + } + } + impl_candidates.push(imp); + }), + None => trait_def.for_each_impl(infcx.tcx, |def_id| { + impl_candidates.push( + infcx.tcx.impl_trait_ref(def_id).unwrap()); + }) + }; + impl_candidates +} + +fn report_similar_impl_candidates(span: Span, + err: &mut DiagnosticBuilder, + impl_candidates: &[ty::TraitRef]) +{ + err.fileline_help(span, &format!("the following implementations were found:")); + + let end = cmp::min(4, impl_candidates.len()); + for candidate in &impl_candidates[0..end] { + err.fileline_help(span, &format!(" {:?}", candidate)); + } + if impl_candidates.len() > 4 { + err.fileline_help(span, &format!("and {} others", impl_candidates.len()-4)); + } +} + /// Reports that an overflow has occurred and halts compilation. We /// halt compilation unconditionally because it is important that /// overflows never be masked -- they basically represent computations @@ -364,59 +411,35 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, "the trait bound `{}` is not satisfied", trait_ref.to_predicate()); - // Try to report a good error message. + // Try to report a help message if !trait_ref.has_infer_types() && predicate_can_apply(infcx, trait_ref) { + // If a where-clause may be useful, remind the + // user that they can add it. + // + // don't display an on-unimplemented note, as + // these notes will often be of the form + // "the type `T` can't be frobnicated" + // which is somewhat confusing. err.fileline_help(obligation.cause.span, &format!( "consider adding a `where {}` bound", trait_ref.to_predicate() )); } else if let Some(s) = on_unimplemented_note(infcx, trait_ref, obligation.cause.span) { + // Otherwise, if there is an on-unimplemented note, + // display it. err.fileline_note(obligation.cause.span, &s); } else { - let simp = fast_reject::simplify_type(infcx.tcx, - trait_ref.self_ty(), - true); - let mut impl_candidates = Vec::new(); - let trait_def = infcx.tcx.lookup_trait_def(trait_ref.def_id()); - - match simp { - Some(simp) => trait_def.for_each_impl(infcx.tcx, |def_id| { - let imp = infcx.tcx.impl_trait_ref(def_id).unwrap(); - let imp_simp = fast_reject::simplify_type(infcx.tcx, - imp.self_ty(), - true); - if let Some(imp_simp) = imp_simp { - if simp != imp_simp { - return; - } - } - impl_candidates.push(imp); - }), - None => trait_def.for_each_impl(infcx.tcx, |def_id| { - impl_candidates.push( - infcx.tcx.impl_trait_ref(def_id).unwrap()); - }) - }; + // If we can't show anything useful, try to find + // similar impls. + let impl_candidates = find_similar_impl_candidates(infcx, trait_ref); if impl_candidates.len() > 0 { - err.fileline_help( - obligation.cause.span, - &format!("the following implementations were found:")); - - let end = cmp::min(4, impl_candidates.len()); - for candidate in &impl_candidates[0..end] { - err.fileline_help(obligation.cause.span, - &format!(" {:?}", candidate)); - } - if impl_candidates.len() > 4 { - err.fileline_help(obligation.cause.span, - &format!("and {} others", - impl_candidates.len()-4)); - } + report_similar_impl_candidates(obligation.cause.span, + &mut err, &impl_candidates); } } note_obligation_cause(infcx, &mut err, obligation); From 4883824dc575eb2068d8b1208bc02ee02d16ec7f Mon Sep 17 00:00:00 2001 From: JP Sugarbroad Date: Tue, 5 Apr 2016 17:06:10 -0700 Subject: [PATCH 16/20] Fix typos in atomic compare_exchange. --- src/libcore/sync/atomic.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index d2e98a795d93..483c3822df6c 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -327,7 +327,7 @@ impl AtomicBool { /// `compare_exchange` takes two `Ordering` arguments to describe the memory ordering of this /// operation. The first describes the required ordering if the operation succeeds while the /// second describes the required ordering when the operation fails. The failure ordering can't - /// be `Acquire` or `AcqRel` and must be equivalent or weaker than the success ordering. + /// be `Release` or `AcqRel` and must be equivalent or weaker than the success ordering. /// /// # Examples /// @@ -376,7 +376,7 @@ impl AtomicBool { /// `compare_exchange_weak` takes two `Ordering` arguments to describe the memory /// ordering of this operation. The first describes the required ordering if the operation /// succeeds while the second describes the required ordering when the operation fails. The - /// failure ordering can't be `Acquire` or `AcqRel` and must be equivalent or weaker than the + /// failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than the /// success ordering. /// /// # Examples @@ -663,7 +663,7 @@ impl AtomicIsize { /// `compare_exchange` takes two `Ordering` arguments to describe the memory ordering of this /// operation. The first describes the required ordering if the operation succeeds while the /// second describes the required ordering when the operation fails. The failure ordering can't - /// be `Acquire` or `AcqRel` and must be equivalent or weaker than the success ordering. + /// be `Release` or `AcqRel` and must be equivalent or weaker than the success ordering. /// /// # Examples /// @@ -705,7 +705,7 @@ impl AtomicIsize { /// `compare_exchange_weak` takes two `Ordering` arguments to describe the memory /// ordering of this operation. The first describes the required ordering if the operation /// succeeds while the second describes the required ordering when the operation fails. The - /// failure ordering can't be `Acquire` or `AcqRel` and must be equivalent or weaker than the + /// failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than the /// success ordering. /// /// # Examples @@ -939,7 +939,7 @@ impl AtomicUsize { /// `compare_exchange` takes two `Ordering` arguments to describe the memory ordering of this /// operation. The first describes the required ordering if the operation succeeds while the /// second describes the required ordering when the operation fails. The failure ordering can't - /// be `Acquire` or `AcqRel` and must be equivalent or weaker than the success ordering. + /// be `Release` or `AcqRel` and must be equivalent or weaker than the success ordering. /// /// # Examples /// @@ -981,7 +981,7 @@ impl AtomicUsize { /// `compare_exchange_weak` takes two `Ordering` arguments to describe the memory /// ordering of this operation. The first describes the required ordering if the operation /// succeeds while the second describes the required ordering when the operation fails. The - /// failure ordering can't be `Acquire` or `AcqRel` and must be equivalent or weaker than the + /// failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than the /// success ordering. /// /// # Examples @@ -1223,7 +1223,7 @@ impl AtomicPtr { /// `compare_exchange` takes two `Ordering` arguments to describe the memory ordering of this /// operation. The first describes the required ordering if the operation succeeds while the /// second describes the required ordering when the operation fails. The failure ordering can't - /// be `Acquire` or `AcqRel` and must be equivalent or weaker than the success ordering. + /// be `Release` or `AcqRel` and must be equivalent or weaker than the success ordering. /// /// # Examples /// @@ -1270,7 +1270,7 @@ impl AtomicPtr { /// `compare_exchange_weak` takes two `Ordering` arguments to describe the memory /// ordering of this operation. The first describes the required ordering if the operation /// succeeds while the second describes the required ordering when the operation fails. The - /// failure ordering can't be `Acquire` or `AcqRel` and must be equivalent or weaker than the + /// failure ordering can't be `Release` or `AcqRel` and must be equivalent or weaker than the /// success ordering. /// /// # Examples @@ -1396,8 +1396,8 @@ unsafe fn atomic_compare_exchange(dst: *mut T, (AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_failrelaxed(dst, old, new), (SeqCst, Relaxed) => intrinsics::atomic_cxchg_failrelaxed(dst, old, new), (SeqCst, Acquire) => intrinsics::atomic_cxchg_failacq(dst, old, new), - (_, Release) => panic!("there is no such thing as an acquire/release failure ordering"), - (_, AcqRel) => panic!("there is no such thing as a release failure ordering"), + (_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"), + (_, Release) => panic!("there is no such thing as a release failure ordering"), _ => panic!("a failure ordering can't be stronger than a success ordering"), }; if ok { @@ -1446,8 +1446,8 @@ unsafe fn atomic_compare_exchange_weak(dst: *mut T, (AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_failrelaxed(dst, old, new), (SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_failrelaxed(dst, old, new), (SeqCst, Acquire) => intrinsics::atomic_cxchgweak_failacq(dst, old, new), - (_, Release) => panic!("there is no such thing as an acquire/release failure ordering"), - (_, AcqRel) => panic!("there is no such thing as a release failure ordering"), + (_, AcqRel) => panic!("there is no such thing as an acquire/release failure ordering"), + (_, Release) => panic!("there is no such thing as a release failure ordering"), _ => panic!("a failure ordering can't be stronger than a success ordering"), }; if ok { From 73790f02e3a9c021cc5dd65ac7c017a9f6ae889f Mon Sep 17 00:00:00 2001 From: James Miller Date: Wed, 6 Apr 2016 17:57:42 +1200 Subject: [PATCH 17/20] Move ReturnDest creation into a method It's quite a large amount of code, and moving it into a method allowed for some refactoring to make the logic a little easier to understand --- src/librustc_trans/mir/block.rs | 122 +++++++++++++++---------------- src/librustc_trans/mir/lvalue.rs | 4 +- 2 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index b8417f985650..7234bff43972 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -211,70 +211,13 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { let mut llargs = Vec::with_capacity(arg_count); // Prepare the return value destination - let ret_dest = if let Some((ref d, _)) = *destination { - match *d { - // Handle temporary lvalues, specifically Operand ones, as - // they don't have allocas - mir::Lvalue::Temp(idx) => { - let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), d); - let ret_ty = lvalue_ty.to_ty(bcx.tcx()); - match self.temps[idx as usize] { - TempRef::Lvalue(dest) => { - if fn_ty.ret.is_indirect() { - llargs.push(dest.llval); - ReturnDest::Nothing - } else if fn_ty.ret.is_ignore() { - ReturnDest::Nothing - } else { - ReturnDest::Store(dest.llval) - } - } - TempRef::Operand(None) => { - let is_intrinsic = if let Intrinsic = callee.data { - true - } else { - false - }; - - if fn_ty.ret.is_indirect() { - // Odd, but possible, case, we have an operand temporary, - // but the calling convention has an indirect return. - let tmp = bcx.with_block(|bcx| { - base::alloc_ty(bcx, ret_ty, "tmp_ret") - }); - llargs.push(tmp); - ReturnDest::IndirectOperand(tmp, idx) - } else if is_intrinsic { - // Currently, intrinsics always need a location to store - // the result. so we create a temporary alloca for the - // result - let tmp = bcx.with_block(|bcx| { - base::alloc_ty(bcx, ret_ty, "tmp_ret") - }); - ReturnDest::IndirectOperand(tmp, idx) - } else if fn_ty.ret.is_ignore() { - ReturnDest::Nothing - } else { - ReturnDest::DirectOperand(idx) - } - } - TempRef::Operand(Some(_)) => { - bug!("lvalue temp already assigned to"); - } - } - } - _ => { - let dest = self.trans_lvalue(&bcx, d); - if fn_ty.ret.is_indirect() { - llargs.push(dest.llval); - ReturnDest::Nothing - } else if fn_ty.ret.is_ignore() { - ReturnDest::Nothing - } else { - ReturnDest::Store(dest.llval) - } - } - } + let ret_dest = if let Some((ref dest, _)) = *destination { + let is_intrinsic = if let Intrinsic = callee.data { + true + } else { + false + }; + self.make_return_dest(&bcx, dest, &fn_ty.ret, &mut llargs, is_intrinsic) } else { ReturnDest::Nothing }; @@ -601,6 +544,57 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { self.blocks[bb.index()].llbb } + fn make_return_dest(&mut self, bcx: &BlockAndBuilder<'bcx, 'tcx>, + dest: &mir::Lvalue<'tcx>, fn_ret_ty: &ArgType, + llargs: &mut Vec, is_intrinsic: bool) -> ReturnDest { + // If the return is ignored, we can just return a do-nothing ReturnDest + if fn_ret_ty.is_ignore() { + return ReturnDest::Nothing; + } + let dest = match *dest { + mir::Lvalue::Temp(idx) => { + let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), dest); + let ret_ty = lvalue_ty.to_ty(bcx.tcx()); + match self.temps[idx as usize] { + TempRef::Lvalue(dest) => dest, + TempRef::Operand(None) => { + // Handle temporary lvalues, specifically Operand ones, as + // they don't have allocas + return if fn_ret_ty.is_indirect() { + // Odd, but possible, case, we have an operand temporary, + // but the calling convention has an indirect return. + let tmp = bcx.with_block(|bcx| { + base::alloc_ty(bcx, ret_ty, "tmp_ret") + }); + llargs.push(tmp); + ReturnDest::IndirectOperand(tmp, idx) + } else if is_intrinsic { + // Currently, intrinsics always need a location to store + // the result. so we create a temporary alloca for the + // result + let tmp = bcx.with_block(|bcx| { + base::alloc_ty(bcx, ret_ty, "tmp_ret") + }); + ReturnDest::IndirectOperand(tmp, idx) + } else { + ReturnDest::DirectOperand(idx) + }; + } + TempRef::Operand(Some(_)) => { + bug!("lvalue temp already assigned to"); + } + } + } + _ => self.trans_lvalue(bcx, dest) + }; + if fn_ret_ty.is_indirect() { + llargs.push(dest.llval); + ReturnDest::Nothing + } else { + ReturnDest::Store(dest.llval) + } + } + fn trans_transmute(&mut self, bcx: &BlockAndBuilder<'bcx, 'tcx>, src: &mir::Operand<'tcx>, dst: LvalueRef<'tcx>) { let mut val = self.trans_operand(bcx, src); diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs index 5a0992a6b6b4..13e1894df16a 100644 --- a/src/librustc_trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -220,7 +220,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { TempRef::Lvalue(lvalue) => f(self, lvalue), TempRef::Operand(None) => { let lvalue_ty = self.mir.lvalue_ty(bcx.tcx(), lvalue); - let lvalue = LvalueRef::alloca(bcx, lvalue_ty.to_ty(bcx.tcx()), "lvalue_temp"); + let lvalue = LvalueRef::alloca(bcx, + lvalue_ty.to_ty(bcx.tcx()), + "lvalue_temp"); let ret = f(self, lvalue); let op = self.trans_load(bcx, lvalue.llval, lvalue_ty.to_ty(bcx.tcx())); self.temps[idx as usize] = TempRef::Operand(Some(op)); From a6c27be0b1074684ae918ab7132bbeb8f75d4f2a Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Wed, 6 Apr 2016 12:19:19 +0200 Subject: [PATCH 18/20] slice: Use doc(hidden) on private traits This should avoid the trait impls showing up in rustdoc. --- src/libcore/slice.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index e9cf650af707..25082eed2fe6 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1672,6 +1672,7 @@ impl PartialOrd for [T] { } } +#[doc(hidden)] // intermediate trait for specialization of slice's PartialEq trait SlicePartialEq { fn equal(&self, other: &[B]) -> bool; @@ -1731,6 +1732,7 @@ impl SlicePartialEq for [A] } } +#[doc(hidden)] // intermediate trait for specialization of slice's PartialOrd trait SlicePartialOrd { fn partial_compare(&self, other: &[B]) -> Option; @@ -1765,6 +1767,7 @@ impl SlicePartialOrd for [u8] { } } +#[doc(hidden)] // intermediate trait for specialization of slice's Ord trait SliceOrd { fn compare(&self, other: &[B]) -> Ordering; @@ -1811,6 +1814,7 @@ impl SliceOrd for [u8] { } } +#[doc(hidden)] /// Trait implemented for types that can be compared for equality using /// their bytewise representation trait BytewiseEquality { } From d23be8730d278549553b94ddeb0319d337b7be1f Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 6 Apr 2016 18:03:42 +0000 Subject: [PATCH 19/20] Fix cargotest --- src/bootstrap/build/check.rs | 13 +++++++++++-- src/bootstrap/build/step.rs | 2 +- src/tools/cargotest/main.rs | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/build/check.rs b/src/bootstrap/build/check.rs index 4e2ee4752851..a2445ae498a7 100644 --- a/src/bootstrap/build/check.rs +++ b/src/bootstrap/build/check.rs @@ -18,9 +18,18 @@ pub fn linkcheck(build: &Build, stage: u32, host: &str) { } pub fn cargotest(build: &Build, stage: u32, host: &str) { + let ref compiler = Compiler::new(stage, host); + + // Configure PATH to find the right rustc. NB. we have to use PATH + // and not RUSTC because the Cargo test suite has tests that will + // fail if rustc is not spelled `rustc`. + let path = build.sysroot(compiler).join("bin"); + let old_path = ::std::env::var("PATH").expect(""); + let sep = if cfg!(windows) { ";" } else {":" }; + let ref newpath = format!("{}{}{}", path.display(), sep, old_path); + build.run(build.tool_cmd(compiler, "cargotest") - .env("RUSTC", build.compiler_path(compiler)) - .env("RUSTDOC", build.rustdoc(compiler)) + .env("PATH", newpath) .arg(&build.cargo)); } diff --git a/src/bootstrap/build/step.rs b/src/bootstrap/build/step.rs index 4e3aacd3720f..283265456626 100644 --- a/src/bootstrap/build/step.rs +++ b/src/bootstrap/build/step.rs @@ -319,7 +319,7 @@ impl<'a> Step<'a> { vec![self.librustc(self.compiler(stage))] } Source::ToolCargoTest { stage } => { - vec![self.libstd(self.compiler(stage))] + vec![self.libtest(self.compiler(stage))] } Source::DistDocs { stage } => vec![self.doc(stage)], diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 69ec9299d68e..87a010386759 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -19,7 +19,7 @@ use std::io::Write; const TEST_REPOS: &'static [(&'static str, &'static str, Option<&'static str>)] = &[ ("https://github.com/rust-lang/cargo", - "ff02b156f094fb83e70acd965c83c9286411914e", + "fae9c539388f1b7c70c31fd0a21b5dd9cd071177", None), ("https://github.com/iron/iron", "16c858ec2901e2992fe5e529780f59fa8ed12903", From 30d8eff6d7d26fae3c3fb9f6247c0c26c44b022b Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 6 Apr 2016 22:00:00 +0300 Subject: [PATCH 20/20] test the substs ppaux code both with and without -Z verbose --- src/librustc/traits/error_reporting.rs | 3 +- src/test/compile-fail/substs-ppaux.rs | 63 +++++++++++++++++++++++++ src/test/compile-fail/substs-verbose.rs | 47 ------------------ 3 files changed, 65 insertions(+), 48 deletions(-) create mode 100644 src/test/compile-fail/substs-ppaux.rs delete mode 100644 src/test/compile-fail/substs-verbose.rs diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 5b5bea012ead..6a9827387efc 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -436,7 +436,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, // If we can't show anything useful, try to find // similar impls. - let impl_candidates = find_similar_impl_candidates(infcx, trait_ref); + let impl_candidates = + find_similar_impl_candidates(infcx, trait_ref); if impl_candidates.len() > 0 { report_similar_impl_candidates(obligation.cause.span, &mut err, &impl_candidates); diff --git a/src/test/compile-fail/substs-ppaux.rs b/src/test/compile-fail/substs-ppaux.rs new file mode 100644 index 000000000000..528e50fff8cc --- /dev/null +++ b/src/test/compile-fail/substs-ppaux.rs @@ -0,0 +1,63 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// revisions: verbose normal +// +//[verbose] compile-flags: -Z verbose +// +// TODO nikomatsakis: test with both verbose and without + +trait Foo<'b, 'c, S=u32> { + fn bar<'a, T>() where T: 'a {} + fn baz() {} +} + +impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} + +fn main() {} + +fn foo<'z>() where &'z (): Sized { + let x: () = >::bar::<'static, char>; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected `()` + //[verbose]~| found `fn() {>::bar::}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected `()` + //[normal]~| found `fn() {>::bar::<'static, char>}` + + + let x: () = >::bar::<'static, char>; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected `()` + //[verbose]~| found `fn() {>::bar::}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected `()` + //[normal]~| found `fn() {>::bar::<'static, char>}` + + let x: () = >::baz; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected `()` + //[verbose]~| found `fn() {>::baz}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected `()` + //[normal]~| found `fn() {>::baz}` + + let x: () = foo::<'static>; + //[verbose]~^ ERROR mismatched types + //[verbose]~| expected `()` + //[verbose]~| found `fn() {foo::}` + //[normal]~^^^^ ERROR mismatched types + //[normal]~| expected `()` + //[normal]~| found `fn() {foo::<'static>}` + + >::bar; + //[verbose]~^ ERROR `str: std::marker::Sized` is not satisfied + //[normal]~^^ ERROR `str: std::marker::Sized` is not satisfied +} diff --git a/src/test/compile-fail/substs-verbose.rs b/src/test/compile-fail/substs-verbose.rs deleted file mode 100644 index 0ee7e67bebb1..000000000000 --- a/src/test/compile-fail/substs-verbose.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// compile-flags: -Z verbose - -// TODO nikomatsakis: test with both verbose and without - -trait Foo<'b, 'c, S=u32> { - fn bar<'a, T>() where T: 'a {} - fn baz() {} -} - -impl<'a,'b,T,S> Foo<'a, 'b, S> for T {} - -fn main() {} - -fn foo<'z>() where &'z (): Sized { - let x: () = >::bar::<'static, char>; - //~^ ERROR mismatched types - //~| expected `()` - //~| found `fn() {>::bar::}` - - let x: () = >::bar::<'static, char>; - //~^ ERROR mismatched types - //~| expected `()` - //~| found `fn() {>::bar::}` - - let x: () = >::baz; - //~^ ERROR mismatched types - //~| expected `()` - //~| found `fn() {>::baz}` - - let x: () = foo::<'static>; - //~^ ERROR mismatched types - //~| expected `()` - //~| found `fn() {foo::}` - - >::bar; - //~^ ERROR `str: std::marker::Sized` is not satisfied -}