From 4e7d53db7127d0a5315cee002d4e891f4e92977e Mon Sep 17 00:00:00 2001 From: O01eg Date: Mon, 24 Dec 2018 18:52:03 +0300 Subject: [PATCH 01/58] Search codegen backends based on target libdir instead of sysroot. Fixes cases with custom libdir when it consists of two or more parts. --- src/librustc/session/filesearch.rs | 7 ++++++ src/librustc_driver/lib.rs | 40 ++++++++++++++---------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs index c204556d517a8..8c72869eb1259 100644 --- a/src/librustc/session/filesearch.rs +++ b/src/librustc/session/filesearch.rs @@ -124,6 +124,13 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf { sysroot.join(&relative_target_lib_path(sysroot, target_triple)) } +pub fn target_lib_path(target_triple: &str) -> PathBuf { + let mut p = PathBuf::from(RUST_LIB_DIR); + p.push(target_triple); + p.push("lib"); + p +} + pub fn get_or_default_sysroot() -> PathBuf { // Follow symlinks. If the resolved path is relative, make it absolute. fn canonicalize(path: Option) -> Option { diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 5527c0ad38787..0f7e0eeaa8723 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -294,37 +294,35 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box { } let target = session::config::host_triple(); - let mut sysroot_candidates = vec![filesearch::get_or_default_sysroot()]; + // get target libdir path based on executable binary path + let sysroot = filesearch::get_or_default_sysroot(); + let mut libdir_candidates = vec![filesearch::make_target_lib_path(&sysroot, &target)]; let path = current_dll_path() .and_then(|s| s.canonicalize().ok()); if let Some(dll) = path { - // use `parent` twice to chop off the file name and then also the - // directory containing the dll which should be either `lib` or `bin`. - if let Some(path) = dll.parent().and_then(|p| p.parent()) { + // use `parent` once to chop off the file name + if let Some(path) = dll.parent() { // The original `path` pointed at the `rustc_driver` crate's dll. // Now that dll should only be in one of two locations. The first is - // in the compiler's libdir, for example `$sysroot/lib/*.dll`. The + // in the compiler's libdir, for example `$sysroot/$libdir/*.dll`. The // other is the target's libdir, for example - // `$sysroot/lib/rustlib/$target/lib/*.dll`. + // `$sysroot/$libdir/rustlib/$target/lib/*.dll`. // // We don't know which, so let's assume that if our `path` above - // ends in `$target` we *could* be in the target libdir, and always - // assume that we may be in the main libdir. - sysroot_candidates.push(path.to_owned()); - - if path.ends_with(target) { - sysroot_candidates.extend(path.parent() // chop off `$target` - .and_then(|p| p.parent()) // chop off `rustlib` - .and_then(|p| p.parent()) // chop off `lib` - .map(|s| s.to_owned())); + // doesn't end in `$target` we *could* be in the main libdir, and always + // assume that we may be in the target libdir. + libdir_candidates.push(path.to_owned()); + + if !path.parent().map_or(false, |p| p.ends_with(target)) { + libdir_candidates.push(path.join(filesearch::target_lib_path(target))); } } } - let sysroot = sysroot_candidates.iter() - .map(|sysroot| { - let libdir = filesearch::relative_target_lib_path(&sysroot, &target); - sysroot.join(libdir).with_file_name( + let sysroot = libdir_candidates.iter() + .map(|libdir| { + debug!("Trying target libdir: {}", libdir.display()); + libdir.with_file_name( option_env!("CFG_CODEGEN_BACKENDS_DIR").unwrap_or("codegen-backends")) }) .filter(|f| { @@ -333,12 +331,12 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box { }) .next(); let sysroot = sysroot.unwrap_or_else(|| { - let candidates = sysroot_candidates.iter() + let candidates = libdir_candidates.iter() .map(|p| p.display().to_string()) .collect::>() .join("\n* "); let err = format!("failed to find a `codegen-backends` folder \ - in the sysroot candidates:\n* {}", candidates); + in the libdir candidates:\n* {}", candidates); early_error(ErrorOutputType::default(), &err); }); info!("probing {} for a codegen backend", sysroot.display()); From fcad2094497519989327e372c09f9470bac7f957 Mon Sep 17 00:00:00 2001 From: David Wood Date: Mon, 24 Dec 2018 15:29:40 +0100 Subject: [PATCH 02/58] Add closure cannot be moved note. This commit extends existing logic for checking whether a closure that is `FnOnce` and therefore moves variables that it captures from the environment has already been invoked when being invoked again. Now, this logic will also check whether the closure is being moved after previously being moved or invoked and add an appropriate note. --- .../borrow_check/error_reporting.rs | 82 ++++++++++--------- src/test/ui/not-copy-closure.nll.stderr | 6 ++ 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index b072e464a2998..d7559a46e94eb 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -123,7 +123,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Origin::Mir, ); - self.add_closure_invoked_twice_with_moved_variable_suggestion( + self.add_moved_or_invoked_closure_note( context.loc, used_place, &mut err, @@ -1331,7 +1331,8 @@ enum StorageDeadOrDrop<'tcx> { impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { - /// Adds a suggestion when a closure is invoked twice with a moved variable. + /// Adds a suggestion when a closure is invoked twice with a moved variable or when a closure + /// is moved after being invoked. /// /// ```text /// note: closure cannot be invoked more than once because it moves the variable `dict` out of @@ -1341,30 +1342,18 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// LL | for (key, value) in dict { /// | ^^^^ /// ``` - pub(super) fn add_closure_invoked_twice_with_moved_variable_suggestion( + pub(super) fn add_moved_or_invoked_closure_note( &self, location: Location, place: &Place<'tcx>, diag: &mut DiagnosticBuilder<'_>, ) { + debug!("add_moved_or_invoked_closure_note: location={:?} place={:?}", location, place); let mut target = place.local(); - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: location={:?} place={:?} \ - target={:?}", - location, place, target, - ); for stmt in &self.mir[location.block].statements[location.statement_index..] { - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: stmt={:?} \ - target={:?}", - stmt, target, - ); + debug!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target); if let StatementKind::Assign(into, box Rvalue::Use(from)) = &stmt.kind { - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: into={:?} \ - from={:?}", - into, from, - ); + debug!("add_fnonce_closure_note: into={:?} from={:?}", into, from); match from { Operand::Copy(ref place) | Operand::Move(ref place) if target == place.local() => @@ -1374,12 +1363,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - + // Check if we are attempting to call a closure after it has been invoked. let terminator = self.mir[location.block].terminator(); - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: terminator={:?}", - terminator, - ); + debug!("add_moved_or_invoked_closure_note: terminator={:?}", terminator); if let TerminatorKind::Call { func: Operand::Constant(box Constant { literal: ty::Const { ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. }, .. }, @@ -1388,7 +1374,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { args, .. } = &terminator.kind { - debug!("add_closure_invoked_twice_with_moved_variable_suggestion: id={:?}", id); + debug!("add_moved_or_invoked_closure_note: id={:?}", id); if self.infcx.tcx.parent(id) == self.infcx.tcx.lang_items().fn_once_trait() { let closure = match args.first() { Some(Operand::Copy(ref place)) | @@ -1396,33 +1382,51 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { place.local().unwrap(), _ => return, }; - debug!( - "add_closure_invoked_twice_with_moved_variable_suggestion: closure={:?}", - closure, - ); - if let ty::TyKind::Closure(did, _substs) = self.mir.local_decls[closure].ty.sty { - let node_id = match self.infcx.tcx.hir().as_local_node_id(did) { - Some(node_id) => node_id, - _ => return, - }; + debug!("add_moved_or_invoked_closure_note: closure={:?}", closure); + if let ty::TyKind::Closure(did, _) = self.mir.local_decls[closure].ty.sty { + let node_id = self.infcx.tcx.hir().as_local_node_id(did).unwrap(); let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id); - if let Some(( - span, name - )) = self.infcx.tcx.typeck_tables_of(did).closure_kind_origins().get(hir_id) { + if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did) + .closure_kind_origins() + .get(hir_id) + { diag.span_note( *span, &format!( - "closure cannot be invoked more than once because it \ - moves the variable `{}` out of its environment", - name, + "closure cannot be invoked more than once because it moves the \ + variable `{}` out of its environment", + name, ), ); + return; } } } } + + // Check if we are just moving a closure after it has been invoked. + if let Some(target) = target { + if let ty::TyKind::Closure(did, _) = self.mir.local_decls[target].ty.sty { + let node_id = self.infcx.tcx.hir().as_local_node_id(did).unwrap(); + let hir_id = self.infcx.tcx.hir().node_to_hir_id(node_id); + + if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did) + .closure_kind_origins() + .get(hir_id) + { + diag.span_note( + *span, + &format!( + "closure cannot be moved more than once as it is not `Copy` due to \ + moving the variable `{}` out of its environment", + name + ), + ); + } + } + } } /// End-user visible description of `place` if one can be found. If the diff --git a/src/test/ui/not-copy-closure.nll.stderr b/src/test/ui/not-copy-closure.nll.stderr index 2f295315a08aa..1a65bcf447317 100644 --- a/src/test/ui/not-copy-closure.nll.stderr +++ b/src/test/ui/not-copy-closure.nll.stderr @@ -5,6 +5,12 @@ LL | let b = hello; | ----- value moved here LL | let c = hello; //~ ERROR use of moved value: `hello` [E0382] | ^^^^^ value used here after move + | +note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment + --> $DIR/not-copy-closure.rs:6:9 + | +LL | a += 1; + | ^ error: aborting due to previous error From fff905bc698c0b6ee8b407273e7151d7b9a7a89a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 27 Dec 2018 09:40:33 +0100 Subject: [PATCH 03/58] panic when calling MaybeUninhabited::into_inner on uninhabited type --- src/libcore/intrinsics.rs | 5 + src/libcore/mem.rs | 6 ++ src/librustc_codegen_ssa/mir/block.rs | 101 ++++++++++-------- src/librustc_typeck/check/intrinsic.rs | 1 + .../run-pass/panic-uninitialized-zeroed.rs | 41 +++++-- 5 files changed, 101 insertions(+), 53 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 7508257f7806f..4f5310f5285c9 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -690,6 +690,11 @@ extern "rust-intrinsic" { /// crate it is invoked in. pub fn type_id() -> u64; + /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: + /// This will statically either panic, or do nothing. + #[cfg(not(stage0))] + pub fn panic_if_uninhabited(); + /// Creates a value initialized to zero. /// /// `init` is unsafe because it returns a zeroed-out datum, diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index c024868714cab..8fcbb73d9ce46 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -492,6 +492,8 @@ pub const fn needs_drop() -> bool { #[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::zeroed` instead")] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn zeroed() -> T { + #[cfg(not(stage0))] + intrinsics::panic_if_uninhabited::(); intrinsics::init() } @@ -624,6 +626,8 @@ pub unsafe fn zeroed() -> T { #[rustc_deprecated(since = "2.0.0", reason = "use `mem::MaybeUninit::uninitialized` instead")] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn uninitialized() -> T { + #[cfg(not(stage0))] + intrinsics::panic_if_uninhabited::(); intrinsics::uninit() } @@ -1128,6 +1132,8 @@ impl MaybeUninit { #[unstable(feature = "maybe_uninit", issue = "53491")] #[inline(always)] pub unsafe fn into_inner(self) -> T { + #[cfg(not(stage0))] + intrinsics::panic_if_uninhabited::(); ManuallyDrop::into_inner(self.value) } diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 7397c722df6c9..de824322263d7 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -500,53 +500,62 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { _ => bx.new_fn_type(sig, &extra_args) }; - // emit a panic instead of instantiating an uninhabited type - if (intrinsic == Some("init") || intrinsic == Some("uninit")) && - fn_ty.ret.layout.abi.is_uninhabited() - { - let loc = bx.sess().source_map().lookup_char_pos(span.lo()); - let filename = Symbol::intern(&loc.file.name.to_string()).as_str(); - let filename = bx.const_str_slice(filename); - let line = bx.const_u32(loc.line as u32); - let col = bx.const_u32(loc.col.to_usize() as u32 + 1); - let align = tcx.data_layout.aggregate_align.abi - .max(tcx.data_layout.i32_align.abi) - .max(tcx.data_layout.pointer_align.abi); - - let str = format!( - "Attempted to instantiate uninhabited type {} using mem::{}", - sig.output(), - if intrinsic == Some("init") { "zeroed" } else { "uninitialized" } - ); - let msg_str = Symbol::intern(&str).as_str(); - let msg_str = bx.const_str_slice(msg_str); - let msg_file_line_col = bx.const_struct( - &[msg_str, filename, line, col], - false, - ); - let msg_file_line_col = bx.static_addr_of( - msg_file_line_col, - align, - Some("panic_loc"), - ); + // emit a panic or a NOP for `panic_if_uninhabited` + if intrinsic == Some("panic_if_uninhabited") { + let ty = match callee.layout.ty.sty { + ty::FnDef(_, substs) => { + substs.type_at(0) + } + _ => bug!("{} is not callable as intrinsic", callee.layout.ty) + }; + let layout = bx.layout_of(ty); + if layout.abi.is_uninhabited() { + let loc = bx.sess().source_map().lookup_char_pos(span.lo()); + let filename = Symbol::intern(&loc.file.name.to_string()).as_str(); + let filename = bx.const_str_slice(filename); + let line = bx.const_u32(loc.line as u32); + let col = bx.const_u32(loc.col.to_usize() as u32 + 1); + let align = tcx.data_layout.aggregate_align.abi + .max(tcx.data_layout.i32_align.abi) + .max(tcx.data_layout.pointer_align.abi); + + let str = format!( + "Attempted to instantiate uninhabited type {}", + ty + ); + let msg_str = Symbol::intern(&str).as_str(); + let msg_str = bx.const_str_slice(msg_str); + let msg_file_line_col = bx.const_struct( + &[msg_str, filename, line, col], + false, + ); + let msg_file_line_col = bx.static_addr_of( + msg_file_line_col, + align, + Some("panic_loc"), + ); - // Obtain the panic entry point. - let def_id = - common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem); - let instance = ty::Instance::mono(bx.tcx(), def_id); - let fn_ty = bx.fn_type_of_instance(&instance); - let llfn = bx.get_fn(instance); - - // Codegen the actual panic invoke/call. - do_call( - self, - &mut bx, - fn_ty, - llfn, - &[msg_file_line_col], - destination.as_ref().map(|(_, bb)| (ReturnDest::Nothing, *bb)), - cleanup, - ); + // Obtain the panic entry point. + let def_id = + common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem); + let instance = ty::Instance::mono(bx.tcx(), def_id); + let fn_ty = bx.fn_type_of_instance(&instance); + let llfn = bx.get_fn(instance); + + // Codegen the actual panic invoke/call. + do_call( + self, + &mut bx, + fn_ty, + llfn, + &[msg_file_line_col], + destination.as_ref().map(|(_, bb)| (ReturnDest::Nothing, *bb)), + cleanup, + ); + } else { + // a NOP + funclet_br(self, &mut bx, destination.as_ref().unwrap().1); + } return; } diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index c80990a0704bd..eb6ebbe0e96a1 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -133,6 +133,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ], tcx.types.usize) } "rustc_peek" => (1, vec![param(0)], param(0)), + "panic_if_uninhabited" => (1, Vec::new(), tcx.mk_unit()), "init" => (1, Vec::new(), param(0)), "uninit" => (1, Vec::new(), param(0)), "forget" => (1, vec![param(0)], tcx.mk_unit()), diff --git a/src/test/run-pass/panic-uninitialized-zeroed.rs b/src/test/run-pass/panic-uninitialized-zeroed.rs index c806bb97c1519..d47ff6c630d11 100644 --- a/src/test/run-pass/panic-uninitialized-zeroed.rs +++ b/src/test/run-pass/panic-uninitialized-zeroed.rs @@ -2,7 +2,7 @@ // This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results // in a runtime panic. -#![feature(never_type)] +#![feature(never_type, maybe_uninit)] use std::{mem, panic}; @@ -20,7 +20,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type ! using mem::uninitialized" + s == "Attempted to instantiate uninhabited type !" })), Some(true) ); @@ -29,7 +29,16 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type ! using mem::zeroed" + s == "Attempted to instantiate uninhabited type !" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::MaybeUninit::::uninitialized().into_inner() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type !" })), Some(true) ); @@ -38,7 +47,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Foo using mem::uninitialized" + s == "Attempted to instantiate uninhabited type Foo" })), Some(true) ); @@ -47,7 +56,16 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Foo using mem::zeroed" + s == "Attempted to instantiate uninhabited type Foo" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::MaybeUninit::::uninitialized().into_inner() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Foo" })), Some(true) ); @@ -56,7 +74,7 @@ fn main() { panic::catch_unwind(|| { mem::uninitialized::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Bar using mem::uninitialized" + s == "Attempted to instantiate uninhabited type Bar" })), Some(true) ); @@ -65,7 +83,16 @@ fn main() { panic::catch_unwind(|| { mem::zeroed::() }).err().and_then(|a| a.downcast_ref::().map(|s| { - s == "Attempted to instantiate uninhabited type Bar using mem::zeroed" + s == "Attempted to instantiate uninhabited type Bar" + })), + Some(true) + ); + + assert_eq!( + panic::catch_unwind(|| { + mem::MaybeUninit::::uninitialized().into_inner() + }).err().and_then(|a| a.downcast_ref::().map(|s| { + s == "Attempted to instantiate uninhabited type Bar" })), Some(true) ); From c118b17953a8e29b850b8ed8fe0d3aaf2917a9da Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 27 Dec 2018 14:25:05 +0100 Subject: [PATCH 04/58] use a better way to get at the type parameter --- src/librustc_codegen_ssa/mir/block.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index de824322263d7..aa82c853257a3 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -502,12 +502,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // emit a panic or a NOP for `panic_if_uninhabited` if intrinsic == Some("panic_if_uninhabited") { - let ty = match callee.layout.ty.sty { - ty::FnDef(_, substs) => { - substs.type_at(0) - } - _ => bug!("{} is not callable as intrinsic", callee.layout.ty) - }; + let ty = instance.unwrap().substs.type_at(0); let layout = bx.layout_of(ty); if layout.abi.is_uninhabited() { let loc = bx.sess().source_map().lookup_char_pos(span.lo()); From 2149d73358b648ee7c6f9635a123bb8aa6bb2009 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sat, 1 Dec 2018 15:04:07 +0000 Subject: [PATCH 05/58] Remove unnecessary borrow generation --- src/librustc_mir/dataflow/impls/borrows.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 518fbaae6271f..0ceff4aa04898 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -279,20 +279,6 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { }); sets.gen(*index); - - // Issue #46746: Two-phase borrows handles - // stmts of form `Tmp = &mut Borrow` ... - match lhs { - Place::Promoted(_) | - Place::Local(..) | Place::Static(..) => {} // okay - Place::Projection(..) => { - // ... can assign into projections, - // e.g., `box (&mut _)`. Current - // conservative solution: force - // immediate activation here. - sets.gen(*index); - } - } } } From 49e52e71de644e3497d32854838e3b99e28ee7c3 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sat, 29 Dec 2018 11:55:00 +0000 Subject: [PATCH 06/58] Remove unused types from rustc::mir::interpret The types are no longer used with the change to stacked borrows for validation. --- src/librustc/ich/impls_ty.rs | 16 ---------------- src/librustc/mir/interpret/mod.rs | 22 ---------------------- 2 files changed, 38 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 65b8f04e30a12..bab3846fe86e5 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -473,22 +473,6 @@ impl_stable_hash_for!(enum mir::interpret::InboundsCheck { MaybeDead }); -impl_stable_hash_for!(enum mir::interpret::Lock { - NoLock, - WriteLock(dl), - ReadLock(v) -}); - -impl_stable_hash_for!(struct mir::interpret::DynamicLifetime { - frame, - region -}); - -impl_stable_hash_for!(enum mir::interpret::AccessKind { - Read, - Write -}); - impl_stable_hash_for!(enum ty::Variance { Covariant, Invariant, diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 25a0f0ba489d1..e6a560b2ad7b6 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -29,7 +29,6 @@ use mir; use hir::def_id::DefId; use ty::{self, TyCtxt, Instance}; use ty::layout::{self, Size}; -use middle::region; use std::io; use rustc_serialize::{Encoder, Decodable, Encodable}; use rustc_data_structures::fx::FxHashMap; @@ -40,27 +39,6 @@ use ty::codec::TyDecoder; use std::sync::atomic::{AtomicU32, Ordering}; use std::num::NonZeroU32; -#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] -pub enum Lock { - NoLock, - WriteLock(DynamicLifetime), - /// This should never be empty -- that would be a read lock held and nobody - /// there to release it... - ReadLock(Vec), -} - -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)] -pub struct DynamicLifetime { - pub frame: usize, - pub region: Option, // "None" indicates "until the function ends" -} - -#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)] -pub enum AccessKind { - Read, - Write, -} - /// Uniquely identifies a specific constant or static. #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, RustcEncodable, RustcDecodable)] pub struct GlobalId<'tcx> { From 4e77c3a9b1ac25e3c01911e37e0b79cef93ec7ee Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 4 Nov 2018 11:27:09 +0100 Subject: [PATCH 07/58] test: Add test for issues 45510 and 18952. Those tests are directly taken from the comments on the bug reports. --- src/test/run-pass/issue-18952.rs | 48 ++++++++++++++++++++++++++++++++ src/test/run-pass/issue-45510.rs | 27 ++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/test/run-pass/issue-18952.rs create mode 100644 src/test/run-pass/issue-45510.rs diff --git a/src/test/run-pass/issue-18952.rs b/src/test/run-pass/issue-18952.rs new file mode 100644 index 0000000000000..ca2645ca9e5d9 --- /dev/null +++ b/src/test/run-pass/issue-18952.rs @@ -0,0 +1,48 @@ +// This issue tests fn_traits overloading on arity. + +#![feature(fn_traits)] +#![feature(unboxed_closures)] + +struct Foo; + +impl Fn<(isize, isize)> for Foo { + extern "rust-call" fn call(&self, args: (isize, isize)) -> Self::Output { + println!("{:?}", args); + } +} + +impl FnMut<(isize, isize)> for Foo { + extern "rust-call" fn call_mut(&mut self, args: (isize, isize)) -> Self::Output { + println!("{:?}", args); + } +} + +impl FnOnce<(isize, isize)> for Foo { + type Output = (); + extern "rust-call" fn call_once(self, args: (isize, isize)) -> Self::Output { + println!("{:?}", args); + } +} + +impl Fn<(isize, isize, isize)> for Foo { + extern "rust-call" fn call(&self, args: (isize, isize, isize)) -> Self::Output { + println!("{:?}", args); + } +} + +impl FnMut<(isize, isize, isize)> for Foo { + extern "rust-call" fn call_mut(&mut self, args: (isize, isize, isize)) -> Self::Output { + println!("{:?}", args); + } +} +impl FnOnce<(isize, isize, isize)> for Foo { + type Output = (); + extern "rust-call" fn call_once(self, args: (isize, isize, isize)) -> Self::Output { + println!("{:?}", args); + } +} + +fn main() { + let foo = Foo; + foo(1, 1); +} diff --git a/src/test/run-pass/issue-45510.rs b/src/test/run-pass/issue-45510.rs new file mode 100644 index 0000000000000..922a26b903094 --- /dev/null +++ b/src/test/run-pass/issue-45510.rs @@ -0,0 +1,27 @@ +// Test overloaded resolution of fn_traits. + +#![feature(fn_traits)] +#![feature(unboxed_closures)] + +struct Ishmael; +struct Maybe; +struct CallMe; + +impl FnOnce<(Ishmael,)> for CallMe { + type Output = (); + extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> () { + println!("Split your lungs with blood and thunder!"); + } +} + +impl FnOnce<(Maybe,)> for CallMe { + type Output = (); + extern "rust-call" fn call_once(self, _args: (Maybe,)) -> () { + println!("So we just met, and this is crazy"); + } +} + +fn main() { + CallMe(Ishmael); + CallMe(Maybe); +} From 6de9c13830c74551632f2a1b299778d9e62381ff Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 4 Nov 2018 16:14:44 +0100 Subject: [PATCH 08/58] rustfmt: librust_typeck/check/callee.rs --- src/librustc_typeck/check/callee.rs | 344 ++++++++++++++++------------ 1 file changed, 200 insertions(+), 144 deletions(-) diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index d4f639c070de3..727fbf7b30f67 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -1,16 +1,16 @@ -use super::{Expectation, FnCtxt, Needs, TupleArgumentsFlag}; use super::autoderef::Autoderef; use super::method::MethodCallee; +use super::{Expectation, FnCtxt, Needs, TupleArgumentsFlag}; +use errors::Applicability; use hir::def::Def; use hir::def_id::{DefId, LOCAL_CRATE}; +use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::{infer, traits}; -use rustc::ty::{self, TyCtxt, TypeFoldable, Ty}; -use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc_target::spec::abi; use syntax::ast::Ident; use syntax_pos::Span; -use errors::Applicability; use rustc::hir; @@ -33,12 +33,13 @@ enum CallStep<'tcx> { } impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { - pub fn check_call(&self, - call_expr: &'gcx hir::Expr, - callee_expr: &'gcx hir::Expr, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>) - -> Ty<'tcx> { + pub fn check_call( + &self, + call_expr: &'gcx hir::Expr, + callee_expr: &'gcx hir::Expr, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { let original_callee_ty = self.check_expr(callee_expr); let expr_ty = self.structurally_resolved_type(call_expr.span, original_callee_ty); @@ -74,15 +75,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { output } - fn try_overloaded_call_step(&self, - call_expr: &'gcx hir::Expr, - callee_expr: &'gcx hir::Expr, - autoderef: &Autoderef<'a, 'gcx, 'tcx>) - -> Option> { + fn try_overloaded_call_step( + &self, + call_expr: &'gcx hir::Expr, + callee_expr: &'gcx hir::Expr, + autoderef: &Autoderef<'a, 'gcx, 'tcx>, + ) -> Option> { let adjusted_ty = autoderef.unambiguous_final_ty(self); - debug!("try_overloaded_call_step(call_expr={:?}, adjusted_ty={:?})", - call_expr, - adjusted_ty); + debug!( + "try_overloaded_call_step(call_expr={:?}, adjusted_ty={:?})", + call_expr, adjusted_ty + ); // If the callee is a bare function or a closure, then we're all set. match adjusted_ty.sty { @@ -100,21 +103,26 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // fnmut vs fnonce. If so, we have to defer further processing. if self.closure_kind(def_id, substs).is_none() { let closure_ty = self.closure_sig(def_id, substs); - let fn_sig = self.replace_bound_vars_with_fresh_vars( - call_expr.span, - infer::FnCall, - &closure_ty - ).0; + let fn_sig = self + .replace_bound_vars_with_fresh_vars( + call_expr.span, + infer::FnCall, + &closure_ty, + ) + .0; let adjustments = autoderef.adjust_steps(self, Needs::None); - self.record_deferred_call_resolution(def_id, DeferredCallResolution { - call_expr, - callee_expr, - adjusted_ty, - adjustments, - fn_sig, - closure_def_id: def_id, - closure_substs: substs, - }); + self.record_deferred_call_resolution( + def_id, + DeferredCallResolution { + call_expr, + callee_expr, + adjusted_ty, + adjustments, + fn_sig, + closure_def_id: def_id, + closure_substs: substs, + }, + ); return Some(CallStep::DeferredClosure(fn_sig)); } } @@ -134,34 +142,50 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => {} } - self.try_overloaded_call_traits(call_expr, adjusted_ty).map(|(autoref, method)| { - let mut adjustments = autoderef.adjust_steps(self, Needs::None); - adjustments.extend(autoref); - self.apply_adjustments(callee_expr, adjustments); - CallStep::Overloaded(method) - }) + self.try_overloaded_call_traits(call_expr, adjusted_ty) + .map(|(autoref, method)| { + let mut adjustments = autoderef.adjust_steps(self, Needs::None); + adjustments.extend(autoref); + self.apply_adjustments(callee_expr, adjustments); + CallStep::Overloaded(method) + }) } - fn try_overloaded_call_traits(&self, - call_expr: &hir::Expr, - adjusted_ty: Ty<'tcx>) - -> Option<(Option>, - MethodCallee<'tcx>)> { + fn try_overloaded_call_traits( + &self, + call_expr: &hir::Expr, + adjusted_ty: Ty<'tcx>, + ) -> Option<(Option>, MethodCallee<'tcx>)> { // Try the options that are least restrictive on the caller first. - for &(opt_trait_def_id, method_name, borrow) in - &[(self.tcx.lang_items().fn_trait(), Ident::from_str("call"), true), - (self.tcx.lang_items().fn_mut_trait(), Ident::from_str("call_mut"), true), - (self.tcx.lang_items().fn_once_trait(), Ident::from_str("call_once"), false)] { + for &(opt_trait_def_id, method_name, borrow) in &[ + ( + self.tcx.lang_items().fn_trait(), + Ident::from_str("call"), + true, + ), + ( + self.tcx.lang_items().fn_mut_trait(), + Ident::from_str("call_mut"), + true, + ), + ( + self.tcx.lang_items().fn_once_trait(), + Ident::from_str("call_once"), + false, + ), + ] { let trait_def_id = match opt_trait_def_id { Some(def_id) => def_id, None => continue, }; - if let Some(ok) = self.lookup_method_in_trait(call_expr.span, - method_name, - trait_def_id, - adjusted_ty, - None) { + if let Some(ok) = self.lookup_method_in_trait( + call_expr.span, + method_name, + trait_def_id, + adjusted_ty, + None, + ) { let method = self.register_infer_ok_obligations(ok); let mut autoref = None; if borrow { @@ -173,11 +197,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // deployment, conservatively omit // overloaded function call ops. allow_two_phase_borrow: AllowTwoPhase::No, - } + }, }; autoref = Some(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), - target: method.sig.inputs()[0] + target: method.sig.inputs()[0], }); } } @@ -188,16 +212,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None } - fn confirm_builtin_call(&self, - call_expr: &hir::Expr, - callee_ty: Ty<'tcx>, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>) - -> Ty<'tcx> { + fn confirm_builtin_call( + &self, + call_expr: &hir::Expr, + callee_ty: Ty<'tcx>, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + ) -> Ty<'tcx> { let (fn_sig, def_span) = match callee_ty.sty { - ty::FnDef(def_id, _) => { - (callee_ty.fn_sig(self.tcx), self.tcx.hir().span_if_local(def_id)) - } + ty::FnDef(def_id, _) => ( + callee_ty.fn_sig(self.tcx), + self.tcx.hir().span_if_local(def_id), + ), ty::FnPtr(sig) => (sig, None), ref t => { let mut unit_variant = None; @@ -219,15 +245,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { match unit_variant { Some(ref path) => format!("enum variant `{}`", path), None => format!("`{}`", callee_ty), - }); + } + ); if let Some(ref path) = unit_variant { err.span_suggestion_with_applicability( call_expr.span, - &format!("`{}` is a unit variant, you need to write it \ - without the parenthesis", path), + &format!( + "`{}` is a unit variant, you need to write it \ + without the parenthesis", + path + ), path.to_string(), - Applicability::MachineApplicable + Applicability::MachineApplicable, ); } @@ -235,48 +265,50 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let def = match callee.node { hir::ExprKind::Path(ref qpath) => { self.tables.borrow().qpath_def(qpath, callee.hir_id) - }, + } hir::ExprKind::Call(ref inner_callee, _) => { // If the call spans more than one line and the callee kind is // itself another `ExprCall`, that's a clue that we might just be // missing a semicolon (Issue #51055) - let call_is_multiline = self.tcx.sess.source_map() - .is_multiline(call_expr.span); + let call_is_multiline = + self.tcx.sess.source_map().is_multiline(call_expr.span); if call_is_multiline { let span = self.tcx.sess.source_map().next_point(callee.span); err.span_suggestion_with_applicability( span, "try adding a semicolon", ";".to_owned(), - Applicability::MaybeIncorrect + Applicability::MaybeIncorrect, ); } if let hir::ExprKind::Path(ref inner_qpath) = inner_callee.node { inner_callee_path = Some(inner_qpath); - self.tables.borrow().qpath_def(inner_qpath, inner_callee.hir_id) + self.tables + .borrow() + .qpath_def(inner_qpath, inner_callee.hir_id) } else { Def::Err } - }, - _ => { - Def::Err } + _ => Def::Err, }; err.span_label(call_expr.span, "call expression requires function"); let def_span = match def { Def::Err => None, - Def::Local(id) | Def::Upvar(id, ..) => { - Some(self.tcx.hir().span(id)) - } - _ => def.opt_def_id().and_then(|did| self.tcx.hir().span_if_local(did)), + Def::Local(id) | Def::Upvar(id, ..) => Some(self.tcx.hir().span(id)), + _ => def + .opt_def_id() + .and_then(|did| self.tcx.hir().span_if_local(did)), }; if let Some(span) = def_span { let label = match (unit_variant, inner_callee_path) { (Some(path), _) => format!("`{}` defined here", path), (_, Some(hir::QPath::Resolved(_, path))) => format!( - "`{}` defined here returns `{}`", path, callee_ty.to_string() + "`{}` defined here returns `{}`", + path, + callee_ty.to_string() ), _ => format!("`{}` defined here", callee_ty.to_string()), }; @@ -284,19 +316,25 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } err.emit(); } else { - bug!("call_expr.node should be an ExprKind::Call, got {:?}", call_expr.node); + bug!( + "call_expr.node should be an ExprKind::Call, got {:?}", + call_expr.node + ); } // This is the "default" function signature, used in case of error. // In that case, we check each argument against "error" in order to // set up all the node type bindings. - (ty::Binder::bind(self.tcx.mk_fn_sig( - self.err_args(arg_exprs.len()).into_iter(), - self.tcx.types.err, - false, - hir::Unsafety::Normal, - abi::Abi::Rust - )), None) + ( + ty::Binder::bind(self.tcx.mk_fn_sig( + self.err_args(arg_exprs.len()).into_iter(), + self.tcx.types.err, + false, + hir::Unsafety::Normal, + abi::Abi::Rust, + )), + None, + ) } }; @@ -305,69 +343,80 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // renormalize the associated types at this point, since they // previously appeared within a `Binder<>` and hence would not // have been normalized before. - let fn_sig = - self.replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, &fn_sig) - .0; + let fn_sig = self + .replace_bound_vars_with_fresh_vars(call_expr.span, infer::FnCall, &fn_sig) + .0; let fn_sig = self.normalize_associated_types_in(call_expr.span, &fn_sig); // Call the generic checker. - let expected_arg_tys = - self.expected_inputs_for_expected_output(call_expr.span, - expected, - fn_sig.output(), - fn_sig.inputs()); - self.check_argument_types(call_expr.span, - call_expr.span, - fn_sig.inputs(), - &expected_arg_tys[..], - arg_exprs, - fn_sig.variadic, - TupleArgumentsFlag::DontTupleArguments, - def_span); + let expected_arg_tys = self.expected_inputs_for_expected_output( + call_expr.span, + expected, + fn_sig.output(), + fn_sig.inputs(), + ); + self.check_argument_types( + call_expr.span, + call_expr.span, + fn_sig.inputs(), + &expected_arg_tys[..], + arg_exprs, + fn_sig.variadic, + TupleArgumentsFlag::DontTupleArguments, + def_span, + ); fn_sig.output() } - fn confirm_deferred_closure_call(&self, - call_expr: &hir::Expr, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>, - fn_sig: ty::FnSig<'tcx>) - -> Ty<'tcx> { + fn confirm_deferred_closure_call( + &self, + call_expr: &hir::Expr, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + fn_sig: ty::FnSig<'tcx>, + ) -> Ty<'tcx> { // `fn_sig` is the *signature* of the cosure being called. We // don't know the full details yet (`Fn` vs `FnMut` etc), but we // do know the types expected for each argument and the return // type. - let expected_arg_tys = self.expected_inputs_for_expected_output(call_expr.span, - expected, - fn_sig.output().clone(), - fn_sig.inputs()); - - self.check_argument_types(call_expr.span, - call_expr.span, - fn_sig.inputs(), - &expected_arg_tys, - arg_exprs, - fn_sig.variadic, - TupleArgumentsFlag::TupleArguments, - None); + let expected_arg_tys = self.expected_inputs_for_expected_output( + call_expr.span, + expected, + fn_sig.output().clone(), + fn_sig.inputs(), + ); + + self.check_argument_types( + call_expr.span, + call_expr.span, + fn_sig.inputs(), + &expected_arg_tys, + arg_exprs, + fn_sig.variadic, + TupleArgumentsFlag::TupleArguments, + None, + ); fn_sig.output() } - fn confirm_overloaded_call(&self, - call_expr: &hir::Expr, - arg_exprs: &'gcx [hir::Expr], - expected: Expectation<'tcx>, - method_callee: MethodCallee<'tcx>) - -> Ty<'tcx> { - let output_type = self.check_method_argument_types(call_expr.span, - call_expr.span, - Ok(method_callee), - arg_exprs, - TupleArgumentsFlag::TupleArguments, - expected); + fn confirm_overloaded_call( + &self, + call_expr: &hir::Expr, + arg_exprs: &'gcx [hir::Expr], + expected: Expectation<'tcx>, + method_callee: MethodCallee<'tcx>, + ) -> Ty<'tcx> { + let output_type = self.check_method_argument_types( + call_expr.span, + call_expr.span, + Ok(method_callee), + arg_exprs, + TupleArgumentsFlag::TupleArguments, + expected, + ); self.write_method_call(call_expr.hir_id, method_callee); output_type @@ -391,11 +440,12 @@ impl<'a, 'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> { // we should not be invoked until the closure kind has been // determined by upvar inference - assert!(fcx.closure_kind(self.closure_def_id, self.closure_substs).is_some()); + assert!(fcx + .closure_kind(self.closure_def_id, self.closure_substs) + .is_some()); // We may now know enough to figure out fn vs fnmut etc. - match fcx.try_overloaded_call_traits(self.call_expr, - self.adjusted_ty) { + match fcx.try_overloaded_call_traits(self.call_expr, self.adjusted_ty) { Some((autoref, method_callee)) => { // One problem is that when we get here, we are going // to have a newly instantiated function signature @@ -410,22 +460,28 @@ impl<'a, 'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> { debug!("attempt_resolution: method_callee={:?}", method_callee); for (method_arg_ty, self_arg_ty) in - method_sig.inputs().iter().skip(1).zip(self.fn_sig.inputs()) { + method_sig.inputs().iter().skip(1).zip(self.fn_sig.inputs()) + { fcx.demand_eqtype(self.call_expr.span, &self_arg_ty, &method_arg_ty); } - fcx.demand_eqtype(self.call_expr.span, method_sig.output(), self.fn_sig.output()); + fcx.demand_eqtype( + self.call_expr.span, + method_sig.output(), + self.fn_sig.output(), + ); let mut adjustments = self.adjustments; adjustments.extend(autoref); fcx.apply_adjustments(self.callee_expr, adjustments); - fcx.write_method_call(self.call_expr.hir_id, - method_callee); + fcx.write_method_call(self.call_expr.hir_id, method_callee); } None => { - span_bug!(self.call_expr.span, - "failed to find an overloaded call trait for closure call"); + span_bug!( + self.call_expr.span, + "failed to find an overloaded call trait for closure call" + ); } } } From 1827d52a3f39fd9b25cebf4d78f2e0926c0cb593 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 4 Nov 2018 11:23:45 +0100 Subject: [PATCH 09/58] rustc_typeck: Implement resolution advised in issue 45510. When resolving Fn traits, the compiler failed to take into account overloaded implementations. To resolve this, we inform the trait dispatch code that the arguments will becoming as a tuple of correct arity. --- src/librustc_typeck/check/callee.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 727fbf7b30f67..5a79bec4dd72d 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -8,6 +8,7 @@ use hir::def_id::{DefId, LOCAL_CRATE}; use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::{infer, traits}; +use rustc::infer::type_variable::TypeVariableOrigin; use rustc_target::spec::abi; use syntax::ast::Ident; use syntax_pos::Span; @@ -46,7 +47,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut autoderef = self.autoderef(callee_expr.span, expr_ty); let mut result = None; while result.is_none() && autoderef.next().is_some() { - result = self.try_overloaded_call_step(call_expr, callee_expr, &autoderef); + result = self.try_overloaded_call_step(call_expr, callee_expr, arg_exprs, &autoderef); } autoderef.finalize(self); @@ -79,6 +80,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { &self, call_expr: &'gcx hir::Expr, callee_expr: &'gcx hir::Expr, + arg_exprs: &'gcx [hir::Expr], autoderef: &Autoderef<'a, 'gcx, 'tcx>, ) -> Option> { let adjusted_ty = autoderef.unambiguous_final_ty(self); @@ -142,7 +144,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => {} } - self.try_overloaded_call_traits(call_expr, adjusted_ty) + self.try_overloaded_call_traits(call_expr, adjusted_ty, Some(arg_exprs)) .map(|(autoref, method)| { let mut adjustments = autoderef.adjust_steps(self, Needs::None); adjustments.extend(autoref); @@ -155,6 +157,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { &self, call_expr: &hir::Expr, adjusted_ty: Ty<'tcx>, + opt_arg_exprs: Option<&'gcx [hir::Expr]>, ) -> Option<(Option>, MethodCallee<'tcx>)> { // Try the options that are least restrictive on the caller first. for &(opt_trait_def_id, method_name, borrow) in &[ @@ -179,12 +182,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { None => continue, }; + let opt_input_types = opt_arg_exprs.map(|arg_exprs| [self.tcx.mk_tup( + arg_exprs + .iter() + .map(|e| self.next_ty_var( + TypeVariableOrigin::TypeInference(e.span) + )) + )]); + let opt_input_types = opt_input_types.as_ref().map(AsRef::as_ref); + if let Some(ok) = self.lookup_method_in_trait( call_expr.span, method_name, trait_def_id, adjusted_ty, - None, + opt_input_types, ) { let method = self.register_infer_ok_obligations(ok); let mut autoref = None; @@ -445,7 +457,7 @@ impl<'a, 'gcx, 'tcx> DeferredCallResolution<'gcx, 'tcx> { .is_some()); // We may now know enough to figure out fn vs fnmut etc. - match fcx.try_overloaded_call_traits(self.call_expr, self.adjusted_ty) { + match fcx.try_overloaded_call_traits(self.call_expr, self.adjusted_ty, None) { Some((autoref, method_callee)) => { // One problem is that when we get here, we are going // to have a newly instantiated function signature From f518cf9ba9f3580c9f6d1d9adf45c4490250c275 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 8 Nov 2018 10:39:46 +0100 Subject: [PATCH 10/58] Move tests to ui. --- src/test/{run-pass => ui}/issue-18952.rs | 1 + src/test/{run-pass => ui}/issue-45510.rs | 1 + 2 files changed, 2 insertions(+) rename src/test/{run-pass => ui}/issue-18952.rs (99%) rename src/test/{run-pass => ui}/issue-45510.rs (97%) diff --git a/src/test/run-pass/issue-18952.rs b/src/test/ui/issue-18952.rs similarity index 99% rename from src/test/run-pass/issue-18952.rs rename to src/test/ui/issue-18952.rs index ca2645ca9e5d9..08e48c232c91e 100644 --- a/src/test/run-pass/issue-18952.rs +++ b/src/test/ui/issue-18952.rs @@ -1,4 +1,5 @@ // This issue tests fn_traits overloading on arity. +// run-pass #![feature(fn_traits)] #![feature(unboxed_closures)] diff --git a/src/test/run-pass/issue-45510.rs b/src/test/ui/issue-45510.rs similarity index 97% rename from src/test/run-pass/issue-45510.rs rename to src/test/ui/issue-45510.rs index 922a26b903094..2fa1ee813c308 100644 --- a/src/test/run-pass/issue-45510.rs +++ b/src/test/ui/issue-45510.rs @@ -1,4 +1,5 @@ // Test overloaded resolution of fn_traits. +// run-pass #![feature(fn_traits)] #![feature(unboxed_closures)] From 2f42a188d9464427803a609905f12a40248c791d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 21 Nov 2018 10:10:16 +0100 Subject: [PATCH 11/58] Fix failing diagnostic test. --- src/librustc_typeck/check/callee.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 5a79bec4dd72d..f10985a4d0eaa 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -145,6 +145,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } self.try_overloaded_call_traits(call_expr, adjusted_ty, Some(arg_exprs)) + .or_else(|| self.try_overloaded_call_traits(call_expr, adjusted_ty, None)) .map(|(autoref, method)| { let mut adjustments = autoderef.adjust_steps(self, Needs::None); adjustments.extend(autoref); From 2530ce9fa63a756d655b8e0801b4542c74ec4cae Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Wed, 21 Nov 2018 10:10:35 +0100 Subject: [PATCH 12/58] Add comment. --- src/librustc_typeck/check/callee.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index f10985a4d0eaa..c59c143f74b62 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -144,6 +144,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { _ => {} } + // Now, we look for the implementation of a Fn trait on the object's type. + // We first do it with the explicit instruction to look for an impl of + // `Fn`, with the tuple `Tuple` having an arity corresponding + // to the number of call parameters. + // If that fails (or_else branch), we try again without specifying the + // shape of the tuple (hence the None). This allows to detect an Fn trait + // is implemented, and use this information for diagnostic. self.try_overloaded_call_traits(call_expr, adjusted_ty, Some(arg_exprs)) .or_else(|| self.try_overloaded_call_traits(call_expr, adjusted_ty, None)) .map(|(autoref, method)| { From 91c155bcd7af54fba0b705de1a2c2d55fa9788fa Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 27 Nov 2018 15:15:27 +0100 Subject: [PATCH 13/58] Change return types and check return values in tests. This allows to verify that we handle different types as return types, and that we call the expected functions. --- src/test/{ui => run-pass}/issue-18952.rs | 13 ++++++++++--- src/test/{ui => run-pass}/issue-45510.rs | 16 ++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) rename src/test/{ui => run-pass}/issue-18952.rs (75%) rename src/test/{ui => run-pass}/issue-45510.rs (59%) diff --git a/src/test/ui/issue-18952.rs b/src/test/run-pass/issue-18952.rs similarity index 75% rename from src/test/ui/issue-18952.rs rename to src/test/run-pass/issue-18952.rs index 08e48c232c91e..56378b59e3642 100644 --- a/src/test/ui/issue-18952.rs +++ b/src/test/run-pass/issue-18952.rs @@ -9,41 +9,48 @@ struct Foo; impl Fn<(isize, isize)> for Foo { extern "rust-call" fn call(&self, args: (isize, isize)) -> Self::Output { println!("{:?}", args); + (args.0 + 1, args.1 + 1) } } impl FnMut<(isize, isize)> for Foo { extern "rust-call" fn call_mut(&mut self, args: (isize, isize)) -> Self::Output { println!("{:?}", args); + (args.0 + 1, args.1 + 1) } } impl FnOnce<(isize, isize)> for Foo { - type Output = (); + type Output = (isize, isize); extern "rust-call" fn call_once(self, args: (isize, isize)) -> Self::Output { println!("{:?}", args); + (args.0 + 1, args.1 + 1) } } impl Fn<(isize, isize, isize)> for Foo { extern "rust-call" fn call(&self, args: (isize, isize, isize)) -> Self::Output { println!("{:?}", args); + (args.0 + 3, args.1 + 3, args.2 + 3) } } impl FnMut<(isize, isize, isize)> for Foo { extern "rust-call" fn call_mut(&mut self, args: (isize, isize, isize)) -> Self::Output { println!("{:?}", args); + (args.0 + 3, args.1 + 3, args.2 + 3) } } impl FnOnce<(isize, isize, isize)> for Foo { - type Output = (); + type Output = (isize, isize, isize); extern "rust-call" fn call_once(self, args: (isize, isize, isize)) -> Self::Output { println!("{:?}", args); + (args.0 + 3, args.1 + 3, args.2 + 3) } } fn main() { let foo = Foo; - foo(1, 1); + assert_eq!(foo(1, 1), (2, 2)); + assert_eq!(foo(1, 1, 1), (4, 4, 4)); } diff --git a/src/test/ui/issue-45510.rs b/src/test/run-pass/issue-45510.rs similarity index 59% rename from src/test/ui/issue-45510.rs rename to src/test/run-pass/issue-45510.rs index 2fa1ee813c308..9e104ce6c4f30 100644 --- a/src/test/ui/issue-45510.rs +++ b/src/test/run-pass/issue-45510.rs @@ -4,25 +4,29 @@ #![feature(fn_traits)] #![feature(unboxed_closures)] +#[derive(Debug, PartialEq, Eq)] struct Ishmael; +#[derive(Debug, PartialEq, Eq)] struct Maybe; struct CallMe; impl FnOnce<(Ishmael,)> for CallMe { - type Output = (); - extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> () { + type Output = Ishmael; + extern "rust-call" fn call_once(self, _args: (Ishmael,)) -> Ishmael { println!("Split your lungs with blood and thunder!"); + Ishmael } } impl FnOnce<(Maybe,)> for CallMe { - type Output = (); - extern "rust-call" fn call_once(self, _args: (Maybe,)) -> () { + type Output = Maybe; + extern "rust-call" fn call_once(self, _args: (Maybe,)) -> Maybe { println!("So we just met, and this is crazy"); + Maybe } } fn main() { - CallMe(Ishmael); - CallMe(Maybe); + assert_eq!(CallMe(Ishmael), Ishmael); + assert_eq!(CallMe(Maybe), Maybe); } From afb7c0683415bec312a1ac4679768472fa8ab73b Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Sun, 30 Dec 2018 18:39:53 +0000 Subject: [PATCH 14/58] Remove unused nll debug flags --- src/librustc/session/config.rs | 4 ---- src/test/run-pass/generator/yield-subtype.rs | 1 - src/test/ui/span/dropck_vec_cycle_checked.nll.stderr | 6 +++--- src/test/ui/span/dropck_vec_cycle_checked.rs | 5 ----- src/test/ui/span/dropck_vec_cycle_checked.stderr | 12 ++++++------ 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index e58c9d75a9db2..b839980f2574e 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1309,12 +1309,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "Disable the instrumentation pre-inliner, useful for profiling / PGO."), relro_level: Option = (None, parse_relro_level, [TRACKED], "choose which RELRO level to use"), - nll_subminimal_causes: bool = (false, parse_bool, [UNTRACKED], - "when tracking region error causes, accept subminimal results for faster execution."), nll_facts: bool = (false, parse_bool, [UNTRACKED], "dump facts from NLL analysis into side files"), - disable_nll_user_type_assert: bool = (false, parse_bool, [UNTRACKED], - "disable user provided type assertion in NLL"), nll_dont_emit_read_for_match: bool = (false, parse_bool, [UNTRACKED], "in match codegen, do not include FakeRead statements (used by mir-borrowck)"), dont_buffer_diagnostics: bool = (false, parse_bool, [UNTRACKED], diff --git a/src/test/run-pass/generator/yield-subtype.rs b/src/test/run-pass/generator/yield-subtype.rs index c00662e6c0121..c38524857b4a2 100644 --- a/src/test/run-pass/generator/yield-subtype.rs +++ b/src/test/run-pass/generator/yield-subtype.rs @@ -3,7 +3,6 @@ #![allow(dead_code)] // revisions:lexical nll -//[nll]compile-flags: -Z disable-nll-user-type-assert #![cfg_attr(nll, feature(nll))] #![feature(generators)] diff --git a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr index 3d9c9354769a4..05692515af846 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr +++ b/src/test/ui/span/dropck_vec_cycle_checked.nll.stderr @@ -1,5 +1,5 @@ error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:103:24 + --> $DIR/dropck_vec_cycle_checked.rs:98:24 | LL | c1.v[0].v.set(Some(&c2)); | ^^^ borrowed value does not live long enough @@ -13,7 +13,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:105:24 + --> $DIR/dropck_vec_cycle_checked.rs:100:24 | LL | c1.v[1].v.set(Some(&c3)); | ^^^ borrowed value does not live long enough @@ -27,7 +27,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are defined error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:111:24 + --> $DIR/dropck_vec_cycle_checked.rs:106:24 | LL | c3.v[0].v.set(Some(&c1)); | ^^^ borrowed value does not live long enough diff --git a/src/test/ui/span/dropck_vec_cycle_checked.rs b/src/test/ui/span/dropck_vec_cycle_checked.rs index 4f627c4270ca5..c80e0386e6a15 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.rs +++ b/src/test/ui/span/dropck_vec_cycle_checked.rs @@ -1,12 +1,7 @@ -// compile-flags: -Z nll-subminimal-causes -// (Work around rust-lang/rust#49998 by opting into nll-subminimal-causes.) - // Reject mixing cyclic structure and Drop when using Vec. // // (Compare against compile-fail/dropck_arr_cycle_checked.rs) - - use std::cell::Cell; use id::Id; diff --git a/src/test/ui/span/dropck_vec_cycle_checked.stderr b/src/test/ui/span/dropck_vec_cycle_checked.stderr index 3a5214446119a..35e4314d0c66f 100644 --- a/src/test/ui/span/dropck_vec_cycle_checked.stderr +++ b/src/test/ui/span/dropck_vec_cycle_checked.stderr @@ -1,5 +1,5 @@ error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:103:25 + --> $DIR/dropck_vec_cycle_checked.rs:98:25 | LL | c1.v[0].v.set(Some(&c2)); | ^^ borrowed value does not live long enough @@ -10,7 +10,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:105:25 + --> $DIR/dropck_vec_cycle_checked.rs:100:25 | LL | c1.v[1].v.set(Some(&c3)); | ^^ borrowed value does not live long enough @@ -21,7 +21,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:107:25 + --> $DIR/dropck_vec_cycle_checked.rs:102:25 | LL | c2.v[0].v.set(Some(&c2)); | ^^ borrowed value does not live long enough @@ -32,7 +32,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c3` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:109:25 + --> $DIR/dropck_vec_cycle_checked.rs:104:25 | LL | c2.v[1].v.set(Some(&c3)); | ^^ borrowed value does not live long enough @@ -43,7 +43,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c1` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:111:25 + --> $DIR/dropck_vec_cycle_checked.rs:106:25 | LL | c3.v[0].v.set(Some(&c1)); | ^^ borrowed value does not live long enough @@ -54,7 +54,7 @@ LL | } = note: values in a scope are dropped in the opposite order they are created error[E0597]: `c2` does not live long enough - --> $DIR/dropck_vec_cycle_checked.rs:113:25 + --> $DIR/dropck_vec_cycle_checked.rs:108:25 | LL | c3.v[1].v.set(Some(&c2)); | ^^ borrowed value does not live long enough From 3512a722dafa4221c9f3e02d27c83ee40eb94d6f Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Tue, 20 Nov 2018 23:37:19 +0100 Subject: [PATCH 15/58] Implement the re-rebalance coherence rfc --- src/librustc/traits/coherence.rs | 125 +++++++++++++++++++++++-------- src/libsyntax/feature_gate.rs | 3 + 2 files changed, 98 insertions(+), 30 deletions(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 980c98d2a2d50..e7636f5b3e0a3 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -344,43 +344,108 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, trait_ref); } - // First, create an ordered iterator over all the type parameters to the trait, with the self - // type appearing first. - // Find the first input type that either references a type parameter OR - // some local type. - for input_ty in trait_ref.input_types() { - if ty_is_local(tcx, input_ty, in_crate) { - debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); - - // First local input type. Check that there are no - // uncovered type parameters. - let uncovered_tys = uncovered_tys(tcx, input_ty, in_crate); - for uncovered_ty in uncovered_tys { - if let Some(param) = uncovered_ty.walk() - .find(|t| is_possibly_remote_type(t, in_crate)) - { - debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); - return Err(OrphanCheckErr::UncoveredTy(param)); + if tcx.features().re_rebalance_coherence { + // Given impl Trait for T0, an impl is valid only + // if at least one of the following is true: + // + // - Trait is a local trait + // (already checked in orphan_check prior to calling this function) + // - All of + // - At least one of the types T0..=Tn must be a local type. + // Let Ti be the first such type. + // - No uncovered type parameters P1..=Pn may appear in T0..Ti (excluding Ti) + // + for input_ty in trait_ref.input_types() { + debug!("orphan_check_trait_ref: check ty `{:?}`", input_ty); + if ty_is_local(tcx, input_ty, in_crate) { + debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); + return Ok(()); + } else if is_uncovered_ty(input_ty) { + debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty); + return Err(OrphanCheckErr::UncoveredTy(input_ty)) + } + } + // If we exit above loop, never found a local type. + debug!("orphan_check_trait_ref: no local type"); + Err(OrphanCheckErr::NoLocalInputType) + } else { + // First, create an ordered iterator over all the type parameters to the trait, with the self + // type appearing first. + // Find the first input type that either references a type parameter OR + // some local type. + for input_ty in trait_ref.input_types() { + if ty_is_local(tcx, input_ty, in_crate) { + debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); + + // First local input type. Check that there are no + // uncovered type parameters. + let uncovered_tys = uncovered_tys(tcx, input_ty, in_crate); + for uncovered_ty in uncovered_tys { + if let Some(param) = uncovered_ty.walk() + .find(|t| is_possibly_remote_type(t, in_crate)) + { + debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); + return Err(OrphanCheckErr::UncoveredTy(param)); + } } + + // OK, found local type, all prior types upheld invariant. + return Ok(()); } - // OK, found local type, all prior types upheld invariant. - return Ok(()); + // Otherwise, enforce invariant that there are no type + // parameters reachable. + if let Some(param) = input_ty.walk() + .find(|t| is_possibly_remote_type(t, in_crate)) + { + debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); + return Err(OrphanCheckErr::UncoveredTy(param)); + } + } + // If we exit above loop, never found a local type. + debug!("orphan_check_trait_ref: no local type"); + Err(OrphanCheckErr::NoLocalInputType) + } +} + +fn is_uncovered_ty(ty: Ty<'_>) -> bool { + match ty.sty { + ty::Bool | + ty::Char | + ty::Int(..) | + ty::Uint(..) | + ty::Float(..) | + ty::Str | + ty::FnDef(..) | + ty::FnPtr(_) | + ty::Array(..) | + ty::Slice(..) | + ty::RawPtr(..) | + ty::Ref(..) | + ty::Never | + ty::Tuple(..) | + ty::Bound(..) | + ty::Infer(..) | + ty::Adt(..) | + ty::Foreign(..) | + ty::Dynamic(..) | + ty::Error | + ty::Projection(..) => { + false + } + + ty::Param(..) => { + true } - // Otherwise, enforce invariant that there are no type - // parameters reachable. - if let Some(param) = input_ty.walk() - .find(|t| is_possibly_remote_type(t, in_crate)) - { - debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); - return Err(OrphanCheckErr::UncoveredTy(param)); + ty::UnnormalizedProjection(..) | + ty::Closure(..) | + ty::Generator(..) | + ty::GeneratorWitness(..) | + ty::Opaque(..) => { + bug!("is_uncovered_ty invoked on unexpected type: {:?}", ty) } } - - // If we exit above loop, never found a local type. - debug!("orphan_check_trait_ref: no local type"); - return Err(OrphanCheckErr::NoLocalInputType); } fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>, in_crate: InCrate) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 3f2122e24a642..8362c86f8bab9 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -479,6 +479,9 @@ declare_features! ( // Allows paths to enum variants on type aliases. (active, type_alias_enum_variants, "1.31.0", Some(49683), None), + + // Re-Rebalance coherence + (active, re_rebalance_coherence, "1.32.0", Some(55437), None), ); declare_features! ( From b8ee6fa7ef756c0684cad402b931e0b69232ce30 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Wed, 21 Nov 2018 21:35:56 +0100 Subject: [PATCH 16/58] Add some tests This copies and adjusts the existing coherence tests to ensure that they continue to work using the new implementation. --- .../auxiliary/coherence_copy_like_lib.rs | 20 +++++ .../auxiliary/coherence_lib.rs | 25 ++++++ .../auxiliary/re_rebalance_coherence_lib.rs | 23 +++++ .../coherence-bigint-int.rs | 25 ++++++ .../coherence-bigint-vecint.rs | 25 ++++++ .../coherence-blanket.rs | 27 ++++++ .../coherence-covered-type-parameter.rs | 25 ++++++ .../coherence-impl-in-fn.rs | 25 ++++++ .../coherence-iterator-vec-any-elem.rs | 25 ++++++ .../coherence-iterator-vec.rs | 25 ++++++ .../coherence-multidispatch-tuple.rs | 35 ++++++++ .../coherence-negative-impls-safe.rs | 24 +++++ .../coherence-rfc447-constrained.rs | 34 ++++++++ .../coherence-subtyping.rs | 51 +++++++++++ .../coherence-where-clause.rs | 49 +++++++++++ .../coherence_copy_like.rs | 31 +++++++ .../re-rebalance-coherence.rs | 13 +++ .../auxiliary/re_rebalance_coherence_lib.rs | 23 +++++ .../feature-gate-re-rebalance-coherence.rs | 13 +++ ...feature-gate-re-rebalance-coherence.stderr | 11 +++ .../auxiliary/coherence_copy_like_lib.rs | 20 +++++ .../auxiliary/coherence_inherent_cc_lib.rs | 21 +++++ .../auxiliary/coherence_lib.rs | 25 ++++++ .../auxiliary/coherence_orphan_lib.rs | 13 +++ .../auxiliary/go_trait.rs | 53 +++++++++++ .../auxiliary/trait_impl_conflict.rs | 16 ++++ .../coherence-all-remote.rs | 21 +++++ .../coherence-all-remote.stderr | 11 +++ .../coherence-bigint-param.rs | 23 +++++ .../coherence-bigint-param.stderr | 11 +++ ...nket-conflicts-with-blanket-implemented.rs | 40 +++++++++ ...-conflicts-with-blanket-implemented.stderr | 12 +++ ...et-conflicts-with-blanket-unimplemented.rs | 36 ++++++++ ...onflicts-with-blanket-unimplemented.stderr | 12 +++ ...ket-conflicts-with-specific-cross-crate.rs | 31 +++++++ ...conflicts-with-specific-cross-crate.stderr | 13 +++ ...t-conflicts-with-specific-multidispatch.rs | 38 ++++++++ ...nflicts-with-specific-multidispatch.stderr | 12 +++ ...e-blanket-conflicts-with-specific-trait.rs | 40 +++++++++ ...anket-conflicts-with-specific-trait.stderr | 12 +++ ...herence-blanket-conflicts-with-specific.rs | 35 ++++++++ ...nce-blanket-conflicts-with-specific.stderr | 12 +++ ...herence-conflicting-negative-trait-impl.rs | 29 +++++++ ...nce-conflicting-negative-trait-impl.stderr | 21 +++++ .../coherence-cow.a.stderr | 12 +++ .../coherence-cow.b.stderr | 12 +++ .../coherence-cow.c.stderr | 12 +++ .../re_rebalance_coherence/coherence-cow.rs | 37 ++++++++ .../coherence-cross-crate-conflict.rs | 26 ++++++ .../coherence-cross-crate-conflict.stderr | 21 +++++ .../coherence-default-trait-impl.rs | 26 ++++++ .../coherence-default-trait-impl.stderr | 16 ++++ .../coherence-error-suppression.rs | 27 ++++++ .../coherence-error-suppression.stderr | 9 ++ ...erence-impl-trait-for-trait-object-safe.rs | 21 +++++ ...ce-impl-trait-for-trait-object-safe.stderr | 11 +++ .../coherence-impl-trait-for-trait.rs | 29 +++++++ .../coherence-impl-trait-for-trait.stderr | 21 +++++ .../coherence-impls-copy.rs | 54 ++++++++++++ .../coherence-impls-copy.stderr | 87 +++++++++++++++++++ .../coherence-impls-send.rs | 41 +++++++++ .../coherence-impls-send.stderr | 37 ++++++++ .../coherence-impls-sized.rs | 47 ++++++++++ .../coherence-impls-sized.stderr | 67 ++++++++++++++ .../coherence-inherited-assoc-ty-cycle-err.rs | 35 ++++++++ ...erence-inherited-assoc-ty-cycle-err.stderr | 16 ++++ .../coherence-lone-type-parameter.rs | 21 +++++ .../coherence-lone-type-parameter.stderr | 11 +++ .../coherence-negative-impls-safe.rs | 21 +++++ .../coherence-negative-impls-safe.stderr | 9 ++ .../coherence-no-direct-lifetime-dispatch.rs | 20 +++++ ...herence-no-direct-lifetime-dispatch.stderr | 11 +++ .../coherence-orphan.rs | 32 +++++++ .../coherence-orphan.stderr | 21 +++++ .../coherence-overlap-all-t-and-tuple.rs | 31 +++++++ .../coherence-overlap-all-t-and-tuple.stderr | 12 +++ .../coherence-overlap-downstream-inherent.rs | 29 +++++++ ...herence-overlap-downstream-inherent.stderr | 23 +++++ .../coherence-overlap-downstream.rs | 29 +++++++ .../coherence-overlap-downstream.stderr | 21 +++++ .../coherence-overlap-issue-23516-inherent.rs | 25 ++++++ ...erence-overlap-issue-23516-inherent.stderr | 14 +++ .../coherence-overlap-issue-23516.rs | 23 +++++ .../coherence-overlap-issue-23516.stderr | 13 +++ .../coherence-overlap-messages.rs | 34 ++++++++ .../coherence-overlap-messages.stderr | 44 ++++++++++ .../coherence-overlap-upstream-inherent.rs | 27 ++++++ ...coherence-overlap-upstream-inherent.stderr | 14 +++ .../coherence-overlap-upstream.rs | 27 ++++++ .../coherence-overlap-upstream.stderr | 13 +++ .../coherence-overlapping-pairs.rs | 23 +++++ .../coherence-overlapping-pairs.stderr | 12 +++ .../coherence-pair-covered-uncovered-1.rs | 25 ++++++ .../coherence-pair-covered-uncovered-1.stderr | 12 +++ .../coherence-pair-covered-uncovered.rs | 23 +++++ .../coherence-pair-covered-uncovered.stderr | 12 +++ .../coherence-projection-conflict-orphan.rs | 29 +++++++ ...oherence-projection-conflict-orphan.stderr | 14 +++ .../coherence-projection-conflict-ty-param.rs | 24 +++++ ...erence-projection-conflict-ty-param.stderr | 12 +++ .../coherence-projection-conflict.rs | 29 +++++++ .../coherence-projection-conflict.stderr | 12 +++ .../coherence-projection-ok-orphan.rs | 30 +++++++ .../coherence-projection-ok.rs | 30 +++++++ .../coherence-tuple-conflict.rs | 31 +++++++ .../coherence-tuple-conflict.stderr | 12 +++ .../coherence-vec-local-2.rs | 25 ++++++ .../coherence-vec-local-2.stderr | 12 +++ .../coherence-vec-local.rs | 25 ++++++ .../coherence-vec-local.stderr | 12 +++ ...erence_copy_like_err_fundamental_struct.rs | 35 ++++++++ ...ce_copy_like_err_fundamental_struct_ref.rs | 35 ++++++++ ..._copy_like_err_fundamental_struct_tuple.rs | 32 +++++++ ...y_like_err_fundamental_struct_tuple.stderr | 14 +++ .../coherence_copy_like_err_struct.rs | 33 +++++++ .../coherence_copy_like_err_struct.stderr | 14 +++ .../coherence_copy_like_err_tuple.rs | 32 +++++++ .../coherence_copy_like_err_tuple.stderr | 14 +++ .../coherence_inherent.rs | 47 ++++++++++ .../coherence_inherent.stderr | 13 +++ .../coherence_inherent_cc.rs | 39 +++++++++ .../coherence_inherent_cc.stderr | 13 +++ .../re_rebalance_coherence/coherence_local.rs | 34 ++++++++ .../coherence_local_err_struct.rs | 29 +++++++ .../coherence_local_err_struct.stderr | 12 +++ .../coherence_local_err_tuple.rs | 29 +++++++ .../coherence_local_err_tuple.stderr | 12 +++ .../coherence_local_ref.rs | 28 ++++++ 128 files changed, 3144 insertions(+) create mode 100644 src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/auxiliary/re_rebalance_coherence_lib.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs create mode 100644 src/test/run-pass/re_rebalance_coherence/re-rebalance-coherence.rs create mode 100644 src/test/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs create mode 100644 src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs create mode 100644 src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr create mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs create mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.rs create mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs create mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs create mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs create mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-all-remote.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-send.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-orphan.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-orphan.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_local.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs create mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr create mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_ref.rs diff --git a/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs b/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs new file mode 100644 index 0000000000000..d3d389c6a8bd5 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(fundamental)] + +pub trait MyCopy { } +impl MyCopy for i32 { } + +pub struct MyStruct(T); + +#[fundamental] +pub struct MyFundamentalStruct(T); diff --git a/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs b/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs new file mode 100644 index 0000000000000..daa123849e4e7 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub trait Remote { + fn foo(&self) { } +} + +pub trait Remote1 { + fn foo(&self, t: T) { } +} + +pub trait Remote2 { + fn foo(&self, t: T, u: U) { } +} + +pub struct Pair(T,U); diff --git a/src/test/run-pass/re_rebalance_coherence/auxiliary/re_rebalance_coherence_lib.rs b/src/test/run-pass/re_rebalance_coherence/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 0000000000000..c8d027b25c748 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/auxiliary/re_rebalance_coherence_lib.rs @@ -0,0 +1,23 @@ + +pub trait Backend{} +pub trait SupportsDefaultKeyword {} + +impl SupportsDefaultKeyword for Postgres {} + +pub struct Postgres; + +impl Backend for Postgres {} + +pub struct AstPass(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[derive(Debug, Clone, Copy)] +pub struct BatchInsert<'a, T: 'a, Tab> { + _marker: ::std::marker::PhantomData<(&'a T, Tab)>, +} + +impl<'a, T:'a, Tab, DB> QueryFragment for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs b/src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs new file mode 100644 index 0000000000000..c436901a34f08 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// run-pass +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub struct BigInt; + +impl Remote1 for isize { } + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs b/src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs new file mode 100644 index 0000000000000..67fb9d1d335cb --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// run-pass +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub struct BigInt; + +impl Remote1 for Vec { } + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs b/src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs new file mode 100644 index 0000000000000..7f8f27f39b1b1 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![feature(re_rebalance_coherence)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub trait Local { + fn foo(&self) { } +} + +impl Local for T { } + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs b/src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs new file mode 100644 index 0000000000000..5e0d61884f917 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Foo(T); + +impl Remote for Foo { } + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs b/src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs new file mode 100644 index 0000000000000..2f8cbc032f2fb --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs @@ -0,0 +1,25 @@ +// 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. + +// run-pass +#![allow(dead_code)] +#![allow(non_camel_case_types)] +#![feature(re_rebalance_coherence)] + +pub fn main() { + #[derive(Copy, Clone)] + enum x { foo } + impl ::std::cmp::PartialEq for x { + fn eq(&self, other: &x) -> bool { + (*self) as isize == (*other) as isize + } + fn ne(&self, other: &x) -> bool { !(*self).eq(other) } + } +} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs b/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs new file mode 100644 index 0000000000000..b19bede744106 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +struct Foo(T); + +impl Remote1 for Foo { } + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs b/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs new file mode 100644 index 0000000000000..5ce71f5d42273 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] +// aux-build:coherence_lib.rs + +// pretty-expanded FIXME #23616 + +extern crate coherence_lib as lib; +use lib::Remote1; + +struct Foo(T); + +impl Remote1 for Foo { } + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs b/src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs new file mode 100644 index 0000000000000..6dc1da3376b15 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(unused_imports)] +#![feature(re_rebalance_coherence)] +// pretty-expanded FIXME #23616 + +use std::fmt::Debug; +use std::default::Default; + +// Test that an impl for homogeneous pairs does not conflict with a +// heterogeneous pair. + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for (T,T) { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for (usize,isize) { + fn get(&self) -> usize { 0 } +} + +fn main() { +} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs b/src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs new file mode 100644 index 0000000000000..5e1a0e39e234e --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs @@ -0,0 +1,24 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +// pretty-expanded FIXME #23616 + +#![feature(optin_builtin_traits)] +#![feature(re_rebalance_coherence)] + +use std::marker::Send; + +struct TestType; + +impl !Send for TestType {} + +fn main() {} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs b/src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs new file mode 100644 index 0000000000000..651e595bde120 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// run-pass +// check that trait matching can handle impls whose types are only +// constrained by a projection. + +trait IsU32 {} +impl IsU32 for u32 {} + +trait Mirror { type Image: ?Sized; } +impl Mirror for T { type Image = T; } + +trait Bar {} +impl, L: Mirror> Bar for V + where U::Image: IsU32 {} + +trait Foo { fn name() -> &'static str; } +impl Foo for u64 { fn name() -> &'static str { "u64" } } +impl Foo for T { fn name() -> &'static str { "Bar" }} + +fn main() { + assert_eq!(::name(), "u64"); + assert_eq!(::name(), "Bar"); +} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs b/src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs new file mode 100644 index 0000000000000..d9a9f580cfaf6 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs @@ -0,0 +1,51 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// run-pass +// Test that two distinct impls which match subtypes of one another +// yield coherence errors (or not) depending on the variance. + +trait Contravariant { + fn foo(&self) { } +} + +impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { +} + +impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { +} + +/////////////////////////////////////////////////////////////////////////// + +trait Covariant { + fn foo(&self) { } +} + +impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { +} + +impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { +} + +/////////////////////////////////////////////////////////////////////////// + +trait Invariant { + fn foo(&self) { } +} + +impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { +} + +impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { +} + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs b/src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs new file mode 100644 index 0000000000000..a7d3602a3cc6b --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs @@ -0,0 +1,49 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// run-pass +use std::fmt::Debug; +use std::default::Default; + +trait MyTrait { + fn get(&self) -> Self; +} + +impl MyTrait for T + where T : Default +{ + fn get(&self) -> T { + Default::default() + } +} + +#[derive(Clone, Copy, Debug, PartialEq)] +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { + fn get(&self) -> MyType { (*self).clone() } +} + +fn test_eq(m: M, n: M) +where M : MyTrait + Debug + PartialEq +{ + assert_eq!(m.get(), n); +} + +pub fn main() { + test_eq(0_usize, 0_usize); + + let value = MyType { dummy: 256 + 22 }; + test_eq(value, value); +} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs b/src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs new file mode 100644 index 0000000000000..221095b148e0c --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { } +impl MyTrait for T { } +impl MyTrait for MyType { } +impl<'a> MyTrait for &'a MyType { } +impl MyTrait for Box { } +impl<'a> MyTrait for &'a Box { } + +fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/re-rebalance-coherence.rs b/src/test/run-pass/re_rebalance_coherence/re-rebalance-coherence.rs new file mode 100644 index 0000000000000..33ad4e9753661 --- /dev/null +++ b/src/test/run-pass/re_rebalance_coherence/re-rebalance-coherence.rs @@ -0,0 +1,13 @@ +#![feature(re_rebalance_coherence)] + +// run-pass +// aux-build:re_rebalance_coherence_lib.rs + +extern crate re_rebalance_coherence_lib as lib; +use lib::*; + +struct Oracle; +impl Backend for Oracle {} +impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} + +fn main() {} diff --git a/src/test/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs b/src/test/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 0000000000000..c8d027b25c748 --- /dev/null +++ b/src/test/ui/feature-gates/auxiliary/re_rebalance_coherence_lib.rs @@ -0,0 +1,23 @@ + +pub trait Backend{} +pub trait SupportsDefaultKeyword {} + +impl SupportsDefaultKeyword for Postgres {} + +pub struct Postgres; + +impl Backend for Postgres {} + +pub struct AstPass(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[derive(Debug, Clone, Copy)] +pub struct BatchInsert<'a, T: 'a, Tab> { + _marker: ::std::marker::PhantomData<(&'a T, Tab)>, +} + +impl<'a, T:'a, Tab, DB> QueryFragment for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs new file mode 100644 index 0000000000000..7031e6061edd3 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs @@ -0,0 +1,13 @@ +// Test that the use of the box syntax is gated by `box_syntax` feature gate. + +// aux-build:re_rebalance_coherence_lib.rs + +extern crate re_rebalance_coherence_lib as lib; +use lib::*; + +struct Oracle; +impl Backend for Oracle {} +impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} +// ~^ ERROR E0210 + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr new file mode 100644 index 0000000000000..7a79d0b1f2a63 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/feature-gate-re-rebalance-coherence.rs:10:1 + | +LL | impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs new file mode 100644 index 0000000000000..d3d389c6a8bd5 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(fundamental)] + +pub trait MyCopy { } +impl MyCopy for i32 { } + +pub struct MyStruct(T); + +#[fundamental] +pub struct MyFundamentalStruct(T); diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.rs new file mode 100644 index 0000000000000..0458636a401ef --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.rs @@ -0,0 +1,21 @@ +// 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. + +// See coherence_inherent_cc.rs + +pub trait TheTrait { + fn the_fn(&self); +} + +pub struct TheStruct; + +impl TheTrait for TheStruct { + fn the_fn(&self) {} +} diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs new file mode 100644 index 0000000000000..daa123849e4e7 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type="lib"] + +pub trait Remote { + fn foo(&self) { } +} + +pub trait Remote1 { + fn foo(&self, t: T) { } +} + +pub trait Remote2 { + fn foo(&self, t: T, u: U) { } +} + +pub struct Pair(T,U); diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs new file mode 100644 index 0000000000000..b22d12300c7d1 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait TheTrait { + fn the_fn(&self); +} diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs b/src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs new file mode 100644 index 0000000000000..044bb606b40e2 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs @@ -0,0 +1,53 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(specialization)] + +// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. + +pub trait Go { + fn go(&self, arg: isize); +} + +pub fn go(this: &G, arg: isize) { + this.go(arg) +} + +pub trait GoMut { + fn go_mut(&mut self, arg: isize); +} + +pub fn go_mut(this: &mut G, arg: isize) { + this.go_mut(arg) +} + +pub trait GoOnce { + fn go_once(self, arg: isize); +} + +pub fn go_once(this: G, arg: isize) { + this.go_once(arg) +} + +impl GoMut for G + where G : Go +{ + default fn go_mut(&mut self, arg: isize) { + go(&*self, arg) + } +} + +impl GoOnce for G + where G : GoMut +{ + default fn go_once(mut self, arg: isize) { + go_mut(&mut self, arg) + } +} diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs b/src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs new file mode 100644 index 0000000000000..3190ce430ad67 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs @@ -0,0 +1,16 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait Foo { + fn foo() {} +} + +impl Foo for isize { +} diff --git a/src/test/ui/re_rebalance_coherence/coherence-all-remote.rs b/src/test/ui/re_rebalance_coherence/coherence-all-remote.rs new file mode 100644 index 0000000000000..0769518b36beb --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-all-remote.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_lib.rs + +#![feature(re_rebalance_coherence)] + +extern crate coherence_lib as lib; +use lib::Remote1; + +impl Remote1 for isize { } +//~^ ERROR E0210 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr b/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr new file mode 100644 index 0000000000000..a6d5105cdc0ea --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-all-remote.rs:18:1 + | +LL | impl Remote1 for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs new file mode 100644 index 0000000000000..712fe9bdb4c75 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote1; + +pub struct BigInt; + +impl Remote1 for T { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr new file mode 100644 index 0000000000000..ed1540a303e68 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-bigint-param.rs:20:1 + | +LL | impl Remote1 for T { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs new file mode 100644 index 0000000000000..da0221c3e0af1 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +use std::fmt::Debug; +use std::default::Default; + +// Test that two blanket impls conflict (at least without negative +// bounds). After all, some other crate could implement Even or Odd +// for the same type (though this crate doesn't). + +trait MyTrait { + fn get(&self) -> usize; +} + +trait Even { } + +trait Odd { } + +impl Even for isize { } + +impl Odd for usize { } + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for T { //~ ERROR E0119 + fn get(&self) -> usize { 0 } +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr new file mode 100644 index 0000000000000..8d5d478778075 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:36:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs new file mode 100644 index 0000000000000..5e407588e2aff --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs @@ -0,0 +1,36 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +use std::fmt::Debug; +use std::default::Default; + +// Test that two blanket impls conflict (at least without negative +// bounds). After all, some other crate could implement Even or Odd +// for the same type (though this crate doesn't implement them at all). + +trait MyTrait { + fn get(&self) -> usize; +} + +trait Even {} + +trait Odd {} + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for T { //~ ERROR E0119 + fn get(&self) -> usize { 0 } +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr new file mode 100644 index 0000000000000..6e7df5e6ed3bf --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:32:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs new file mode 100644 index 0000000000000..9d1caf929222e --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// aux-build:go_trait.rs + +extern crate go_trait; + +use go_trait::{Go,GoMut}; +use std::fmt::Debug; +use std::default::Default; + +struct MyThingy; + +impl Go for MyThingy { + fn go(&self, arg: isize) { } +} + +impl GoMut for MyThingy { //~ ERROR conflicting implementations + fn go_mut(&mut self, arg: isize) { } +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr new file mode 100644 index 0000000000000..30656fa41b4f8 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`: + --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:27:1 + | +LL | impl GoMut for MyThingy { //~ ERROR conflicting implementations + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `go_trait`: + - impl go_trait::GoMut for G + where G: go_trait::Go; + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs new file mode 100644 index 0000000000000..f866465bd081d --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +use std::fmt::Debug; +use std::default::Default; + +// Test that a blank impl for all T conflicts with an impl for some +// specific T, even when there are multiple type parameters involved. + +trait MyTrait { + fn get(&self) -> T; +} + +impl MyTrait for T { + fn get(&self) -> T { + panic!() + } +} + +#[derive(Clone)] +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { //~ ERROR E0119 + fn get(&self) -> usize { (*self).clone() } +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr new file mode 100644 index 0000000000000..f68e1fd94f0c2 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:34:1 + | +LL | impl MyTrait for T { + | ------------------------ first implementation here +... +LL | impl MyTrait for MyType { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs new file mode 100644 index 0000000000000..74b458b838e04 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs @@ -0,0 +1,40 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that a blank impl for all T:PartialEq conflicts with an impl for some +// specific T when T:PartialEq. + +trait OtherTrait { + fn noop(&self); +} + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { //~ ERROR E0119 + fn get(&self) -> usize { self.dummy } +} + +impl OtherTrait for MyType { + fn noop(&self) { } +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr new file mode 100644 index 0000000000000..bafeadcfcbefb --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:32:1 + | +LL | impl MyTrait for T { + | -------------------------------- first implementation here +... +LL | impl MyTrait for MyType { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs new file mode 100644 index 0000000000000..51de0e33034c8 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs @@ -0,0 +1,35 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +use std::fmt::Debug; +use std::default::Default; + +// Test that a blank impl for all T conflicts with an impl for some +// specific T. + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for T { + fn get(&self) -> usize { 0 } +} + +struct MyType { + dummy: usize +} + +impl MyTrait for MyType { //~ ERROR E0119 + fn get(&self) -> usize { self.dummy } +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr new file mode 100644 index 0000000000000..efc32d1236402 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific.rs:31:1 + | +LL | impl MyTrait for T { + | --------------------- first implementation here +... +LL | impl MyTrait for MyType { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs b/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs new file mode 100644 index 0000000000000..c2db97c68e8ec --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs @@ -0,0 +1,29 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(overlapping_marker_traits)] +#![feature(re_rebalance_coherence)] + +trait MyTrait {} + +struct TestType(::std::marker::PhantomData); + +unsafe impl Send for TestType {} + +impl !Send for TestType {} +//~^ ERROR conflicting implementations of trait `std::marker::Send` + +unsafe impl Send for TestType {} + +impl !Send for TestType {} +//~^ ERROR conflicting implementations of trait `std::marker::Send` + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr b/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr new file mode 100644 index 0000000000000..7555e9996cf29 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:21:1 + | +LL | unsafe impl Send for TestType {} + | ---------------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` + +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:26:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr b/src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr new file mode 100644 index 0000000000000..09cc9801c14a1 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:28:1 + | +LL | impl Remote for Pair> { } //[a]~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr b/src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr new file mode 100644 index 0000000000000..7bb8378ee4ba8 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:31:1 + | +LL | impl Remote for Pair,T> { } //[b]~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr b/src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr new file mode 100644 index 0000000000000..6dbf0a44f02b8 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:34:1 + | +LL | impl Remote for Pair,U> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.rs b/src/test/ui/re_rebalance_coherence/coherence-cow.rs new file mode 100644 index 0000000000000..da69d56a25a56 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-cow.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// revisions: a b c + +// aux-build:coherence_lib.rs + +// Test that the `Pair` type reports an error if it contains type +// parameters, even when they are covered by local types. This test +// was originally intended to test the opposite, but the rules changed +// with RFC 1023 and this became illegal. + +extern crate coherence_lib as lib; +use lib::{Remote,Pair}; + +pub struct Cover(T); + +#[cfg(a)] +impl Remote for Pair> { } //[a]~ ERROR E0117 + +#[cfg(b)] +impl Remote for Pair,T> { } //[b]~ ERROR E0117 + +#[cfg(c)] +impl Remote for Pair,U> { } +//[c]~^ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs new file mode 100644 index 0000000000000..02624c70dc9d8 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// The error here is strictly due to orphan rules; the impl here +// generalizes the one upstream + +// aux-build:trait_impl_conflict.rs +extern crate trait_impl_conflict; +use trait_impl_conflict::Foo; + +impl Foo for A { + //~^ ERROR type parameter `A` must be used as the type parameter for some local type + //~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` +} + +fn main() { +} diff --git a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr new file mode 100644 index 0000000000000..e4f8ba9868e4e --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`: + --> $DIR/coherence-cross-crate-conflict.rs:20:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `trait_impl_conflict`: + - impl trait_impl_conflict::Foo for isize; + +error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-cross-crate-conflict.rs:20:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to 2 previous errors + +Some errors occurred: E0119, E0210. +For more information about an error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs b/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs new file mode 100644 index 0000000000000..86dd0e4f74fbd --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs @@ -0,0 +1,26 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(re_rebalance_coherence)] + +auto trait MySafeTrait {} + +struct Foo; + +unsafe impl MySafeTrait for Foo {} +//~^ ERROR implementing the trait `MySafeTrait` is not unsafe + +unsafe auto trait MyUnsafeTrait {} + +impl MyUnsafeTrait for Foo {} +//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr b/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr new file mode 100644 index 0000000000000..6c3d79cf53c1c --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr @@ -0,0 +1,16 @@ +error[E0199]: implementing the trait `MySafeTrait` is not unsafe + --> $DIR/coherence-default-trait-impl.rs:18:1 + | +LL | unsafe impl MySafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration + --> $DIR/coherence-default-trait-impl.rs:23:1 + | +LL | impl MyUnsafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0199, E0200. +For more information about an error, try `rustc --explain E0199`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs b/src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs new file mode 100644 index 0000000000000..24df1a1ee01f8 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// check that error types in coherence do not cause error cascades. + +trait Foo {} + +impl Foo for i8 {} +impl Foo for i16 {} +impl Foo for i32 {} +impl Foo for i64 {} +impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope +impl Foo for u8 {} +impl Foo for u16 {} +impl Foo for u32 {} +impl Foo for u64 {} + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr b/src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr new file mode 100644 index 0000000000000..97ed46c71bd53 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `DoesNotExist` in this scope + --> $DIR/coherence-error-suppression.rs:21:14 + | +LL | impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope + | ^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs new file mode 100644 index 0000000000000..9e9a00af903dd --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that we give suitable error messages when the user attempts to +// impl a trait `Trait` for its own object type. + +// If the trait is not object-safe, we give a more tailored message +// because we're such schnuckels: +trait NotObjectSafe { fn eq(&self, other: Self); } +impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr new file mode 100644 index 0000000000000..0f4f33e4eb9a8 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `NotObjectSafe` cannot be made into an object + --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:19:6 + | +LL | impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 + | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object + | + = note: method `eq` references the `Self` type in its arguments or return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs new file mode 100644 index 0000000000000..0ed88058f1fb0 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that we give suitable error messages when the user attempts to +// impl a trait `Trait` for its own object type. + +trait Foo { fn dummy(&self) { } } +trait Bar: Foo { } +trait Baz: Bar { } + +// Supertraits of Baz are not legal: +impl Foo for Baz { } //~ ERROR E0371 +impl Bar for Baz { } //~ ERROR E0371 +impl Baz for Baz { } //~ ERROR E0371 + +// But other random traits are: +trait Other { } +impl Other for Baz { } // OK, Other not a supertrait of Baz + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr new file mode 100644 index 0000000000000..d529e86f8fc01 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr @@ -0,0 +1,21 @@ +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` + --> $DIR/coherence-impl-trait-for-trait.rs:21:1 + | +LL | impl Foo for Baz { } //~ ERROR E0371 + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` + --> $DIR/coherence-impl-trait-for-trait.rs:22:1 + | +LL | impl Bar for Baz { } //~ ERROR E0371 + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` + --> $DIR/coherence-impl-trait-for-trait.rs:23:1 + | +LL | impl Baz for Baz { } //~ ERROR E0371 + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0371`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs b/src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs new file mode 100644 index 0000000000000..9f58d13efc2a4 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs @@ -0,0 +1,54 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(re_rebalance_coherence)] + +use std::marker::Copy; + +impl Copy for i32 {} +//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`: +//~| ERROR only traits defined in the current crate can be implemented for arbitrary types + +enum TestE { + A +} + +struct MyType; + +struct NotSync; +impl !Sync for NotSync {} + +impl Copy for TestE {} +impl Clone for TestE { fn clone(&self) -> Self { *self } } + +impl Copy for MyType {} + +impl Copy for &'static mut MyType {} +//~^ ERROR the trait `Copy` may not be implemented for this type +impl Clone for MyType { fn clone(&self) -> Self { *self } } + +impl Copy for (MyType, MyType) {} +//~^ ERROR the trait `Copy` may not be implemented for this type +//~| ERROR only traits defined in the current crate can be implemented for arbitrary types + +impl Copy for &'static NotSync {} +//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: + +impl Copy for [MyType] {} +//~^ ERROR the trait `Copy` may not be implemented for this type +//~| ERROR only traits defined in the current crate can be implemented for arbitrary types + +impl Copy for &'static [NotSync] {} +//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: +//~| ERROR only traits defined in the current crate can be implemented for arbitrary types + +fn main() { +} diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr b/src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr new file mode 100644 index 0000000000000..80e2d203aaaab --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr @@ -0,0 +1,87 @@ +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`: + --> $DIR/coherence-impls-copy.rs:16:1 + | +LL | impl Copy for i32 {} + | ^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for i32; + +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: + --> $DIR/coherence-impls-copy.rs:42:1 + | +LL | impl Copy for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for &T + where T: ?Sized; + +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: + --> $DIR/coherence-impls-copy.rs:49:1 + | +LL | impl Copy for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for &T + where T: ?Sized; + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:34:15 + | +LL | impl Copy for &'static mut MyType {} + | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:38:15 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:45:15 + | +LL | impl Copy for [MyType] {} + | ^^^^^^^^ type is not a structure or enumeration + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:16:1 + | +LL | impl Copy for i32 {} + | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:38:1 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:45:1 + | +LL | impl Copy for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:49:1 + | +LL | impl Copy for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 10 previous errors + +Some errors occurred: E0117, E0119, E0206. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-send.rs b/src/test/ui/re_rebalance_coherence/coherence-impls-send.rs new file mode 100644 index 0000000000000..11b92d5254c44 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impls-send.rs @@ -0,0 +1,41 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(overlapping_marker_traits)] +#![feature(re_rebalance_coherence)] + +use std::marker::Copy; + +enum TestE { + A +} + +struct MyType; + +struct NotSync; +impl !Sync for NotSync {} + +unsafe impl Send for TestE {} +unsafe impl Send for MyType {} +unsafe impl Send for (MyType, MyType) {} +//~^ ERROR E0117 + +unsafe impl Send for &'static NotSync {} +//~^ ERROR E0321 + +unsafe impl Send for [MyType] {} +//~^ ERROR E0117 + +unsafe impl Send for &'static [NotSync] {} +//~^ ERROR E0117 + +fn main() { +} diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr b/src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr new file mode 100644 index 0000000000000..8f09deeeb9303 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr @@ -0,0 +1,37 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:28:1 + | +LL | unsafe impl Send for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` + --> $DIR/coherence-impls-send.rs:31:1 + | +LL | unsafe impl Send for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:34:1 + | +LL | unsafe impl Send for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:37:1 + | +LL | unsafe impl Send for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 4 previous errors + +Some errors occurred: E0117, E0321. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs b/src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs new file mode 100644 index 0000000000000..3f7970f34fc5e --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs @@ -0,0 +1,47 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(re_rebalance_coherence)] + +use std::marker::Copy; + +enum TestE { + A +} + +struct MyType; + +struct NotSync; +impl !Sync for NotSync {} + +impl Sized for TestE {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed + +impl Sized for MyType {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed + +impl Sized for (MyType, MyType) {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed +//~| ERROR E0117 + +impl Sized for &'static NotSync {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed + +impl Sized for [MyType] {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed +//~| ERROR E0117 + +impl Sized for &'static [NotSync] {} //~ ERROR E0322 +//~^ impl of 'Sized' not allowed +//~| ERROR E0117 + +fn main() { +} diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr b/src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr new file mode 100644 index 0000000000000..92b165bdc3b74 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr @@ -0,0 +1,67 @@ +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:25:1 + | +LL | impl Sized for TestE {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:28:1 + | +LL | impl Sized for MyType {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:31:1 + | +LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:35:1 + | +LL | impl Sized for &'static NotSync {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:38:1 + | +LL | impl Sized for [MyType] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:42:1 + | +LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:31:1 + | +LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:38:1 + | +LL | impl Sized for [MyType] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:42:1 + | +LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 9 previous errors + +Some errors occurred: E0117, E0322. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs b/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs new file mode 100644 index 0000000000000..a2cfb11fdc234 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Formerly this ICEd with the following message: +// Tried to project an inherited associated type during coherence checking, +// which is currently not supported. +// +// No we expect to run into a more user-friendly cycle error instead. + +#![feature(specialization)] +#![feature(re_rebalance_coherence)] + +trait Trait { type Assoc; } +//~^ cycle detected + +impl Trait for Vec { + type Assoc = (); +} + +impl Trait for Vec {} + +impl Trait for String { + type Assoc = (); +} + +impl Trait< as Trait>::Assoc> for String {} + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr new file mode 100644 index 0000000000000..aca2d64b6231b --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr @@ -0,0 +1,16 @@ +error[E0391]: cycle detected when processing `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:20:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + | + = note: ...which again requires processing `Trait`, completing the cycle +note: cycle used when coherence checking all impls of trait `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:20:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs new file mode 100644 index 0000000000000..8d3551beb5fcd --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs @@ -0,0 +1,21 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +impl Remote for T { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr new file mode 100644 index 0000000000000..60ec7fb67defe --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) + --> $DIR/coherence-lone-type-parameter.rs:18:1 + | +LL | impl Remote for T { } + | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs b/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs new file mode 100644 index 0000000000000..40f7ebfd25025 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs @@ -0,0 +1,21 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(optin_builtin_traits)] +#![feature(re_rebalance_coherence)] + +use std::marker::Send; + +struct TestType; + +unsafe impl !Send for TestType {} +//~^ ERROR negative impls cannot be unsafe + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr b/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr new file mode 100644 index 0000000000000..70a879efa27c3 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr @@ -0,0 +1,9 @@ +error[E0198]: negative impls cannot be unsafe + --> $DIR/coherence-negative-impls-safe.rs:18:1 + | +LL | unsafe impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0198`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs b/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs new file mode 100644 index 0000000000000..838bc71d3afeb --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs @@ -0,0 +1,20 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that you cannot *directly* dispatch on lifetime requirements + +trait MyTrait { fn foo() {} } + +impl MyTrait for T {} +impl MyTrait for T {} //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr b/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr new file mode 100644 index 0000000000000..aa6427ba24f95 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-no-direct-lifetime-dispatch.rs:18:1 + | +LL | impl MyTrait for T {} + | --------------------- first implementation here +LL | impl MyTrait for T {} //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-orphan.rs b/src/test/ui/re_rebalance_coherence/coherence-orphan.rs new file mode 100644 index 0000000000000..dbe26a8898d4d --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-orphan.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:coherence_orphan_lib.rs + +#![feature(optin_builtin_traits)] +#![feature(re_rebalance_coherence)] + +extern crate coherence_orphan_lib as lib; + +use lib::TheTrait; + +struct TheType; + +impl TheTrait for isize { } +//~^ ERROR E0117 + +impl TheTrait for isize { } + +impl TheTrait for TheType { } + +impl !Send for Vec { } +//~^ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-orphan.stderr b/src/test/ui/re_rebalance_coherence/coherence-orphan.stderr new file mode 100644 index 0000000000000..6e5e734401f41 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-orphan.stderr @@ -0,0 +1,21 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:22:1 + | +LL | impl TheTrait for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:29:1 + | +LL | impl !Send for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs new file mode 100644 index 0000000000000..13604d9e4952a --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs @@ -0,0 +1,31 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Check that we detect an overlap here in the case where: +// +// for some type X: +// T = (X,) +// T11 = X, U11 = X +// +// Seems pretty basic, but then there was issue #24241. :) + +trait From { + fn foo() {} +} + +impl From for T { +} + +impl From<(U11,)> for (T11,) { //~ ERROR E0119 +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr new file mode 100644 index 0000000000000..dc052931ed14e --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`: + --> $DIR/coherence-overlap-all-t-and-tuple.rs:28:1 + | +LL | impl From for T { + | ---------------------- first implementation here +... +LL | impl From<(U11,)> for (T11,) { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs new file mode 100644 index 0000000000000..1f0ca50b60fca --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even +// though no impls are found. + +struct Sweet(X); +pub trait Sugar {} +pub trait Fruit {} +impl Sweet { fn dummy(&self) { } } +//~^ ERROR E0592 +impl Sweet { fn dummy(&self) { } } + +trait Bar {} +struct A(T, X); +impl A where T: Bar { fn f(&self) {} } +//~^ ERROR E0592 +impl A { fn f(&self) {} } + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr new file mode 100644 index 0000000000000..8a817fcb44067 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr @@ -0,0 +1,23 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-downstream-inherent.rs:19:26 + | +LL | impl Sweet { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +LL | //~^ ERROR E0592 +LL | impl Sweet { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + +error[E0592]: duplicate definitions with name `f` + --> $DIR/coherence-overlap-downstream-inherent.rs:25:38 + | +LL | impl A where T: Bar { fn f(&self) {} } + | ^^^^^^^^^^^^^^ duplicate definitions for `f` +LL | //~^ ERROR E0592 +LL | impl A { fn f(&self) {} } + | -------------- other definition for `f` + | + = note: downstream crates may implement trait `Bar<_>` for type `i32` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs new file mode 100644 index 0000000000000..7a2b28f49b549 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs @@ -0,0 +1,29 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even +// though no impls are found. + +pub trait Sugar {} +pub trait Fruit {} +pub trait Sweet {} +impl Sweet for T { } +impl Sweet for T { } +//~^ ERROR E0119 + +pub trait Foo {} +pub trait Bar {} +impl Foo for T where T: Bar {} +impl Foo for i32 {} +//~^ ERROR E0119 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr new file mode 100644 index 0000000000000..ce08ae15df131 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `Sweet`: + --> $DIR/coherence-overlap-downstream.rs:20:1 + | +LL | impl Sweet for T { } + | ------------------------- first implementation here +LL | impl Sweet for T { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`: + --> $DIR/coherence-overlap-downstream.rs:26:1 + | +LL | impl Foo for T where T: Bar {} + | --------------------------------------- first implementation here +LL | impl Foo for i32 {} + | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | + = note: downstream crates may implement trait `Bar<_>` for type `i32` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs new file mode 100644 index 0000000000000..ff6af49dfb2ef --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Tests that we consider `Box: !Sugar` to be ambiguous, even +// though we see no impl of `Sugar` for `Box`. Therefore, an overlap +// error is reported for the following pair of impls (#23516). + +pub trait Sugar {} + +struct Cake(X); + +impl Cake { fn dummy(&self) { } } +//~^ ERROR E0592 +impl Cake> { fn dummy(&self) { } } + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr new file mode 100644 index 0000000000000..26b59fbe71bd7 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr @@ -0,0 +1,14 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-issue-23516-inherent.rs:21:25 + | +LL | impl Cake { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +LL | //~^ ERROR E0592 +LL | impl Cake> { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + | + = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs new file mode 100644 index 0000000000000..2e45572e4eccd --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs @@ -0,0 +1,23 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Tests that we consider `Box: !Sugar` to be ambiguous, even +// though we see no impl of `Sugar` for `Box`. Therefore, an overlap +// error is reported for the following pair of impls (#23516). + +pub trait Sugar { fn dummy(&self) { } } +pub trait Sweet { fn dummy(&self) { } } +impl Sweet for T { } +impl Sweet for Box { } +//~^ ERROR E0119 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr new file mode 100644 index 0000000000000..9d3d564b8a91c --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>`: + --> $DIR/coherence-overlap-issue-23516.rs:20:1 + | +LL | impl Sweet for T { } + | ------------------------- first implementation here +LL | impl Sweet for Box { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>` + | + = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs new file mode 100644 index 0000000000000..1474fbd700c77 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +trait Foo { fn foo() {} } + +impl Foo for T {} +impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: + +trait Bar { fn bar() {} } + +impl Bar for (T, u8) {} +impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: + +trait Baz { fn baz() {} } + +impl Baz for T {} +impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: + +trait Quux { fn quux() {} } + +impl Quux for T {} +impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr new file mode 100644 index 0000000000000..c7b24e7bf6dee --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr @@ -0,0 +1,44 @@ +error[E0119]: conflicting implementations of trait `Foo`: + --> $DIR/coherence-overlap-messages.rs:16:1 + | +LL | impl Foo for T {} + | ----------------- first implementation here +LL | impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: + | ^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: + --> $DIR/coherence-overlap-messages.rs:21:1 + | +LL | impl Bar for (T, u8) {} + | ----------------------- first implementation here +LL | impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` + +error[E0119]: conflicting implementations of trait `Baz` for type `u8`: + --> $DIR/coherence-overlap-messages.rs:26:1 + | +LL | impl Baz for T {} + | --------------------- first implementation here +LL | impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:31:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:32:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs new file mode 100644 index 0000000000000..e802c0113ad82 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Tests that we consider `i16: Remote` to be ambiguous, even +// though the upstream crate doesn't implement it for now. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib; + +use coherence_lib::Remote; + +struct A(X); +impl A where T: Remote { fn dummy(&self) { } } +//~^ ERROR E0592 +impl A { fn dummy(&self) { } } + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr new file mode 100644 index 0000000000000..70b19ddb429a5 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr @@ -0,0 +1,14 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-upstream-inherent.rs:23:32 + | +LL | impl A where T: Remote { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +LL | //~^ ERROR E0592 +LL | impl A { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + | + = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs new file mode 100644 index 0000000000000..afbc69cac330f --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Tests that we consider `i16: Remote` to be ambiguous, even +// though the upstream crate doesn't implement it for now. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib; + +use coherence_lib::Remote; + +trait Foo {} +impl Foo for T where T: Remote {} +impl Foo for i16 {} +//~^ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr new file mode 100644 index 0000000000000..88bea02b34816 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i16`: + --> $DIR/coherence-overlap-upstream.rs:24:1 + | +LL | impl Foo for T where T: Remote {} + | --------------------------------- first implementation here +LL | impl Foo for i16 {} + | ^^^^^^^^^^^^^^^^ conflicting implementation for `i16` + | + = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs b/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs new file mode 100644 index 0000000000000..25d8e3197f42a --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Foo; + +impl Remote for lib::Pair { } +//~^ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr new file mode 100644 index 0000000000000..2629a017b7933 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-overlapping-pairs.rs:20:1 + | +LL | impl Remote for lib::Pair { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs new file mode 100644 index 0000000000000..4edfd5e122704 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that the same coverage rules apply even if the local type appears in the +// list of type parameters, not the self type. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::{Remote1, Pair}; + +pub struct Local(T); + +impl Remote1>> for i32 { } + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr new file mode 100644 index 0000000000000..197056746b9c5 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-pair-covered-uncovered-1.rs:23:1 + | +LL | impl Remote1>> for i32 { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs new file mode 100644 index 0000000000000..9b0d7177ffcce --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::{Remote, Pair}; + +struct Local(T); + +impl Remote for Pair> { } +//~^ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr new file mode 100644 index 0000000000000..b9e2eced94b18 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-pair-covered-uncovered.rs:20:1 + | +LL | impl Remote for Pair> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs new file mode 100644 index 0000000000000..e3f945504feba --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(rustc_attrs)] +#![feature(re_rebalance_coherence)] + +// Here we expect a coherence conflict because, even though `i32` does +// not implement `Iterator`, we cannot rely on that negative reasoning +// due to the orphan rules. Therefore, `A::Item` may yet turn out to +// be `i32`. + +pub trait Foo

{ fn foo() {} } + +pub trait Bar { + type Output: 'static; +} + +impl Foo for i32 { } + +impl Foo for A { } //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr new file mode 100644 index 0000000000000..81b1343837348 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict-orphan.rs:27:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | + = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs new file mode 100644 index 0000000000000..cb5c94a18a728 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Coherence error results because we do not know whether `T: Foo

` or not +// for the second impl. + +use std::marker::PhantomData; + +pub trait Foo

{ fn foo() {} } + +impl > Foo

for Option {} + +impl Foo for Option { } //~ ERROR E0119 + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr new file mode 100644 index 0000000000000..fe5a66ef9ea24 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`: + --> $DIR/coherence-projection-conflict-ty-param.rs:22:1 + | +LL | impl > Foo

for Option {} + | ---------------------------------------- first implementation here +LL | +LL | impl Foo for Option { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs new file mode 100644 index 0000000000000..73adba0819e69 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +use std::marker::PhantomData; + +pub trait Foo

{ fn foo() {} } + +pub trait Bar { + type Output: 'static; +} + +impl Foo for i32 { } + +impl Foo for A { } //~ ERROR E0119 + +impl Bar for i32 { + type Output = i32; +} + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr new file mode 100644 index 0000000000000..7f5ff3de17864 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict.rs:23:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs new file mode 100644 index 0000000000000..b02289dc68e52 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// skip-codegen +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] +// Here we do not get a coherence conflict because `Baz: Iterator` +// does not hold and (due to the orphan rules), we can rely on that. + +pub trait Foo

{} + +pub trait Bar { + type Output: 'static; +} + +struct Baz; +impl Foo for Baz { } + +impl Foo for A { } + + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs new file mode 100644 index 0000000000000..9c797b61a43b2 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// compile-pass +// skip-codegen +pub trait Foo

` or not // for the second impl. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::marker::PhantomData; pub trait Foo

{ fn foo() {} } impl > Foo

for Option {} -impl Foo for Option { } //~ ERROR E0119 +impl Foo for Option { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-projection-conflict.rs b/src/test/ui/coherence/coherence-projection-conflict.rs index 34f078f9a8c35..4086aeef8c03a 100644 --- a/src/test/ui/coherence/coherence-projection-conflict.rs +++ b/src/test/ui/coherence/coherence-projection-conflict.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::marker::PhantomData; pub trait Foo

{ fn foo() {} } @@ -8,7 +12,9 @@ pub trait Bar { impl Foo for i32 { } -impl Foo for A { } //~ ERROR E0119 +impl Foo for A { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 impl Bar for i32 { type Output = i32; diff --git a/src/test/ui/coherence/coherence-projection-ok-orphan.rs b/src/test/ui/coherence/coherence-projection-ok-orphan.rs index be7fbfbf1b6d8..652b438feb137 100644 --- a/src/test/ui/coherence/coherence-projection-ok-orphan.rs +++ b/src/test/ui/coherence/coherence-projection-ok-orphan.rs @@ -1,5 +1,8 @@ // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // Here we do not get a coherence conflict because `Baz: Iterator` // does not hold and (due to the orphan rules), we can rely on that. diff --git a/src/test/ui/coherence/coherence-projection-ok.rs b/src/test/ui/coherence/coherence-projection-ok.rs index 74d44eb14b5b5..f759a9e1b4508 100644 --- a/src/test/ui/coherence/coherence-projection-ok.rs +++ b/src/test/ui/coherence/coherence-projection-ok.rs @@ -1,5 +1,8 @@ // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] pub trait Foo

{} pub trait Bar { diff --git a/src/test/ui/coherence/coherence-tuple-conflict.rs b/src/test/ui/coherence/coherence-tuple-conflict.rs index bece87a9dd95f..130867b22428b 100644 --- a/src/test/ui/coherence/coherence-tuple-conflict.rs +++ b/src/test/ui/coherence/coherence-tuple-conflict.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -12,7 +16,9 @@ impl MyTrait for (T,T) { fn get(&self) -> usize { 0 } } -impl MyTrait for (A,B) { //~ ERROR E0119 +impl MyTrait for (A,B) { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { self.dummy } } diff --git a/src/test/ui/coherence/coherence-vec-local-2.rs b/src/test/ui/coherence/coherence-vec-local-2.rs index b77b1f2e05443..423543964c20b 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.rs +++ b/src/test/ui/coherence/coherence-vec-local-2.rs @@ -2,12 +2,17 @@ // *non-fundamental* remote type like `Vec` is not considered local. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; struct Local(T); -impl Remote for Vec> { } //~ ERROR E0210 +impl Remote for Vec> { } +//[old]~^ ERROR E0210 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-vec-local.rs b/src/test/ui/coherence/coherence-vec-local.rs index de12b43d485df..351ddd2aa6744 100644 --- a/src/test/ui/coherence/coherence-vec-local.rs +++ b/src/test/ui/coherence/coherence-vec-local.rs @@ -2,12 +2,17 @@ // *non-fundamental* remote type like `Vec` is not considered local. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; struct Local; -impl Remote for Vec { } //~ ERROR E0117 +impl Remote for Vec { } +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs index 205f5fd1c579d..a030314262270 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codgen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs index ac62310fab79d..bd8317e224699 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_ref.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs index a3a851f606f28..2a61042c6a03a 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.rs @@ -2,7 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_copy_like_lib as lib; @@ -14,7 +16,9 @@ trait MyTrait { fn foo() {} } impl MyTrait for T { } // Tuples are not fundamental. -impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 +impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence_copy_like_err_struct.rs b/src/test/ui/coherence/coherence_copy_like_err_struct.rs index f8c01b4e89eee..38fc2e662d71e 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_struct.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_struct.rs @@ -1,4 +1,7 @@ // aux-build:coherence_copy_like_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // Test that we are able to introduce a negative constraint that // `MyType: !MyTrait` along with other "fundamental" wrappers. @@ -16,6 +19,8 @@ impl MyTrait for T { } // MyStruct: !MyTrait // // which we cannot approve. -impl MyTrait for lib::MyStruct { } //~ ERROR E0119 +impl MyTrait for lib::MyStruct { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence_copy_like_err_tuple.rs b/src/test/ui/coherence/coherence_copy_like_err_tuple.rs index 791ea1640f9e7..7234bed1ba0d0 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_tuple.rs +++ b/src/test/ui/coherence/coherence_copy_like_err_tuple.rs @@ -2,6 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_copy_like_lib as lib; @@ -15,6 +18,8 @@ impl MyTrait for T { } // (MyType,): !MyTrait // // which we cannot approve. -impl MyTrait for (MyType,) { } //~ ERROR E0119 +impl MyTrait for (MyType,) { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence_inherent.rs b/src/test/ui/coherence/coherence_inherent.rs index f77f84bbb0c50..f0d3682adb8ca 100644 --- a/src/test/ui/coherence/coherence_inherent.rs +++ b/src/test/ui/coherence/coherence_inherent.rs @@ -1,6 +1,10 @@ // Tests that methods that implement a trait cannot be invoked // unless the trait is imported. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + mod Lib { pub trait TheTrait { fn the_fn(&self); @@ -28,7 +32,9 @@ mod NoImport { use Lib::TheStruct; fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found + s.the_fn(); + //[old]~^ ERROR no method named `the_fn` found + //[re]~^^ ERROR E0599 } } diff --git a/src/test/ui/coherence/coherence_inherent_cc.rs b/src/test/ui/coherence/coherence_inherent_cc.rs index 7ab10b2aa66b8..2c980d839b94b 100644 --- a/src/test/ui/coherence/coherence_inherent_cc.rs +++ b/src/test/ui/coherence/coherence_inherent_cc.rs @@ -1,4 +1,7 @@ // aux-build:coherence_inherent_cc_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // Tests that methods that implement a trait cannot be invoked // unless the trait is imported. @@ -20,7 +23,9 @@ mod NoImport { use coherence_inherent_cc_lib::TheStruct; fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found + s.the_fn(); + //[old]~^ ERROR no method named `the_fn` found + //[re]~^^ ERROR E0599 } } diff --git a/src/test/ui/coherence/coherence_local.rs b/src/test/ui/coherence/coherence_local.rs index dc71253e3f78d..cac45b0b9edff 100644 --- a/src/test/ui/coherence/coherence_local.rs +++ b/src/test/ui/coherence/coherence_local.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/coherence/coherence_local_err_struct.rs b/src/test/ui/coherence/coherence_local_err_struct.rs index b94fc6c6abc0f..d6faaf2977a76 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.rs +++ b/src/test/ui/coherence/coherence_local_err_struct.rs @@ -2,8 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re - +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; @@ -13,7 +14,9 @@ struct MyType { x: i32 } // These are all legal because they are all fundamental types: // MyStruct is not fundamental. -impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 +impl lib::MyCopy for lib::MyStruct { } +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence_local_err_tuple.rs b/src/test/ui/coherence/coherence_local_err_tuple.rs index 2e95a0f663d66..2685b2df8cb65 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.rs +++ b/src/test/ui/coherence/coherence_local_err_tuple.rs @@ -2,8 +2,9 @@ // `MyType: !MyTrait` along with other "fundamental" wrappers. // aux-build:coherence_copy_like_lib.rs +// revisions: old re - +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; @@ -13,7 +14,9 @@ struct MyType { x: i32 } // These are all legal because they are all fundamental types: // Tuples are not fundamental, so this is not a local impl. -impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 +impl lib::MyCopy for (MyType,) { } +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence_local_ref.rs b/src/test/ui/coherence/coherence_local_ref.rs index f2978bcd960ab..a52510b8ea9ca 100644 --- a/src/test/ui/coherence/coherence_local_ref.rs +++ b/src/test/ui/coherence/coherence_local_ref.rs @@ -4,6 +4,9 @@ // aux-build:coherence_copy_like_lib.rs // compile-pass // skip-codegen +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] extern crate coherence_copy_like_lib as lib; diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs deleted file mode 100644 index d3d389c6a8bd5..0000000000000 --- a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(fundamental)] - -pub trait MyCopy { } -impl MyCopy for i32 { } - -pub struct MyStruct(T); - -#[fundamental] -pub struct MyFundamentalStruct(T); diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.rs deleted file mode 100644 index 0458636a401ef..0000000000000 --- a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.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. - -// See coherence_inherent_cc.rs - -pub trait TheTrait { - fn the_fn(&self); -} - -pub struct TheStruct; - -impl TheTrait for TheStruct { - fn the_fn(&self) {} -} diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs deleted file mode 100644 index daa123849e4e7..0000000000000 --- a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub trait Remote { - fn foo(&self) { } -} - -pub trait Remote1 { - fn foo(&self, t: T) { } -} - -pub trait Remote2 { - fn foo(&self, t: T, u: U) { } -} - -pub struct Pair(T,U); diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs b/src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs deleted file mode 100644 index b22d12300c7d1..0000000000000 --- a/src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait TheTrait { - fn the_fn(&self); -} diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs b/src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs deleted file mode 100644 index 044bb606b40e2..0000000000000 --- a/src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(specialization)] - -// Common code used for tests that model the Fn/FnMut/FnOnce hierarchy. - -pub trait Go { - fn go(&self, arg: isize); -} - -pub fn go(this: &G, arg: isize) { - this.go(arg) -} - -pub trait GoMut { - fn go_mut(&mut self, arg: isize); -} - -pub fn go_mut(this: &mut G, arg: isize) { - this.go_mut(arg) -} - -pub trait GoOnce { - fn go_once(self, arg: isize); -} - -pub fn go_once(this: G, arg: isize) { - this.go_once(arg) -} - -impl GoMut for G - where G : Go -{ - default fn go_mut(&mut self, arg: isize) { - go(&*self, arg) - } -} - -impl GoOnce for G - where G : GoMut -{ - default fn go_once(mut self, arg: isize) { - go_mut(&mut self, arg) - } -} diff --git a/src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs b/src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs deleted file mode 100644 index 3190ce430ad67..0000000000000 --- a/src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub trait Foo { - fn foo() {} -} - -impl Foo for isize { -} diff --git a/src/test/ui/re_rebalance_coherence/coherence-all-remote.rs b/src/test/ui/re_rebalance_coherence/coherence-all-remote.rs deleted file mode 100644 index 0769518b36beb..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-all-remote.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_lib.rs - -#![feature(re_rebalance_coherence)] - -extern crate coherence_lib as lib; -use lib::Remote1; - -impl Remote1 for isize { } -//~^ ERROR E0210 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr b/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr deleted file mode 100644 index 509cee34b233f..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-all-remote.rs:18:1 - | -LL | impl Remote1 for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type - | - = note: only traits defined in the current crate can be implemented for a type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs deleted file mode 100644 index 712fe9bdb4c75..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub struct BigInt; - -impl Remote1 for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr deleted file mode 100644 index c2f6a15e8e3f7..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-bigint-param.rs:20:1 - | -LL | impl Remote1 for T { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type - | - = note: only traits defined in the current crate can be implemented for a type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs deleted file mode 100644 index da0221c3e0af1..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -use std::fmt::Debug; -use std::default::Default; - -// Test that two blanket impls conflict (at least without negative -// bounds). After all, some other crate could implement Even or Odd -// for the same type (though this crate doesn't). - -trait MyTrait { - fn get(&self) -> usize; -} - -trait Even { } - -trait Odd { } - -impl Even for isize { } - -impl Odd for usize { } - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for T { //~ ERROR E0119 - fn get(&self) -> usize { 0 } -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr deleted file mode 100644 index 8d5d478778075..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:36:1 - | -LL | impl MyTrait for T { - | -------------------------- first implementation here -... -LL | impl MyTrait for T { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs deleted file mode 100644 index 5e407588e2aff..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -use std::fmt::Debug; -use std::default::Default; - -// Test that two blanket impls conflict (at least without negative -// bounds). After all, some other crate could implement Even or Odd -// for the same type (though this crate doesn't implement them at all). - -trait MyTrait { - fn get(&self) -> usize; -} - -trait Even {} - -trait Odd {} - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for T { //~ ERROR E0119 - fn get(&self) -> usize { 0 } -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr deleted file mode 100644 index 6e7df5e6ed3bf..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:32:1 - | -LL | impl MyTrait for T { - | -------------------------- first implementation here -... -LL | impl MyTrait for T { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs deleted file mode 100644 index 9d1caf929222e..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// aux-build:go_trait.rs - -extern crate go_trait; - -use go_trait::{Go,GoMut}; -use std::fmt::Debug; -use std::default::Default; - -struct MyThingy; - -impl Go for MyThingy { - fn go(&self, arg: isize) { } -} - -impl GoMut for MyThingy { //~ ERROR conflicting implementations - fn go_mut(&mut self, arg: isize) { } -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr deleted file mode 100644 index 30656fa41b4f8..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`: - --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:27:1 - | -LL | impl GoMut for MyThingy { //~ ERROR conflicting implementations - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `go_trait`: - - impl go_trait::GoMut for G - where G: go_trait::Go; - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs deleted file mode 100644 index f866465bd081d..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -use std::fmt::Debug; -use std::default::Default; - -// Test that a blank impl for all T conflicts with an impl for some -// specific T, even when there are multiple type parameters involved. - -trait MyTrait { - fn get(&self) -> T; -} - -impl MyTrait for T { - fn get(&self) -> T { - panic!() - } -} - -#[derive(Clone)] -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { //~ ERROR E0119 - fn get(&self) -> usize { (*self).clone() } -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr deleted file mode 100644 index f68e1fd94f0c2..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:34:1 - | -LL | impl MyTrait for T { - | ------------------------ first implementation here -... -LL | impl MyTrait for MyType { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs deleted file mode 100644 index 74b458b838e04..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that a blank impl for all T:PartialEq conflicts with an impl for some -// specific T when T:PartialEq. - -trait OtherTrait { - fn noop(&self); -} - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { //~ ERROR E0119 - fn get(&self) -> usize { self.dummy } -} - -impl OtherTrait for MyType { - fn noop(&self) { } -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr deleted file mode 100644 index bafeadcfcbefb..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:32:1 - | -LL | impl MyTrait for T { - | -------------------------------- first implementation here -... -LL | impl MyTrait for MyType { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs deleted file mode 100644 index 51de0e33034c8..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -use std::fmt::Debug; -use std::default::Default; - -// Test that a blank impl for all T conflicts with an impl for some -// specific T. - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for T { - fn get(&self) -> usize { 0 } -} - -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { //~ ERROR E0119 - fn get(&self) -> usize { self.dummy } -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr b/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr deleted file mode 100644 index efc32d1236402..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific.rs:31:1 - | -LL | impl MyTrait for T { - | --------------------- first implementation here -... -LL | impl MyTrait for MyType { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs b/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs deleted file mode 100644 index c2db97c68e8ec..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(overlapping_marker_traits)] -#![feature(re_rebalance_coherence)] - -trait MyTrait {} - -struct TestType(::std::marker::PhantomData); - -unsafe impl Send for TestType {} - -impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` - -unsafe impl Send for TestType {} - -impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr b/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr deleted file mode 100644 index 7555e9996cf29..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: - --> $DIR/coherence-conflicting-negative-trait-impl.rs:21:1 - | -LL | unsafe impl Send for TestType {} - | ---------------------------------------------------- first implementation here -LL | -LL | impl !Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` - -error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType`: - --> $DIR/coherence-conflicting-negative-trait-impl.rs:26:1 - | -LL | unsafe impl Send for TestType {} - | ------------------------------------------- first implementation here -LL | -LL | impl !Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr b/src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr deleted file mode 100644 index 09cc9801c14a1..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-cow.rs:28:1 - | -LL | impl Remote for Pair> { } //[a]~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr b/src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr deleted file mode 100644 index 7bb8378ee4ba8..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-cow.rs:31:1 - | -LL | impl Remote for Pair,T> { } //[b]~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr b/src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr deleted file mode 100644 index 6dbf0a44f02b8..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-cow.rs:34:1 - | -LL | impl Remote for Pair,U> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-cow.rs b/src/test/ui/re_rebalance_coherence/coherence-cow.rs deleted file mode 100644 index da69d56a25a56..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-cow.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// revisions: a b c - -// aux-build:coherence_lib.rs - -// Test that the `Pair` type reports an error if it contains type -// parameters, even when they are covered by local types. This test -// was originally intended to test the opposite, but the rules changed -// with RFC 1023 and this became illegal. - -extern crate coherence_lib as lib; -use lib::{Remote,Pair}; - -pub struct Cover(T); - -#[cfg(a)] -impl Remote for Pair> { } //[a]~ ERROR E0117 - -#[cfg(b)] -impl Remote for Pair,T> { } //[b]~ ERROR E0117 - -#[cfg(c)] -impl Remote for Pair,U> { } -//[c]~^ ERROR E0117 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs deleted file mode 100644 index 02624c70dc9d8..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// The error here is strictly due to orphan rules; the impl here -// generalizes the one upstream - -// aux-build:trait_impl_conflict.rs -extern crate trait_impl_conflict; -use trait_impl_conflict::Foo; - -impl Foo for A { - //~^ ERROR type parameter `A` must be used as the type parameter for some local type - //~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` -} - -fn main() { -} diff --git a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr deleted file mode 100644 index cc10ac8f02544..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`: - --> $DIR/coherence-cross-crate-conflict.rs:20:1 - | -LL | impl Foo for A { - | ^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `trait_impl_conflict`: - - impl trait_impl_conflict::Foo for isize; - -error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cross-crate-conflict.rs:20:1 - | -LL | impl Foo for A { - | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type - | - = note: only traits defined in the current crate can be implemented for a type parameter - -error: aborting due to 2 previous errors - -Some errors occurred: E0119, E0210. -For more information about an error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs b/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs deleted file mode 100644 index 86dd0e4f74fbd..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(re_rebalance_coherence)] - -auto trait MySafeTrait {} - -struct Foo; - -unsafe impl MySafeTrait for Foo {} -//~^ ERROR implementing the trait `MySafeTrait` is not unsafe - -unsafe auto trait MyUnsafeTrait {} - -impl MyUnsafeTrait for Foo {} -//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr b/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr deleted file mode 100644 index 6c3d79cf53c1c..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0199]: implementing the trait `MySafeTrait` is not unsafe - --> $DIR/coherence-default-trait-impl.rs:18:1 - | -LL | unsafe impl MySafeTrait for Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration - --> $DIR/coherence-default-trait-impl.rs:23:1 - | -LL | impl MyUnsafeTrait for Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -Some errors occurred: E0199, E0200. -For more information about an error, try `rustc --explain E0199`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs b/src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs deleted file mode 100644 index 24df1a1ee01f8..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// check that error types in coherence do not cause error cascades. - -trait Foo {} - -impl Foo for i8 {} -impl Foo for i16 {} -impl Foo for i32 {} -impl Foo for i64 {} -impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope -impl Foo for u8 {} -impl Foo for u16 {} -impl Foo for u32 {} -impl Foo for u64 {} - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr b/src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr deleted file mode 100644 index 97ed46c71bd53..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0412]: cannot find type `DoesNotExist` in this scope - --> $DIR/coherence-error-suppression.rs:21:14 - | -LL | impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope - | ^^^^^^^^^^^^ not found in this scope - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs deleted file mode 100644 index 9e9a00af903dd..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that we give suitable error messages when the user attempts to -// impl a trait `Trait` for its own object type. - -// If the trait is not object-safe, we give a more tailored message -// because we're such schnuckels: -trait NotObjectSafe { fn eq(&self, other: Self); } -impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr deleted file mode 100644 index 0f4f33e4eb9a8..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0038]: the trait `NotObjectSafe` cannot be made into an object - --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:19:6 - | -LL | impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 - | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object - | - = note: method `eq` references the `Self` type in its arguments or return type - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs deleted file mode 100644 index 0ed88058f1fb0..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that we give suitable error messages when the user attempts to -// impl a trait `Trait` for its own object type. - -trait Foo { fn dummy(&self) { } } -trait Bar: Foo { } -trait Baz: Bar { } - -// Supertraits of Baz are not legal: -impl Foo for Baz { } //~ ERROR E0371 -impl Bar for Baz { } //~ ERROR E0371 -impl Baz for Baz { } //~ ERROR E0371 - -// But other random traits are: -trait Other { } -impl Other for Baz { } // OK, Other not a supertrait of Baz - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr b/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr deleted file mode 100644 index d529e86f8fc01..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` - --> $DIR/coherence-impl-trait-for-trait.rs:21:1 - | -LL | impl Foo for Baz { } //~ ERROR E0371 - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` - -error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` - --> $DIR/coherence-impl-trait-for-trait.rs:22:1 - | -LL | impl Bar for Baz { } //~ ERROR E0371 - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` - -error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` - --> $DIR/coherence-impl-trait-for-trait.rs:23:1 - | -LL | impl Baz for Baz { } //~ ERROR E0371 - | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0371`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs b/src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs deleted file mode 100644 index 9f58d13efc2a4..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(re_rebalance_coherence)] - -use std::marker::Copy; - -impl Copy for i32 {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`: -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - -enum TestE { - A -} - -struct MyType; - -struct NotSync; -impl !Sync for NotSync {} - -impl Copy for TestE {} -impl Clone for TestE { fn clone(&self) -> Self { *self } } - -impl Copy for MyType {} - -impl Copy for &'static mut MyType {} -//~^ ERROR the trait `Copy` may not be implemented for this type -impl Clone for MyType { fn clone(&self) -> Self { *self } } - -impl Copy for (MyType, MyType) {} -//~^ ERROR the trait `Copy` may not be implemented for this type -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - -impl Copy for &'static NotSync {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: - -impl Copy for [MyType] {} -//~^ ERROR the trait `Copy` may not be implemented for this type -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - -impl Copy for &'static [NotSync] {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - -fn main() { -} diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr b/src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr deleted file mode 100644 index 80e2d203aaaab..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr +++ /dev/null @@ -1,87 +0,0 @@ -error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`: - --> $DIR/coherence-impls-copy.rs:16:1 - | -LL | impl Copy for i32 {} - | ^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `core`: - - impl std::marker::Copy for i32; - -error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: - --> $DIR/coherence-impls-copy.rs:42:1 - | -LL | impl Copy for &'static NotSync {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `core`: - - impl std::marker::Copy for &T - where T: ?Sized; - -error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: - --> $DIR/coherence-impls-copy.rs:49:1 - | -LL | impl Copy for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `core`: - - impl std::marker::Copy for &T - where T: ?Sized; - -error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:34:15 - | -LL | impl Copy for &'static mut MyType {} - | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration - -error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:38:15 - | -LL | impl Copy for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration - -error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:45:15 - | -LL | impl Copy for [MyType] {} - | ^^^^^^^^ type is not a structure or enumeration - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:16:1 - | -LL | impl Copy for i32 {} - | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:38:1 - | -LL | impl Copy for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:45:1 - | -LL | impl Copy for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:49:1 - | -LL | impl Copy for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to 10 previous errors - -Some errors occurred: E0117, E0119, E0206. -For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-send.rs b/src/test/ui/re_rebalance_coherence/coherence-impls-send.rs deleted file mode 100644 index 11b92d5254c44..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impls-send.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(overlapping_marker_traits)] -#![feature(re_rebalance_coherence)] - -use std::marker::Copy; - -enum TestE { - A -} - -struct MyType; - -struct NotSync; -impl !Sync for NotSync {} - -unsafe impl Send for TestE {} -unsafe impl Send for MyType {} -unsafe impl Send for (MyType, MyType) {} -//~^ ERROR E0117 - -unsafe impl Send for &'static NotSync {} -//~^ ERROR E0321 - -unsafe impl Send for [MyType] {} -//~^ ERROR E0117 - -unsafe impl Send for &'static [NotSync] {} -//~^ ERROR E0117 - -fn main() { -} diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr b/src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr deleted file mode 100644 index 8f09deeeb9303..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr +++ /dev/null @@ -1,37 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:28:1 - | -LL | unsafe impl Send for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` - --> $DIR/coherence-impls-send.rs:31:1 - | -LL | unsafe impl Send for &'static NotSync {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:34:1 - | -LL | unsafe impl Send for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:37:1 - | -LL | unsafe impl Send for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to 4 previous errors - -Some errors occurred: E0117, E0321. -For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs b/src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs deleted file mode 100644 index 3f7970f34fc5e..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(re_rebalance_coherence)] - -use std::marker::Copy; - -enum TestE { - A -} - -struct MyType; - -struct NotSync; -impl !Sync for NotSync {} - -impl Sized for TestE {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for MyType {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for (MyType, MyType) {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static NotSync {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for [MyType] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static [NotSync] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -fn main() { -} diff --git a/src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr b/src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr deleted file mode 100644 index 92b165bdc3b74..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:25:1 - | -LL | impl Sized for TestE {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed - -error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:28:1 - | -LL | impl Sized for MyType {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed - -error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:31:1 - | -LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed - -error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:35:1 - | -LL | impl Sized for &'static NotSync {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed - -error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:38:1 - | -LL | impl Sized for [MyType] {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed - -error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:42:1 - | -LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:31:1 - | -LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:38:1 - | -LL | impl Sized for [MyType] {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:42:1 - | -LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to 9 previous errors - -Some errors occurred: E0117, E0322. -For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs b/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs deleted file mode 100644 index a2cfb11fdc234..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Formerly this ICEd with the following message: -// Tried to project an inherited associated type during coherence checking, -// which is currently not supported. -// -// No we expect to run into a more user-friendly cycle error instead. - -#![feature(specialization)] -#![feature(re_rebalance_coherence)] - -trait Trait { type Assoc; } -//~^ cycle detected - -impl Trait for Vec { - type Assoc = (); -} - -impl Trait for Vec {} - -impl Trait for String { - type Assoc = (); -} - -impl Trait< as Trait>::Assoc> for String {} - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr deleted file mode 100644 index aca2d64b6231b..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0391]: cycle detected when processing `Trait` - --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:20:1 - | -LL | trait Trait { type Assoc; } - | ^^^^^^^^^^^^^^ - | - = note: ...which again requires processing `Trait`, completing the cycle -note: cycle used when coherence checking all impls of trait `Trait` - --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:20:1 - | -LL | trait Trait { type Assoc; } - | ^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs deleted file mode 100644 index 8d3551beb5fcd..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -impl Remote for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr deleted file mode 100644 index 403ced3f287c2..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-lone-type-parameter.rs:18:1 - | -LL | impl Remote for T { } - | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type - | - = note: only traits defined in the current crate can be implemented for a type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs b/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs deleted file mode 100644 index 40f7ebfd25025..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(optin_builtin_traits)] -#![feature(re_rebalance_coherence)] - -use std::marker::Send; - -struct TestType; - -unsafe impl !Send for TestType {} -//~^ ERROR negative impls cannot be unsafe - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr b/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr deleted file mode 100644 index 70a879efa27c3..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0198]: negative impls cannot be unsafe - --> $DIR/coherence-negative-impls-safe.rs:18:1 - | -LL | unsafe impl !Send for TestType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0198`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs b/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs deleted file mode 100644 index 838bc71d3afeb..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that you cannot *directly* dispatch on lifetime requirements - -trait MyTrait { fn foo() {} } - -impl MyTrait for T {} -impl MyTrait for T {} //~ ERROR E0119 - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr b/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr deleted file mode 100644 index aa6427ba24f95..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-no-direct-lifetime-dispatch.rs:18:1 - | -LL | impl MyTrait for T {} - | --------------------- first implementation here -LL | impl MyTrait for T {} //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-orphan.rs b/src/test/ui/re_rebalance_coherence/coherence-orphan.rs deleted file mode 100644 index dbe26a8898d4d..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-orphan.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:coherence_orphan_lib.rs - -#![feature(optin_builtin_traits)] -#![feature(re_rebalance_coherence)] - -extern crate coherence_orphan_lib as lib; - -use lib::TheTrait; - -struct TheType; - -impl TheTrait for isize { } -//~^ ERROR E0117 - -impl TheTrait for isize { } - -impl TheTrait for TheType { } - -impl !Send for Vec { } -//~^ ERROR E0117 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-orphan.stderr b/src/test/ui/re_rebalance_coherence/coherence-orphan.stderr deleted file mode 100644 index 6e5e734401f41..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-orphan.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-orphan.rs:22:1 - | -LL | impl TheTrait for isize { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-orphan.rs:29:1 - | -LL | impl !Send for Vec { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs deleted file mode 100644 index 13604d9e4952a..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Check that we detect an overlap here in the case where: -// -// for some type X: -// T = (X,) -// T11 = X, U11 = X -// -// Seems pretty basic, but then there was issue #24241. :) - -trait From { - fn foo() {} -} - -impl From for T { -} - -impl From<(U11,)> for (T11,) { //~ ERROR E0119 -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr deleted file mode 100644 index dc052931ed14e..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`: - --> $DIR/coherence-overlap-all-t-and-tuple.rs:28:1 - | -LL | impl From for T { - | ---------------------- first implementation here -... -LL | impl From<(U11,)> for (T11,) { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs deleted file mode 100644 index 1f0ca50b60fca..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even -// though no impls are found. - -struct Sweet(X); -pub trait Sugar {} -pub trait Fruit {} -impl Sweet { fn dummy(&self) { } } -//~^ ERROR E0592 -impl Sweet { fn dummy(&self) { } } - -trait Bar {} -struct A(T, X); -impl A where T: Bar { fn f(&self) {} } -//~^ ERROR E0592 -impl A { fn f(&self) {} } - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr deleted file mode 100644 index 8a817fcb44067..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-downstream-inherent.rs:19:26 - | -LL | impl Sweet { fn dummy(&self) { } } - | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 -LL | impl Sweet { fn dummy(&self) { } } - | ------------------- other definition for `dummy` - -error[E0592]: duplicate definitions with name `f` - --> $DIR/coherence-overlap-downstream-inherent.rs:25:38 - | -LL | impl A where T: Bar { fn f(&self) {} } - | ^^^^^^^^^^^^^^ duplicate definitions for `f` -LL | //~^ ERROR E0592 -LL | impl A { fn f(&self) {} } - | -------------- other definition for `f` - | - = note: downstream crates may implement trait `Bar<_>` for type `i32` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs deleted file mode 100644 index 7a2b28f49b549..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even -// though no impls are found. - -pub trait Sugar {} -pub trait Fruit {} -pub trait Sweet {} -impl Sweet for T { } -impl Sweet for T { } -//~^ ERROR E0119 - -pub trait Foo {} -pub trait Bar {} -impl Foo for T where T: Bar {} -impl Foo for i32 {} -//~^ ERROR E0119 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr deleted file mode 100644 index ce08ae15df131..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0119]: conflicting implementations of trait `Sweet`: - --> $DIR/coherence-overlap-downstream.rs:20:1 - | -LL | impl Sweet for T { } - | ------------------------- first implementation here -LL | impl Sweet for T { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - -error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`: - --> $DIR/coherence-overlap-downstream.rs:26:1 - | -LL | impl Foo for T where T: Bar {} - | --------------------------------------- first implementation here -LL | impl Foo for i32 {} - | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` - | - = note: downstream crates may implement trait `Bar<_>` for type `i32` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs deleted file mode 100644 index ff6af49dfb2ef..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Tests that we consider `Box: !Sugar` to be ambiguous, even -// though we see no impl of `Sugar` for `Box`. Therefore, an overlap -// error is reported for the following pair of impls (#23516). - -pub trait Sugar {} - -struct Cake(X); - -impl Cake { fn dummy(&self) { } } -//~^ ERROR E0592 -impl Cake> { fn dummy(&self) { } } - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr deleted file mode 100644 index 26b59fbe71bd7..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-issue-23516-inherent.rs:21:25 - | -LL | impl Cake { fn dummy(&self) { } } - | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 -LL | impl Cake> { fn dummy(&self) { } } - | ------------------- other definition for `dummy` - | - = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs deleted file mode 100644 index 2e45572e4eccd..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Tests that we consider `Box: !Sugar` to be ambiguous, even -// though we see no impl of `Sugar` for `Box`. Therefore, an overlap -// error is reported for the following pair of impls (#23516). - -pub trait Sugar { fn dummy(&self) { } } -pub trait Sweet { fn dummy(&self) { } } -impl Sweet for T { } -impl Sweet for Box { } -//~^ ERROR E0119 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr deleted file mode 100644 index 9d3d564b8a91c..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>`: - --> $DIR/coherence-overlap-issue-23516.rs:20:1 - | -LL | impl Sweet for T { } - | ------------------------- first implementation here -LL | impl Sweet for Box { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>` - | - = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs deleted file mode 100644 index 1474fbd700c77..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -trait Foo { fn foo() {} } - -impl Foo for T {} -impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: - -trait Bar { fn bar() {} } - -impl Bar for (T, u8) {} -impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: - -trait Baz { fn baz() {} } - -impl Baz for T {} -impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: - -trait Quux { fn quux() {} } - -impl Quux for T {} -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr deleted file mode 100644 index c7b24e7bf6dee..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr +++ /dev/null @@ -1,44 +0,0 @@ -error[E0119]: conflicting implementations of trait `Foo`: - --> $DIR/coherence-overlap-messages.rs:16:1 - | -LL | impl Foo for T {} - | ----------------- first implementation here -LL | impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: - | ^^^^^^^^^^^^^^^^^ conflicting implementation - -error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: - --> $DIR/coherence-overlap-messages.rs:21:1 - | -LL | impl Bar for (T, u8) {} - | ----------------------- first implementation here -LL | impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: - | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` - -error[E0119]: conflicting implementations of trait `Baz` for type `u8`: - --> $DIR/coherence-overlap-messages.rs:26:1 - | -LL | impl Baz for T {} - | --------------------- first implementation here -LL | impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: - | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` - -error[E0119]: conflicting implementations of trait `Quux<_, _>`: - --> $DIR/coherence-overlap-messages.rs:31:1 - | -LL | impl Quux for T {} - | ------------------------------ first implementation here -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - -error[E0119]: conflicting implementations of trait `Quux<_, _>`: - --> $DIR/coherence-overlap-messages.rs:32:1 - | -LL | impl Quux for T {} - | ------------------------------ first implementation here -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs deleted file mode 100644 index e802c0113ad82..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Tests that we consider `i16: Remote` to be ambiguous, even -// though the upstream crate doesn't implement it for now. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib; - -use coherence_lib::Remote; - -struct A(X); -impl A where T: Remote { fn dummy(&self) { } } -//~^ ERROR E0592 -impl A { fn dummy(&self) { } } - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr deleted file mode 100644 index 70b19ddb429a5..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-upstream-inherent.rs:23:32 - | -LL | impl A where T: Remote { fn dummy(&self) { } } - | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 -LL | impl A { fn dummy(&self) { } } - | ------------------- other definition for `dummy` - | - = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs deleted file mode 100644 index afbc69cac330f..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Tests that we consider `i16: Remote` to be ambiguous, even -// though the upstream crate doesn't implement it for now. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib; - -use coherence_lib::Remote; - -trait Foo {} -impl Foo for T where T: Remote {} -impl Foo for i16 {} -//~^ ERROR E0119 - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr deleted file mode 100644 index 88bea02b34816..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0119]: conflicting implementations of trait `Foo` for type `i16`: - --> $DIR/coherence-overlap-upstream.rs:24:1 - | -LL | impl Foo for T where T: Remote {} - | --------------------------------- first implementation here -LL | impl Foo for i16 {} - | ^^^^^^^^^^^^^^^^ conflicting implementation for `i16` - | - = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs b/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs deleted file mode 100644 index 25d8e3197f42a..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Foo; - -impl Remote for lib::Pair { } -//~^ ERROR E0117 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr b/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr deleted file mode 100644 index 2629a017b7933..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-overlapping-pairs.rs:20:1 - | -LL | impl Remote for lib::Pair { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs deleted file mode 100644 index 002b422f704c5..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that the same coverage rules apply even if the local type appears in the -// list of type parameters, not the self type. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::{Remote1, Pair}; - -pub struct Local(T); - -impl Remote1>> for i32 { } -//~^ ERROR E0117 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr deleted file mode 100644 index 197056746b9c5..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-pair-covered-uncovered-1.rs:23:1 - | -LL | impl Remote1>> for i32 { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs deleted file mode 100644 index 9b0d7177ffcce..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::{Remote, Pair}; - -struct Local(T); - -impl Remote for Pair> { } -//~^ ERROR E0117 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr deleted file mode 100644 index b9e2eced94b18..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-pair-covered-uncovered.rs:20:1 - | -LL | impl Remote for Pair> { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs deleted file mode 100644 index e3f945504feba..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(rustc_attrs)] -#![feature(re_rebalance_coherence)] - -// Here we expect a coherence conflict because, even though `i32` does -// not implement `Iterator`, we cannot rely on that negative reasoning -// due to the orphan rules. Therefore, `A::Item` may yet turn out to -// be `i32`. - -pub trait Foo

{ fn foo() {} } - -pub trait Bar { - type Output: 'static; -} - -impl Foo for i32 { } - -impl Foo for A { } //~ ERROR E0119 - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr deleted file mode 100644 index 81b1343837348..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0119]: conflicting implementations of trait `Foo` for type `i32`: - --> $DIR/coherence-projection-conflict-orphan.rs:27:1 - | -LL | impl Foo for i32 { } - | --------------------- first implementation here -LL | -LL | impl Foo for A { } //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` - | - = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs deleted file mode 100644 index cb5c94a18a728..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Coherence error results because we do not know whether `T: Foo

` or not -// for the second impl. - -use std::marker::PhantomData; - -pub trait Foo

{ fn foo() {} } - -impl > Foo

for Option {} - -impl Foo for Option { } //~ ERROR E0119 - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr deleted file mode 100644 index fe5a66ef9ea24..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`: - --> $DIR/coherence-projection-conflict-ty-param.rs:22:1 - | -LL | impl > Foo

for Option {} - | ---------------------------------------- first implementation here -LL | -LL | impl Foo for Option { } //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs deleted file mode 100644 index 73adba0819e69..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -use std::marker::PhantomData; - -pub trait Foo

{ fn foo() {} } - -pub trait Bar { - type Output: 'static; -} - -impl Foo for i32 { } - -impl Foo for A { } //~ ERROR E0119 - -impl Bar for i32 { - type Output = i32; -} - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr b/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr deleted file mode 100644 index 7f5ff3de17864..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `Foo` for type `i32`: - --> $DIR/coherence-projection-conflict.rs:23:1 - | -LL | impl Foo for i32 { } - | --------------------- first implementation here -LL | -LL | impl Foo for A { } //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs deleted file mode 100644 index b02289dc68e52..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass -// skip-codegen -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] -// Here we do not get a coherence conflict because `Baz: Iterator` -// does not hold and (due to the orphan rules), we can rely on that. - -pub trait Foo

{} - -pub trait Bar { - type Output: 'static; -} - -struct Baz; -impl Foo for Baz { } - -impl Foo for A { } - - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs b/src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs deleted file mode 100644 index 9c797b61a43b2..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// compile-pass -// skip-codegen -pub trait Foo

{} - -pub trait Bar { - type Output: 'static; -} - -impl Foo for i32 { } - -impl Foo for A { } - -impl Bar for i32 { - type Output = u32; -} - - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs b/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs deleted file mode 100644 index c6dda7f277316..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -use std::fmt::Debug; -use std::default::Default; - -// Test that a blank impl for all T conflicts with an impl for some -// specific T. - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for (T,T) { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for (A,B) { //~ ERROR E0119 - fn get(&self) -> usize { self.dummy } -} - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr b/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr deleted file mode 100644 index bd4f2908cdfe7..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `(_, _)`: - --> $DIR/coherence-tuple-conflict.rs:27:1 - | -LL | impl MyTrait for (T,T) { - | ------------------------- first implementation here -... -LL | impl MyTrait for (A,B) { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs b/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs deleted file mode 100644 index 6849f004c635d..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that a local, generic type appearing within a -// *non-fundamental* remote type like `Vec` is not considered local. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Local(T); - -impl Remote for Vec> { } //~ ERROR E0117 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr b/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr deleted file mode 100644 index d507edbb0bde9..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-vec-local-2.rs:23:1 - | -LL | impl Remote for Vec> { } //~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local.rs b/src/test/ui/re_rebalance_coherence/coherence-vec-local.rs deleted file mode 100644 index 24a00febfd8f4..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-vec-local.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that a local type (with no type parameters) appearing within a -// *non-fundamental* remote type like `Vec` is not considered local. - -// aux-build:coherence_lib.rs - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Local; - -impl Remote for Vec { } //~ ERROR E0117 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr b/src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr deleted file mode 100644 index fc400da711551..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-vec-local.rs:23:1 - | -LL | impl Remote for Vec { } //~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs deleted file mode 100644 index 5e09cf69a61af..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs -// compile-pass -// skip-codgen -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// `MyFundamentalStruct` is declared fundamental, so we can test that -// -// MyFundamentalStruct: !MyTrait -// -// Huzzah. -impl MyTrait for lib::MyFundamentalStruct { } - - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs deleted file mode 100644 index 8e5d2bf4cf7b6..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs -// compile-pass -// skip-codegen -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// `MyFundamentalStruct` is declared fundamental, so we can test that -// -// MyFundamentalStruct<&MyTrait>: !MyTrait -// -// Huzzah. -impl<'a> MyTrait for lib::MyFundamentalStruct<&'a MyType> { } - - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs deleted file mode 100644 index e7a8edbd22147..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - - - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } - -impl MyTrait for T { } - -// Tuples are not fundamental. -impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 - - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr deleted file mode 100644 index e6adc08c28c37..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>`: - --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:29:1 - | -LL | impl MyTrait for T { } - | ---------------------------------- first implementation here -... -LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` - | - = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs deleted file mode 100644 index 3f91750104b9a..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// aux-build:coherence_copy_like_lib.rs - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// `MyStruct` is not declared fundamental, therefore this would -// require that -// -// MyStruct: !MyTrait -// -// which we cannot approve. -impl MyTrait for lib::MyStruct { } //~ ERROR E0119 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr deleted file mode 100644 index a40ae4fc4488d..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct`: - --> $DIR/coherence_copy_like_err_struct.rs:31:1 - | -LL | impl MyTrait for T { } - | ---------------------------------- first implementation here -... -LL | impl MyTrait for lib::MyStruct { } //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct` - | - = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyStruct` in future versions - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs deleted file mode 100644 index 0e7eef6fe6de2..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { fn foo() {} } -impl MyTrait for T { } - -// Tuples are not fundamental, therefore this would require that -// -// (MyType,): !MyTrait -// -// which we cannot approve. -impl MyTrait for (MyType,) { } //~ ERROR E0119 - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr deleted file mode 100644 index 82e43f6d721eb..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `(MyType,)`: - --> $DIR/coherence_copy_like_err_tuple.rs:30:1 - | -LL | impl MyTrait for T { } - | ---------------------------------- first implementation here -... -LL | impl MyTrait for (MyType,) { } //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(MyType,)` - | - = note: upstream crates may add new impl of trait `lib::MyCopy` for type `(MyType,)` in future versions - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent.rs b/src/test/ui/re_rebalance_coherence/coherence_inherent.rs deleted file mode 100644 index d4d29326e4f78..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_inherent.rs +++ /dev/null @@ -1,47 +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. - -#![feature(re_rebalance_coherence)] - -// Tests that methods that implement a trait cannot be invoked -// unless the trait is imported. - -mod Lib { - pub trait TheTrait { - fn the_fn(&self); - } - - pub struct TheStruct; - - impl TheTrait for TheStruct { - fn the_fn(&self) {} - } -} - -mod Import { - // Trait is in scope here: - use Lib::TheStruct; - use Lib::TheTrait; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); - } -} - -mod NoImport { - // Trait is not in scope here: - use Lib::TheStruct; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found - } -} - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence_inherent.stderr deleted file mode 100644 index 9294899bfee54..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_inherent.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope - --> $DIR/coherence_inherent.rs:43:11 - | -LL | s.the_fn(); //~ ERROR no method named `the_fn` found - | ^^^^^^ - | - = help: items from traits can only be used if the trait is in scope - = note: the following trait is implemented but not in scope, perhaps add a `use` for it: - `use Lib::TheTrait;` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs b/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs deleted file mode 100644 index beb60f57a2a2c..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// aux-build:coherence_inherent_cc_lib.rs - -// Tests that methods that implement a trait cannot be invoked -// unless the trait is imported. - -extern crate coherence_inherent_cc_lib; - -mod Import { - // Trait is in scope here: - use coherence_inherent_cc_lib::TheStruct; - use coherence_inherent_cc_lib::TheTrait; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); - } -} - -mod NoImport { - // Trait is not in scope here: - use coherence_inherent_cc_lib::TheStruct; - - fn call_the_fn(s: &TheStruct) { - s.the_fn(); //~ ERROR no method named `the_fn` found - } -} - -fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr b/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr deleted file mode 100644 index bf67313879b7e..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope - --> $DIR/coherence_inherent_cc.rs:35:11 - | -LL | s.the_fn(); //~ ERROR no method named `the_fn` found - | ^^^^^^ - | - = help: items from traits can only be used if the trait is in scope - = note: the following trait is implemented but not in scope, perhaps add a `use` for it: - `use coherence_inherent_cc_lib::TheTrait;` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_local.rs b/src/test/ui/re_rebalance_coherence/coherence_local.rs deleted file mode 100644 index 7f72ff7af8887..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_local.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs -// compile-pass -// skip-codegen -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// These are all legal because they are all fundamental types: - -impl lib::MyCopy for MyType { } -impl<'a> lib::MyCopy for &'a MyType { } -impl<'a> lib::MyCopy for &'a Box { } -impl lib::MyCopy for Box { } -impl lib::MyCopy for lib::MyFundamentalStruct { } -impl lib::MyCopy for lib::MyFundamentalStruct> { } - - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs b/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs deleted file mode 100644 index 3d7145e489d18..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(re_rebalance_coherence)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// These are all legal because they are all fundamental types: - -// MyStruct is not fundamental. -impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 - - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr b/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr deleted file mode 100644 index c35e95040de15..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence_local_err_struct.rs:26:1 - | -LL | impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs b/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs deleted file mode 100644 index f2c9008dd8ca9..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -#![feature(re_rebalance_coherence)] -#![allow(dead_code)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// These are all legal because they are all fundamental types: - -// Tuples are not fundamental, so this is not a local impl. -impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 - - -fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr deleted file mode 100644 index a3f9f2d32b8f9..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence_local_err_tuple.rs:26:1 - | -LL | impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_ref.rs b/src/test/ui/re_rebalance_coherence/coherence_local_ref.rs deleted file mode 100644 index b15a5cc245bf4..0000000000000 --- a/src/test/ui/re_rebalance_coherence/coherence_local_ref.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs -// compile-pass -// skip-codegen -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -// naturally, legal -impl lib::MyCopy for MyType { } - - -fn main() { } From da08a8131de77d6bc12964b2e9d9e9f8abf59c2d Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Sat, 29 Dec 2018 00:51:26 +0100 Subject: [PATCH 24/58] Fix typo --- .../ui/feature-gates/feature-gate-re-rebalance-coherence.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs index c702b92f042a2..505a45379cdca 100644 --- a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs @@ -1,4 +1,4 @@ -// Test that the use of the box syntax is gated by `box_syntax` feature gate. +// Test that the use of the box syntax is gated by `re-rebalance-coherence` feature gate. // aux-build:re_rebalance_coherence_lib.rs From 6caa4ce565b5aa87ea368cdcc1630ab6f6860e4b Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Sat, 29 Dec 2018 02:13:06 +0100 Subject: [PATCH 25/58] Add missing files --- .../auxiliary/re_rebalance_coherence_lib.rs | 23 +++++ ...stderr => coherence-all-remote.old.stderr} | 2 +- .../coherence/coherence-all-remote.re.stderr | 11 +++ ...derr => coherence-bigint-param.old.stderr} | 2 +- .../coherence-bigint-param.re.stderr | 11 +++ ...licts-with-blanket-implemented.old.stderr} | 4 +- ...nflicts-with-blanket-implemented.re.stderr | 12 +++ ...cts-with-blanket-unimplemented.old.stderr} | 4 +- ...licts-with-blanket-unimplemented.re.stderr | 12 +++ ...icts-with-specific-cross-crate.old.stderr} | 4 +- ...flicts-with-specific-cross-crate.re.stderr | 13 +++ ...ts-with-specific-multidispatch.old.stderr} | 4 +- ...icts-with-specific-multidispatch.re.stderr | 12 +++ ...-conflicts-with-specific-trait.old.stderr} | 4 +- ...et-conflicts-with-specific-trait.re.stderr | 12 +++ ...lanket-conflicts-with-specific.old.stderr} | 4 +- ...-blanket-conflicts-with-specific.re.stderr | 12 +++ ...onflicting-negative-trait-impl.old.stderr} | 4 +- ...-conflicting-negative-trait-impl.re.stderr | 21 +++++ src/test/ui/coherence/coherence-cow.a.stderr | 2 +- src/test/ui/coherence/coherence-cow.b.stderr | 2 +- src/test/ui/coherence/coherence-cow.c.stderr | 2 +- .../ui/coherence/coherence-cow.re_a.stderr | 12 +++ .../ui/coherence/coherence-cow.re_b.stderr | 12 +++ .../ui/coherence/coherence-cow.re_c.stderr | 12 +++ ...coherence-cross-crate-conflict.old.stderr} | 4 +- .../coherence-cross-crate-conflict.re.stderr | 21 +++++ ...> coherence-default-trait-impl.old.stderr} | 4 +- .../coherence-default-trait-impl.re.stderr | 16 ++++ ...=> coherence-error-suppression.old.stderr} | 4 +- .../coherence-error-suppression.re.stderr | 9 ++ ...pl-trait-for-trait-object-safe.old.stderr} | 4 +- ...impl-trait-for-trait-object-safe.re.stderr | 11 +++ ...coherence-impl-trait-for-trait.old.stderr} | 12 +-- .../coherence-impl-trait-for-trait.re.stderr | 21 +++++ ...stderr => coherence-impls-copy.old.stderr} | 20 ++--- .../coherence/coherence-impls-copy.re.stderr | 87 +++++++++++++++++++ ...stderr => coherence-impls-send.old.stderr} | 8 +- .../coherence/coherence-impls-send.re.stderr | 37 ++++++++ ...tderr => coherence-impls-sized.old.stderr} | 36 ++++---- .../coherence/coherence-impls-sized.re.stderr | 67 ++++++++++++++ ...e-inherited-assoc-ty-cycle-err.old.stderr} | 4 +- ...nce-inherited-assoc-ty-cycle-err.re.stderr | 16 ++++ ... coherence-lone-type-parameter.old.stderr} | 2 +- .../coherence-lone-type-parameter.re.stderr | 11 +++ ... coherence-negative-impls-safe.old.stderr} | 2 +- .../coherence-negative-impls-safe.re.stderr | 9 ++ ...ce-no-direct-lifetime-dispatch.old.stderr} | 4 +- ...ence-no-direct-lifetime-dispatch.re.stderr | 11 +++ ...han.stderr => coherence-orphan.old.stderr} | 4 +- .../ui/coherence/coherence-orphan.re.stderr | 21 +++++ ...erence-overlap-all-t-and-tuple.old.stderr} | 4 +- ...oherence-overlap-all-t-and-tuple.re.stderr | 12 +++ ...ce-overlap-downstream-inherent.old.stderr} | 8 +- ...ence-overlap-downstream-inherent.re.stderr | 23 +++++ ...> coherence-overlap-downstream.old.stderr} | 4 +- .../coherence-overlap-downstream.re.stderr | 21 +++++ ...e-overlap-issue-23516-inherent.old.stderr} | 4 +- ...nce-overlap-issue-23516-inherent.re.stderr | 14 +++ ... coherence-overlap-issue-23516.old.stderr} | 2 +- .../coherence-overlap-issue-23516.re.stderr | 13 +++ ... => coherence-overlap-messages.old.stderr} | 22 ++--- .../coherence-overlap-messages.re.stderr | 44 ++++++++++ ...ence-overlap-upstream-inherent.old.stderr} | 4 +- ...erence-overlap-upstream-inherent.re.stderr | 14 +++ ... => coherence-overlap-upstream.old.stderr} | 2 +- .../coherence-overlap-upstream.re.stderr | 13 +++ ...=> coherence-overlapping-pairs.old.stderr} | 2 +- .../coherence-overlapping-pairs.re.stderr | 12 +++ ...rence-pair-covered-uncovered-1.old.stderr} | 2 +- ...herence-pair-covered-uncovered-1.re.stderr | 12 +++ ...herence-pair-covered-uncovered.old.stderr} | 2 +- ...coherence-pair-covered-uncovered.re.stderr | 12 +++ ...nce-projection-conflict-orphan.old.stderr} | 4 +- ...rence-projection-conflict-orphan.re.stderr | 14 +++ ...e-projection-conflict-ty-param.old.stderr} | 4 +- ...nce-projection-conflict-ty-param.re.stderr | 12 +++ ... coherence-projection-conflict.old.stderr} | 4 +- .../coherence-projection-conflict.re.stderr | 12 +++ ...rr => coherence-tuple-conflict.old.stderr} | 4 +- .../coherence-tuple-conflict.re.stderr | 12 +++ ...tderr => coherence-vec-local-2.old.stderr} | 4 +- .../coherence/coherence-vec-local-2.re.stderr | 12 +++ ....stderr => coherence-vec-local.old.stderr} | 4 +- .../coherence/coherence-vec-local.re.stderr | 12 +++ ...e_err_fundamental_struct_tuple.old.stderr} | 4 +- ...ike_err_fundamental_struct_tuple.re.stderr | 14 +++ ...coherence_copy_like_err_struct.old.stderr} | 4 +- .../coherence_copy_like_err_struct.re.stderr | 14 +++ ... coherence_copy_like_err_tuple.old.stderr} | 4 +- .../coherence_copy_like_err_tuple.re.stderr | 14 +++ ...t.stderr => coherence_inherent.old.stderr} | 4 +- .../ui/coherence/coherence_inherent.re.stderr | 13 +++ ...tderr => coherence_inherent_cc.old.stderr} | 4 +- .../coherence/coherence_inherent_cc.re.stderr | 13 +++ ... => coherence_local_err_struct.old.stderr} | 4 +- .../coherence_local_err_struct.re.stderr | 12 +++ ...r => coherence_local_err_tuple.old.stderr} | 4 +- .../coherence_local_err_tuple.re.stderr | 12 +++ .../ui/coherence/re-rebalance-coherence.rs | 13 +++ 100 files changed, 1008 insertions(+), 127 deletions(-) create mode 100644 src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs rename src/test/ui/coherence/{coherence-all-remote.stderr => coherence-all-remote.old.stderr} (92%) create mode 100644 src/test/ui/coherence/coherence-all-remote.re.stderr rename src/test/ui/coherence/{coherence-bigint-param.stderr => coherence-bigint-param.old.stderr} (91%) create mode 100644 src/test/ui/coherence/coherence-bigint-param.re.stderr rename src/test/ui/coherence/{coherence-blanket-conflicts-with-blanket-implemented.stderr => coherence-blanket-conflicts-with-blanket-implemented.old.stderr} (87%) create mode 100644 src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.re.stderr rename src/test/ui/coherence/{coherence-blanket-conflicts-with-blanket-unimplemented.stderr => coherence-blanket-conflicts-with-blanket-unimplemented.old.stderr} (86%) create mode 100644 src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.re.stderr rename src/test/ui/coherence/{coherence-blanket-conflicts-with-specific-cross-crate.stderr => coherence-blanket-conflicts-with-specific-cross-crate.old.stderr} (84%) create mode 100644 src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.re.stderr rename src/test/ui/coherence/{coherence-blanket-conflicts-with-specific-multidispatch.stderr => coherence-blanket-conflicts-with-specific-multidispatch.old.stderr} (86%) create mode 100644 src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.re.stderr rename src/test/ui/coherence/{coherence-blanket-conflicts-with-specific-trait.stderr => coherence-blanket-conflicts-with-specific-trait.old.stderr} (77%) create mode 100644 src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.re.stderr rename src/test/ui/coherence/{coherence-blanket-conflicts-with-specific.stderr => coherence-blanket-conflicts-with-specific.old.stderr} (76%) create mode 100644 src/test/ui/coherence/coherence-blanket-conflicts-with-specific.re.stderr rename src/test/ui/coherence/{coherence-conflicting-negative-trait-impl.stderr => coherence-conflicting-negative-trait-impl.old.stderr} (87%) create mode 100644 src/test/ui/coherence/coherence-conflicting-negative-trait-impl.re.stderr create mode 100644 src/test/ui/coherence/coherence-cow.re_a.stderr create mode 100644 src/test/ui/coherence/coherence-cow.re_b.stderr create mode 100644 src/test/ui/coherence/coherence-cow.re_c.stderr rename src/test/ui/coherence/{coherence-cross-crate-conflict.stderr => coherence-cross-crate-conflict.old.stderr} (88%) create mode 100644 src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr rename src/test/ui/coherence/{coherence-default-trait-impl.stderr => coherence-default-trait-impl.old.stderr} (82%) create mode 100644 src/test/ui/coherence/coherence-default-trait-impl.re.stderr rename src/test/ui/coherence/{coherence-error-suppression.stderr => coherence-error-suppression.old.stderr} (62%) create mode 100644 src/test/ui/coherence/coherence-error-suppression.re.stderr rename src/test/ui/coherence/{coherence-impl-trait-for-trait-object-safe.stderr => coherence-impl-trait-for-trait-object-safe.old.stderr} (73%) create mode 100644 src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr rename src/test/ui/coherence/{coherence-impl-trait-for-trait.stderr => coherence-impl-trait-for-trait.old.stderr} (69%) create mode 100644 src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr rename src/test/ui/coherence/{coherence-impls-copy.stderr => coherence-impls-copy.old.stderr} (89%) create mode 100644 src/test/ui/coherence/coherence-impls-copy.re.stderr rename src/test/ui/coherence/{coherence-impls-send.stderr => coherence-impls-send.old.stderr} (92%) create mode 100644 src/test/ui/coherence/coherence-impls-send.re.stderr rename src/test/ui/coherence/{coherence-impls-sized.stderr => coherence-impls-sized.old.stderr} (73%) create mode 100644 src/test/ui/coherence/coherence-impls-sized.re.stderr rename src/test/ui/coherence/{coherence-inherited-assoc-ty-cycle-err.stderr => coherence-inherited-assoc-ty-cycle-err.old.stderr} (78%) create mode 100644 src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.re.stderr rename src/test/ui/coherence/{coherence-lone-type-parameter.stderr => coherence-lone-type-parameter.old.stderr} (90%) create mode 100644 src/test/ui/coherence/coherence-lone-type-parameter.re.stderr rename src/test/ui/coherence/{coherence-negative-impls-safe.stderr => coherence-negative-impls-safe.old.stderr} (82%) create mode 100644 src/test/ui/coherence/coherence-negative-impls-safe.re.stderr rename src/test/ui/coherence/{coherence-no-direct-lifetime-dispatch.stderr => coherence-no-direct-lifetime-dispatch.old.stderr} (74%) create mode 100644 src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.re.stderr rename src/test/ui/coherence/{coherence-orphan.stderr => coherence-orphan.old.stderr} (91%) create mode 100644 src/test/ui/coherence/coherence-orphan.re.stderr rename src/test/ui/coherence/{coherence-overlap-all-t-and-tuple.stderr => coherence-overlap-all-t-and-tuple.old.stderr} (75%) create mode 100644 src/test/ui/coherence/coherence-overlap-all-t-and-tuple.re.stderr rename src/test/ui/coherence/{coherence-overlap-downstream-inherent.stderr => coherence-overlap-downstream-inherent.old.stderr} (83%) create mode 100644 src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr rename src/test/ui/coherence/{coherence-overlap-downstream.stderr => coherence-overlap-downstream.old.stderr} (88%) create mode 100644 src/test/ui/coherence/coherence-overlap-downstream.re.stderr rename src/test/ui/coherence/{coherence-overlap-issue-23516-inherent.stderr => coherence-overlap-issue-23516-inherent.old.stderr} (86%) create mode 100644 src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr rename src/test/ui/coherence/{coherence-overlap-issue-23516.stderr => coherence-overlap-issue-23516.old.stderr} (91%) create mode 100644 src/test/ui/coherence/coherence-overlap-issue-23516.re.stderr rename src/test/ui/coherence/{coherence-overlap-messages.stderr => coherence-overlap-messages.old.stderr} (60%) create mode 100644 src/test/ui/coherence/coherence-overlap-messages.re.stderr rename src/test/ui/coherence/{coherence-overlap-upstream-inherent.stderr => coherence-overlap-upstream-inherent.old.stderr} (87%) create mode 100644 src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr rename src/test/ui/coherence/{coherence-overlap-upstream.stderr => coherence-overlap-upstream.old.stderr} (91%) create mode 100644 src/test/ui/coherence/coherence-overlap-upstream.re.stderr rename src/test/ui/coherence/{coherence-overlapping-pairs.stderr => coherence-overlapping-pairs.old.stderr} (91%) create mode 100644 src/test/ui/coherence/coherence-overlapping-pairs.re.stderr rename src/test/ui/coherence/{coherence-pair-covered-uncovered-1.stderr => coherence-pair-covered-uncovered-1.old.stderr} (90%) create mode 100644 src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr rename src/test/ui/coherence/{coherence-pair-covered-uncovered.stderr => coherence-pair-covered-uncovered.old.stderr} (90%) create mode 100644 src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr rename src/test/ui/coherence/{coherence-projection-conflict-orphan.stderr => coherence-projection-conflict-orphan.old.stderr} (80%) create mode 100644 src/test/ui/coherence/coherence-projection-conflict-orphan.re.stderr rename src/test/ui/coherence/{coherence-projection-conflict-ty-param.stderr => coherence-projection-conflict-ty-param.old.stderr} (78%) create mode 100644 src/test/ui/coherence/coherence-projection-conflict-ty-param.re.stderr rename src/test/ui/coherence/{coherence-projection-conflict.stderr => coherence-projection-conflict.old.stderr} (76%) create mode 100644 src/test/ui/coherence/coherence-projection-conflict.re.stderr rename src/test/ui/coherence/{coherence-tuple-conflict.stderr => coherence-tuple-conflict.old.stderr} (79%) create mode 100644 src/test/ui/coherence/coherence-tuple-conflict.re.stderr rename src/test/ui/coherence/{coherence-vec-local-2.stderr => coherence-vec-local-2.old.stderr} (81%) create mode 100644 src/test/ui/coherence/coherence-vec-local-2.re.stderr rename src/test/ui/coherence/{coherence-vec-local.stderr => coherence-vec-local.old.stderr} (81%) create mode 100644 src/test/ui/coherence/coherence-vec-local.re.stderr rename src/test/ui/coherence/{coherence_copy_like_err_fundamental_struct_tuple.stderr => coherence_copy_like_err_fundamental_struct_tuple.old.stderr} (89%) create mode 100644 src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.re.stderr rename src/test/ui/coherence/{coherence_copy_like_err_struct.stderr => coherence_copy_like_err_struct.old.stderr} (82%) create mode 100644 src/test/ui/coherence/coherence_copy_like_err_struct.re.stderr rename src/test/ui/coherence/{coherence_copy_like_err_tuple.stderr => coherence_copy_like_err_tuple.old.stderr} (83%) create mode 100644 src/test/ui/coherence/coherence_copy_like_err_tuple.re.stderr rename src/test/ui/coherence/{coherence_inherent.stderr => coherence_inherent.old.stderr} (80%) create mode 100644 src/test/ui/coherence/coherence_inherent.re.stderr rename src/test/ui/coherence/{coherence_inherent_cc.stderr => coherence_inherent_cc.old.stderr} (81%) create mode 100644 src/test/ui/coherence/coherence_inherent_cc.re.stderr rename src/test/ui/coherence/{coherence_local_err_struct.stderr => coherence_local_err_struct.old.stderr} (78%) create mode 100644 src/test/ui/coherence/coherence_local_err_struct.re.stderr rename src/test/ui/coherence/{coherence_local_err_tuple.stderr => coherence_local_err_tuple.old.stderr} (80%) create mode 100644 src/test/ui/coherence/coherence_local_err_tuple.re.stderr create mode 100644 src/test/ui/coherence/re-rebalance-coherence.rs diff --git a/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs new file mode 100644 index 0000000000000..c8d027b25c748 --- /dev/null +++ b/src/test/ui/coherence/auxiliary/re_rebalance_coherence_lib.rs @@ -0,0 +1,23 @@ + +pub trait Backend{} +pub trait SupportsDefaultKeyword {} + +impl SupportsDefaultKeyword for Postgres {} + +pub struct Postgres; + +impl Backend for Postgres {} + +pub struct AstPass(::std::marker::PhantomData); + +pub trait QueryFragment {} + + +#[derive(Debug, Clone, Copy)] +pub struct BatchInsert<'a, T: 'a, Tab> { + _marker: ::std::marker::PhantomData<(&'a T, Tab)>, +} + +impl<'a, T:'a, Tab, DB> QueryFragment for BatchInsert<'a, T, Tab> +where DB: SupportsDefaultKeyword + Backend, +{} diff --git a/src/test/ui/coherence/coherence-all-remote.stderr b/src/test/ui/coherence/coherence-all-remote.old.stderr similarity index 92% rename from src/test/ui/coherence/coherence-all-remote.stderr rename to src/test/ui/coherence/coherence-all-remote.old.stderr index 3d8afc418ead9..0389a6228efcd 100644 --- a/src/test/ui/coherence/coherence-all-remote.stderr +++ b/src/test/ui/coherence/coherence-all-remote.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-all-remote.rs:6:1 + --> $DIR/coherence-all-remote.rs:9:1 | LL | impl Remote1 for isize { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-all-remote.re.stderr b/src/test/ui/coherence/coherence-all-remote.re.stderr new file mode 100644 index 0000000000000..0389a6228efcd --- /dev/null +++ b/src/test/ui/coherence/coherence-all-remote.re.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-all-remote.rs:9:1 + | +LL | impl Remote1 for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/coherence/coherence-bigint-param.stderr b/src/test/ui/coherence/coherence-bigint-param.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-bigint-param.stderr rename to src/test/ui/coherence/coherence-bigint-param.old.stderr index 81d56349a9e6c..54fec07e65a0d 100644 --- a/src/test/ui/coherence/coherence-bigint-param.stderr +++ b/src/test/ui/coherence/coherence-bigint-param.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-bigint-param.rs:8:1 + --> $DIR/coherence-bigint-param.rs:11:1 | LL | impl Remote1 for T { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-bigint-param.re.stderr b/src/test/ui/coherence/coherence-bigint-param.re.stderr new file mode 100644 index 0000000000000..54fec07e65a0d --- /dev/null +++ b/src/test/ui/coherence/coherence-bigint-param.re.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-bigint-param.rs:11:1 + | +LL | impl Remote1 for T { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.old.stderr similarity index 87% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.old.stderr index 9dd08b9e5583a..a6d29048b4d8c 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:24:1 + --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:28:1 | LL | impl MyTrait for T { | -------------------------- first implementation here ... -LL | impl MyTrait for T { //~ ERROR E0119 +LL | impl MyTrait for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.re.stderr new file mode 100644 index 0000000000000..a6d29048b4d8c --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-implemented.rs:28:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.old.stderr similarity index 86% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.old.stderr index 1719bc60a04de..1f3ddd1dc42c6 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:20:1 + --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:24:1 | LL | impl MyTrait for T { | -------------------------- first implementation here ... -LL | impl MyTrait for T { //~ ERROR E0119 +LL | impl MyTrait for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.re.stderr new file mode 100644 index 0000000000000..1f3ddd1dc42c6 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-blanket-conflicts-with-blanket-unimplemented.rs:24:1 + | +LL | impl MyTrait for T { + | -------------------------- first implementation here +... +LL | impl MyTrait for T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.old.stderr similarity index 84% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.old.stderr index 5872f609e90c0..298ac6d1f2169 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.old.stderr @@ -1,7 +1,7 @@ error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`: - --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:15:1 + --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:18:1 | -LL | impl GoMut for MyThingy { //~ ERROR conflicting implementations +LL | impl GoMut for MyThingy { | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: conflicting implementation in crate `go_trait`: diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.re.stderr new file mode 100644 index 0000000000000..298ac6d1f2169 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.re.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `go_trait::GoMut` for type `MyThingy`: + --> $DIR/coherence-blanket-conflicts-with-specific-cross-crate.rs:18:1 + | +LL | impl GoMut for MyThingy { + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `go_trait`: + - impl go_trait::GoMut for G + where G: go_trait::Go; + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.old.stderr similarity index 86% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.old.stderr index 9de354d8cf67f..94bbbdbe0a404 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:22:1 + --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:26:1 | LL | impl MyTrait for T { | ------------------------ first implementation here ... -LL | impl MyTrait for MyType { //~ ERROR E0119 +LL | impl MyTrait for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.re.stderr new file mode 100644 index 0000000000000..94bbbdbe0a404 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:26:1 + | +LL | impl MyTrait for T { + | ------------------------ first implementation here +... +LL | impl MyTrait for MyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.old.stderr similarity index 77% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.old.stderr index c3f06a952c4b7..cf799c20cb49c 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:20:1 + --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:24:1 | LL | impl MyTrait for T { | -------------------------------- first implementation here ... -LL | impl MyTrait for MyType { //~ ERROR E0119 +LL | impl MyTrait for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.re.stderr new file mode 100644 index 0000000000000..cf799c20cb49c --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific-trait.rs:24:1 + | +LL | impl MyTrait for T { + | -------------------------------- first implementation here +... +LL | impl MyTrait for MyType { + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.old.stderr similarity index 76% rename from src/test/ui/coherence/coherence-blanket-conflicts-with-specific.stderr rename to src/test/ui/coherence/coherence-blanket-conflicts-with-specific.old.stderr index 0b04c5fd0bddf..0807b11a434f9 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.stderr +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: - --> $DIR/coherence-blanket-conflicts-with-specific.rs:19:1 + --> $DIR/coherence-blanket-conflicts-with-specific.rs:23:1 | LL | impl MyTrait for T { | --------------------- first implementation here ... -LL | impl MyTrait for MyType { //~ ERROR E0119 +LL | impl MyTrait for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.re.stderr b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.re.stderr new file mode 100644 index 0000000000000..0807b11a434f9 --- /dev/null +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `MyType`: + --> $DIR/coherence-blanket-conflicts-with-specific.rs:23:1 + | +LL | impl MyTrait for T { + | --------------------- first implementation here +... +LL | impl MyTrait for MyType { + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.old.stderr similarity index 87% rename from src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr rename to src/test/ui/coherence/coherence-conflicting-negative-trait-impl.old.stderr index 0a8bbc4bc50a8..bb3641f224780 100644 --- a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.stderr +++ b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: - --> $DIR/coherence-conflicting-negative-trait-impl.rs:10:1 + --> $DIR/coherence-conflicting-negative-trait-impl.rs:13:1 | LL | unsafe impl Send for TestType {} | ---------------------------------------------------- first implementation here @@ -8,7 +8,7 @@ LL | impl !Send for TestType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType`: - --> $DIR/coherence-conflicting-negative-trait-impl.rs:15:1 + --> $DIR/coherence-conflicting-negative-trait-impl.rs:19:1 | LL | unsafe impl Send for TestType {} | ------------------------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.re.stderr b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.re.stderr new file mode 100644 index 0000000000000..bb3641f224780 --- /dev/null +++ b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.re.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType<_>`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:13:1 + | +LL | unsafe impl Send for TestType {} + | ---------------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` + +error[E0119]: conflicting implementations of trait `std::marker::Send` for type `TestType`: + --> $DIR/coherence-conflicting-negative-trait-impl.rs:19:1 + | +LL | unsafe impl Send for TestType {} + | ------------------------------------------- first implementation here +LL | +LL | impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-cow.a.stderr b/src/test/ui/coherence/coherence-cow.a.stderr index 2a3e57b1ce25b..dd9cfab503f72 100644 --- a/src/test/ui/coherence/coherence-cow.a.stderr +++ b/src/test/ui/coherence/coherence-cow.a.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:28:1 + --> $DIR/coherence-cow.rs:18:1 | LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-cow.b.stderr b/src/test/ui/coherence/coherence-cow.b.stderr index 0512baef13669..fb3ca3fc6b777 100644 --- a/src/test/ui/coherence/coherence-cow.b.stderr +++ b/src/test/ui/coherence/coherence-cow.b.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:33:1 + --> $DIR/coherence-cow.rs:23:1 | LL | impl Remote for Pair,T> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-cow.c.stderr b/src/test/ui/coherence/coherence-cow.c.stderr index 1a95d82a03acf..f17823b7f8954 100644 --- a/src/test/ui/coherence/coherence-cow.c.stderr +++ b/src/test/ui/coherence/coherence-cow.c.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:38:1 + --> $DIR/coherence-cow.rs:28:1 | LL | impl Remote for Pair,U> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-cow.re_a.stderr b/src/test/ui/coherence/coherence-cow.re_a.stderr new file mode 100644 index 0000000000000..ed627600b0f5d --- /dev/null +++ b/src/test/ui/coherence/coherence-cow.re_a.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:18:1 + | +LL | impl Remote for Pair> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-cow.re_b.stderr b/src/test/ui/coherence/coherence-cow.re_b.stderr new file mode 100644 index 0000000000000..1a85887ae7bc4 --- /dev/null +++ b/src/test/ui/coherence/coherence-cow.re_b.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:23:1 + | +LL | impl Remote for Pair,T> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-cow.re_c.stderr b/src/test/ui/coherence/coherence-cow.re_c.stderr new file mode 100644 index 0000000000000..8043b6702b07e --- /dev/null +++ b/src/test/ui/coherence/coherence-cow.re_c.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-cow.rs:28:1 + | +LL | impl Remote for Pair,U> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.stderr b/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr similarity index 88% rename from src/test/ui/coherence/coherence-cross-crate-conflict.stderr rename to src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr index 4a73aa357d076..3ba32a528354e 100644 --- a/src/test/ui/coherence/coherence-cross-crate-conflict.stderr +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`: - --> $DIR/coherence-cross-crate-conflict.rs:8:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:1 | LL | impl Foo for A { | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | impl Foo for A { - impl trait_impl_conflict::Foo for isize; error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cross-crate-conflict.rs:8:1 + --> $DIR/coherence-cross-crate-conflict.rs:12:1 | LL | impl Foo for A { | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr b/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr new file mode 100644 index 0000000000000..3ba32a528354e --- /dev/null +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.re.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize`: + --> $DIR/coherence-cross-crate-conflict.rs:12:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `trait_impl_conflict`: + - impl trait_impl_conflict::Foo for isize; + +error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-cross-crate-conflict.rs:12:1 + | +LL | impl Foo for A { + | ^^^^^^^^^^^^^^^^^ type parameter `A` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to 2 previous errors + +Some errors occurred: E0119, E0210. +For more information about an error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-default-trait-impl.stderr b/src/test/ui/coherence/coherence-default-trait-impl.old.stderr similarity index 82% rename from src/test/ui/coherence/coherence-default-trait-impl.stderr rename to src/test/ui/coherence/coherence-default-trait-impl.old.stderr index 6309d60dd9675..534f4b0dcdb3c 100644 --- a/src/test/ui/coherence/coherence-default-trait-impl.stderr +++ b/src/test/ui/coherence/coherence-default-trait-impl.old.stderr @@ -1,11 +1,11 @@ error[E0199]: implementing the trait `MySafeTrait` is not unsafe - --> $DIR/coherence-default-trait-impl.rs:7:1 + --> $DIR/coherence-default-trait-impl.rs:10:1 | LL | unsafe impl MySafeTrait for Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration - --> $DIR/coherence-default-trait-impl.rs:12:1 + --> $DIR/coherence-default-trait-impl.rs:16:1 | LL | impl MyUnsafeTrait for Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/coherence/coherence-default-trait-impl.re.stderr b/src/test/ui/coherence/coherence-default-trait-impl.re.stderr new file mode 100644 index 0000000000000..534f4b0dcdb3c --- /dev/null +++ b/src/test/ui/coherence/coherence-default-trait-impl.re.stderr @@ -0,0 +1,16 @@ +error[E0199]: implementing the trait `MySafeTrait` is not unsafe + --> $DIR/coherence-default-trait-impl.rs:10:1 + | +LL | unsafe impl MySafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0200]: the trait `MyUnsafeTrait` requires an `unsafe impl` declaration + --> $DIR/coherence-default-trait-impl.rs:16:1 + | +LL | impl MyUnsafeTrait for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors occurred: E0199, E0200. +For more information about an error, try `rustc --explain E0199`. diff --git a/src/test/ui/coherence/coherence-error-suppression.stderr b/src/test/ui/coherence/coherence-error-suppression.old.stderr similarity index 62% rename from src/test/ui/coherence/coherence-error-suppression.stderr rename to src/test/ui/coherence/coherence-error-suppression.old.stderr index 17a3c62772005..b81f75533176f 100644 --- a/src/test/ui/coherence/coherence-error-suppression.stderr +++ b/src/test/ui/coherence/coherence-error-suppression.old.stderr @@ -1,7 +1,7 @@ error[E0412]: cannot find type `DoesNotExist` in this scope - --> $DIR/coherence-error-suppression.rs:9:14 + --> $DIR/coherence-error-suppression.rs:13:14 | -LL | impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope +LL | impl Foo for DoesNotExist {} | ^^^^^^^^^^^^ not found in this scope error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-error-suppression.re.stderr b/src/test/ui/coherence/coherence-error-suppression.re.stderr new file mode 100644 index 0000000000000..b81f75533176f --- /dev/null +++ b/src/test/ui/coherence/coherence-error-suppression.re.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `DoesNotExist` in this scope + --> $DIR/coherence-error-suppression.rs:13:14 + | +LL | impl Foo for DoesNotExist {} + | ^^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr similarity index 73% rename from src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr rename to src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr index a19b00194c341..b48f6bbfb9417 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.old.stderr @@ -1,7 +1,7 @@ error[E0038]: the trait `NotObjectSafe` cannot be made into an object - --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:7:6 + --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 | -LL | impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 +LL | impl NotObjectSafe for NotObjectSafe { } | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object | = note: method `eq` references the `Self` type in its arguments or return type diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr new file mode 100644 index 0000000000000..b48f6bbfb9417 --- /dev/null +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.re.stderr @@ -0,0 +1,11 @@ +error[E0038]: the trait `NotObjectSafe` cannot be made into an object + --> $DIR/coherence-impl-trait-for-trait-object-safe.rs:11:6 + | +LL | impl NotObjectSafe for NotObjectSafe { } + | ^^^^^^^^^^^^^ the trait `NotObjectSafe` cannot be made into an object + | + = note: method `eq` references the `Self` type in its arguments or return type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr similarity index 69% rename from src/test/ui/coherence/coherence-impl-trait-for-trait.stderr rename to src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr index 05abef145b7e3..324747603f911 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.stderr +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.old.stderr @@ -1,19 +1,19 @@ error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` - --> $DIR/coherence-impl-trait-for-trait.rs:9:1 + --> $DIR/coherence-impl-trait-for-trait.rs:13:1 | -LL | impl Foo for Baz { } //~ ERROR E0371 +LL | impl Foo for Baz { } | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` - --> $DIR/coherence-impl-trait-for-trait.rs:10:1 + --> $DIR/coherence-impl-trait-for-trait.rs:16:1 | -LL | impl Bar for Baz { } //~ ERROR E0371 +LL | impl Bar for Baz { } | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` - --> $DIR/coherence-impl-trait-for-trait.rs:11:1 + --> $DIR/coherence-impl-trait-for-trait.rs:19:1 | -LL | impl Baz for Baz { } //~ ERROR E0371 +LL | impl Baz for Baz { } | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` error: aborting due to 3 previous errors diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr new file mode 100644 index 0000000000000..324747603f911 --- /dev/null +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.re.stderr @@ -0,0 +1,21 @@ +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Foo` + --> $DIR/coherence-impl-trait-for-trait.rs:13:1 + | +LL | impl Foo for Baz { } + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Foo` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Bar` + --> $DIR/coherence-impl-trait-for-trait.rs:16:1 + | +LL | impl Bar for Baz { } + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Bar` + +error[E0371]: the object type `(dyn Baz + 'static)` automatically implements the trait `Baz` + --> $DIR/coherence-impl-trait-for-trait.rs:19:1 + | +LL | impl Baz for Baz { } + | ^^^^^^^^^^^^^^^^ `(dyn Baz + 'static)` automatically implements trait `Baz` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0371`. diff --git a/src/test/ui/coherence/coherence-impls-copy.stderr b/src/test/ui/coherence/coherence-impls-copy.old.stderr similarity index 89% rename from src/test/ui/coherence/coherence-impls-copy.stderr rename to src/test/ui/coherence/coherence-impls-copy.old.stderr index b528bf8fa5991..defbbbadd5598 100644 --- a/src/test/ui/coherence/coherence-impls-copy.stderr +++ b/src/test/ui/coherence/coherence-impls-copy.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`: - --> $DIR/coherence-impls-copy.rs:5:1 + --> $DIR/coherence-impls-copy.rs:8:1 | LL | impl Copy for i32 {} | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | impl Copy for i32 {} - impl std::marker::Copy for i32; error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: - --> $DIR/coherence-impls-copy.rs:31:1 + --> $DIR/coherence-impls-copy.rs:37:1 | LL | impl Copy for &'static NotSync {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | impl Copy for &'static NotSync {} where T: ?Sized; error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: - --> $DIR/coherence-impls-copy.rs:38:1 + --> $DIR/coherence-impls-copy.rs:45:1 | LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,25 +28,25 @@ LL | impl Copy for &'static [NotSync] {} where T: ?Sized; error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:23:15 + --> $DIR/coherence-impls-copy.rs:27:15 | LL | impl Copy for &'static mut MyType {} | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:27:15 + --> $DIR/coherence-impls-copy.rs:32:15 | LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/coherence-impls-copy.rs:34:15 + --> $DIR/coherence-impls-copy.rs:40:15 | LL | impl Copy for [MyType] {} | ^^^^^^^^ type is not a structure or enumeration error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:5:1 + --> $DIR/coherence-impls-copy.rs:8:1 | LL | impl Copy for i32 {} | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -55,7 +55,7 @@ LL | impl Copy for i32 {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:27:1 + --> $DIR/coherence-impls-copy.rs:32:1 | LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -64,7 +64,7 @@ LL | impl Copy for (MyType, MyType) {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:34:1 + --> $DIR/coherence-impls-copy.rs:40:1 | LL | impl Copy for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -73,7 +73,7 @@ LL | impl Copy for [MyType] {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-copy.rs:38:1 + --> $DIR/coherence-impls-copy.rs:45:1 | LL | impl Copy for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate diff --git a/src/test/ui/coherence/coherence-impls-copy.re.stderr b/src/test/ui/coherence/coherence-impls-copy.re.stderr new file mode 100644 index 0000000000000..defbbbadd5598 --- /dev/null +++ b/src/test/ui/coherence/coherence-impls-copy.re.stderr @@ -0,0 +1,87 @@ +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `i32`: + --> $DIR/coherence-impls-copy.rs:8:1 + | +LL | impl Copy for i32 {} + | ^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for i32; + +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: + --> $DIR/coherence-impls-copy.rs:37:1 + | +LL | impl Copy for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for &T + where T: ?Sized; + +error[E0119]: conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: + --> $DIR/coherence-impls-copy.rs:45:1 + | +LL | impl Copy for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: conflicting implementation in crate `core`: + - impl std::marker::Copy for &T + where T: ?Sized; + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:27:15 + | +LL | impl Copy for &'static mut MyType {} + | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:32:15 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/coherence-impls-copy.rs:40:15 + | +LL | impl Copy for [MyType] {} + | ^^^^^^^^ type is not a structure or enumeration + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:8:1 + | +LL | impl Copy for i32 {} + | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:32:1 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:40:1 + | +LL | impl Copy for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-copy.rs:45:1 + | +LL | impl Copy for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 10 previous errors + +Some errors occurred: E0117, E0119, E0206. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-impls-send.stderr b/src/test/ui/coherence/coherence-impls-send.old.stderr similarity index 92% rename from src/test/ui/coherence/coherence-impls-send.stderr rename to src/test/ui/coherence/coherence-impls-send.old.stderr index 02d90eea8fe6a..ca45c28ec2d74 100644 --- a/src/test/ui/coherence/coherence-impls-send.stderr +++ b/src/test/ui/coherence/coherence-impls-send.old.stderr @@ -1,5 +1,5 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:17:1 + --> $DIR/coherence-impls-send.rs:20:1 | LL | unsafe impl Send for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -8,13 +8,13 @@ LL | unsafe impl Send for (MyType, MyType) {} = note: define and implement a trait or new type instead error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` - --> $DIR/coherence-impls-send.rs:20:1 + --> $DIR/coherence-impls-send.rs:24:1 | LL | unsafe impl Send for &'static NotSync {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:23:1 + --> $DIR/coherence-impls-send.rs:28:1 | LL | unsafe impl Send for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -23,7 +23,7 @@ LL | unsafe impl Send for [MyType] {} = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-send.rs:26:1 + --> $DIR/coherence-impls-send.rs:32:1 | LL | unsafe impl Send for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate diff --git a/src/test/ui/coherence/coherence-impls-send.re.stderr b/src/test/ui/coherence/coherence-impls-send.re.stderr new file mode 100644 index 0000000000000..ca45c28ec2d74 --- /dev/null +++ b/src/test/ui/coherence/coherence-impls-send.re.stderr @@ -0,0 +1,37 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:20:1 + | +LL | unsafe impl Send for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `&'static NotSync` + --> $DIR/coherence-impls-send.rs:24:1 + | +LL | unsafe impl Send for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:28:1 + | +LL | unsafe impl Send for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-send.rs:32:1 + | +LL | unsafe impl Send for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 4 previous errors + +Some errors occurred: E0117, E0321. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-impls-sized.stderr b/src/test/ui/coherence/coherence-impls-sized.old.stderr similarity index 73% rename from src/test/ui/coherence/coherence-impls-sized.stderr rename to src/test/ui/coherence/coherence-impls-sized.old.stderr index fbe08a59f5258..c9c7dd0ed6688 100644 --- a/src/test/ui/coherence/coherence-impls-sized.stderr +++ b/src/test/ui/coherence/coherence-impls-sized.old.stderr @@ -1,61 +1,61 @@ error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:14:1 + --> $DIR/coherence-impls-sized.rs:17:1 | -LL | impl Sized for TestE {} //~ ERROR E0322 +LL | impl Sized for TestE {} | ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:17:1 + --> $DIR/coherence-impls-sized.rs:22:1 | -LL | impl Sized for MyType {} //~ ERROR E0322 +LL | impl Sized for MyType {} | ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:20:1 + --> $DIR/coherence-impls-sized.rs:27:1 | -LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 +LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:24:1 + --> $DIR/coherence-impls-sized.rs:34:1 | -LL | impl Sized for &'static NotSync {} //~ ERROR E0322 +LL | impl Sized for &'static NotSync {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:27:1 + --> $DIR/coherence-impls-sized.rs:39:1 | -LL | impl Sized for [MyType] {} //~ ERROR E0322 +LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0322]: explicit impls for the `Sized` trait are not permitted - --> $DIR/coherence-impls-sized.rs:31:1 + --> $DIR/coherence-impls-sized.rs:46:1 | -LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 +LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:20:1 + --> $DIR/coherence-impls-sized.rs:27:1 | -LL | impl Sized for (MyType, MyType) {} //~ ERROR E0322 +LL | impl Sized for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:27:1 + --> $DIR/coherence-impls-sized.rs:39:1 | -LL | impl Sized for [MyType] {} //~ ERROR E0322 +LL | impl Sized for [MyType] {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-impls-sized.rs:31:1 + --> $DIR/coherence-impls-sized.rs:46:1 | -LL | impl Sized for &'static [NotSync] {} //~ ERROR E0322 +LL | impl Sized for &'static [NotSync] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence-impls-sized.re.stderr b/src/test/ui/coherence/coherence-impls-sized.re.stderr new file mode 100644 index 0000000000000..c9c7dd0ed6688 --- /dev/null +++ b/src/test/ui/coherence/coherence-impls-sized.re.stderr @@ -0,0 +1,67 @@ +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:17:1 + | +LL | impl Sized for TestE {} + | ^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:22:1 + | +LL | impl Sized for MyType {} + | ^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:27:1 + | +LL | impl Sized for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:34:1 + | +LL | impl Sized for &'static NotSync {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:39:1 + | +LL | impl Sized for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0322]: explicit impls for the `Sized` trait are not permitted + --> $DIR/coherence-impls-sized.rs:46:1 + | +LL | impl Sized for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of 'Sized' not allowed + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:27:1 + | +LL | impl Sized for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:39:1 + | +LL | impl Sized for [MyType] {} + | ^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-impls-sized.rs:46:1 + | +LL | impl Sized for &'static [NotSync] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 9 previous errors + +Some errors occurred: E0117, E0322. +For more information about an error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.old.stderr similarity index 78% rename from src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr rename to src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.old.stderr index 0b9f03db5c6b7..a2fa49acd2c90 100644 --- a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr +++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.old.stderr @@ -1,12 +1,12 @@ error[E0391]: cycle detected when processing `Trait` - --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:9:1 + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 | LL | trait Trait { type Assoc; } | ^^^^^^^^^^^^^^ | = note: ...which again requires processing `Trait`, completing the cycle note: cycle used when coherence checking all impls of trait `Trait` - --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:9:1 + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 | LL | trait Trait { type Assoc; } | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.re.stderr b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.re.stderr new file mode 100644 index 0000000000000..a2fa49acd2c90 --- /dev/null +++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.re.stderr @@ -0,0 +1,16 @@ +error[E0391]: cycle detected when processing `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + | + = note: ...which again requires processing `Trait`, completing the cycle +note: cycle used when coherence checking all impls of trait `Trait` + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:12:1 + | +LL | trait Trait { type Assoc; } + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.stderr b/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr similarity index 90% rename from src/test/ui/coherence/coherence-lone-type-parameter.stderr rename to src/test/ui/coherence/coherence-lone-type-parameter.old.stderr index 68e2dae095fa9..ac77241e9e791 100644 --- a/src/test/ui/coherence/coherence-lone-type-parameter.stderr +++ b/src/test/ui/coherence/coherence-lone-type-parameter.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-lone-type-parameter.rs:6:1 + --> $DIR/coherence-lone-type-parameter.rs:9:1 | LL | impl Remote for T { } | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr b/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr new file mode 100644 index 0000000000000..ac77241e9e791 --- /dev/null +++ b/src/test/ui/coherence/coherence-lone-type-parameter.re.stderr @@ -0,0 +1,11 @@ +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) + --> $DIR/coherence-lone-type-parameter.rs:9:1 + | +LL | impl Remote for T { } + | ^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0210`. diff --git a/src/test/ui/coherence/coherence-negative-impls-safe.stderr b/src/test/ui/coherence/coherence-negative-impls-safe.old.stderr similarity index 82% rename from src/test/ui/coherence/coherence-negative-impls-safe.stderr rename to src/test/ui/coherence/coherence-negative-impls-safe.old.stderr index c47c9d25e3614..7ed47dca4972d 100644 --- a/src/test/ui/coherence/coherence-negative-impls-safe.stderr +++ b/src/test/ui/coherence/coherence-negative-impls-safe.old.stderr @@ -1,5 +1,5 @@ error[E0198]: negative impls cannot be unsafe - --> $DIR/coherence-negative-impls-safe.rs:7:1 + --> $DIR/coherence-negative-impls-safe.rs:10:1 | LL | unsafe impl !Send for TestType {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/coherence/coherence-negative-impls-safe.re.stderr b/src/test/ui/coherence/coherence-negative-impls-safe.re.stderr new file mode 100644 index 0000000000000..7ed47dca4972d --- /dev/null +++ b/src/test/ui/coherence/coherence-negative-impls-safe.re.stderr @@ -0,0 +1,9 @@ +error[E0198]: negative impls cannot be unsafe + --> $DIR/coherence-negative-impls-safe.rs:10:1 + | +LL | unsafe impl !Send for TestType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0198`. diff --git a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.stderr b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.old.stderr similarity index 74% rename from src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.stderr rename to src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.old.stderr index f1cc0088cf1ef..81465e7185676 100644 --- a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.stderr +++ b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.old.stderr @@ -1,9 +1,9 @@ error[E0119]: conflicting implementations of trait `MyTrait`: - --> $DIR/coherence-no-direct-lifetime-dispatch.rs:6:1 + --> $DIR/coherence-no-direct-lifetime-dispatch.rs:10:1 | LL | impl MyTrait for T {} | --------------------- first implementation here -LL | impl MyTrait for T {} //~ ERROR E0119 +LL | impl MyTrait for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.re.stderr b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.re.stderr new file mode 100644 index 0000000000000..81465e7185676 --- /dev/null +++ b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.re.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `MyTrait`: + --> $DIR/coherence-no-direct-lifetime-dispatch.rs:10:1 + | +LL | impl MyTrait for T {} + | --------------------- first implementation here +LL | impl MyTrait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-orphan.stderr b/src/test/ui/coherence/coherence-orphan.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-orphan.stderr rename to src/test/ui/coherence/coherence-orphan.old.stderr index 1b32faf970cb7..da5de461bf41b 100644 --- a/src/test/ui/coherence/coherence-orphan.stderr +++ b/src/test/ui/coherence/coherence-orphan.old.stderr @@ -1,5 +1,5 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-orphan.rs:11:1 + --> $DIR/coherence-orphan.rs:13:1 | LL | impl TheTrait for isize { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate @@ -8,7 +8,7 @@ LL | impl TheTrait for isize { } = note: define and implement a trait or new type instead error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-orphan.rs:18:1 + --> $DIR/coherence-orphan.rs:21:1 | LL | impl !Send for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate diff --git a/src/test/ui/coherence/coherence-orphan.re.stderr b/src/test/ui/coherence/coherence-orphan.re.stderr new file mode 100644 index 0000000000000..da5de461bf41b --- /dev/null +++ b/src/test/ui/coherence/coherence-orphan.re.stderr @@ -0,0 +1,21 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:13:1 + | +LL | impl TheTrait for isize { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-orphan.rs:21:1 + | +LL | impl !Send for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.stderr b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.old.stderr similarity index 75% rename from src/test/ui/coherence/coherence-overlap-all-t-and-tuple.stderr rename to src/test/ui/coherence/coherence-overlap-all-t-and-tuple.old.stderr index 2bb3031edce09..c7f85b0b59078 100644 --- a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.stderr +++ b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`: - --> $DIR/coherence-overlap-all-t-and-tuple.rs:16:1 + --> $DIR/coherence-overlap-all-t-and-tuple.rs:20:1 | LL | impl From for T { | ---------------------- first implementation here ... -LL | impl From<(U11,)> for (T11,) { //~ ERROR E0119 +LL | impl From<(U11,)> for (T11,) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.re.stderr b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.re.stderr new file mode 100644 index 0000000000000..c7f85b0b59078 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `From<(_,)>` for type `(_,)`: + --> $DIR/coherence-overlap-all-t-and-tuple.rs:20:1 + | +LL | impl From for T { + | ---------------------- first implementation here +... +LL | impl From<(U11,)> for (T11,) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr b/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr similarity index 83% rename from src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr rename to src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr index 9a060edb5b1bf..dcfc017f1b038 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream-inherent.stderr +++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.old.stderr @@ -1,18 +1,18 @@ error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-downstream-inherent.rs:7:26 + --> $DIR/coherence-overlap-downstream-inherent.rs:11:26 | LL | impl Sweet { fn dummy(&self) { } } | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 +... LL | impl Sweet { fn dummy(&self) { } } | ------------------- other definition for `dummy` error[E0592]: duplicate definitions with name `f` - --> $DIR/coherence-overlap-downstream-inherent.rs:13:38 + --> $DIR/coherence-overlap-downstream-inherent.rs:18:38 | LL | impl A where T: Bar { fn f(&self) {} } | ^^^^^^^^^^^^^^ duplicate definitions for `f` -LL | //~^ ERROR E0592 +... LL | impl A { fn f(&self) {} } | -------------- other definition for `f` | diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr new file mode 100644 index 0000000000000..dcfc017f1b038 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.re.stderr @@ -0,0 +1,23 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-downstream-inherent.rs:11:26 + | +LL | impl Sweet { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +... +LL | impl Sweet { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + +error[E0592]: duplicate definitions with name `f` + --> $DIR/coherence-overlap-downstream-inherent.rs:18:38 + | +LL | impl A where T: Bar { fn f(&self) {} } + | ^^^^^^^^^^^^^^ duplicate definitions for `f` +... +LL | impl A { fn f(&self) {} } + | -------------- other definition for `f` + | + = note: downstream crates may implement trait `Bar<_>` for type `i32` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/coherence/coherence-overlap-downstream.stderr b/src/test/ui/coherence/coherence-overlap-downstream.old.stderr similarity index 88% rename from src/test/ui/coherence/coherence-overlap-downstream.stderr rename to src/test/ui/coherence/coherence-overlap-downstream.old.stderr index 6fb398562d6be..b4847c03d4179 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream.stderr +++ b/src/test/ui/coherence/coherence-overlap-downstream.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Sweet`: - --> $DIR/coherence-overlap-downstream.rs:8:1 + --> $DIR/coherence-overlap-downstream.rs:12:1 | LL | impl Sweet for T { } | ------------------------- first implementation here @@ -7,7 +7,7 @@ LL | impl Sweet for T { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`: - --> $DIR/coherence-overlap-downstream.rs:14:1 + --> $DIR/coherence-overlap-downstream.rs:19:1 | LL | impl Foo for T where T: Bar {} | --------------------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-overlap-downstream.re.stderr b/src/test/ui/coherence/coherence-overlap-downstream.re.stderr new file mode 100644 index 0000000000000..b4847c03d4179 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-downstream.re.stderr @@ -0,0 +1,21 @@ +error[E0119]: conflicting implementations of trait `Sweet`: + --> $DIR/coherence-overlap-downstream.rs:12:1 + | +LL | impl Sweet for T { } + | ------------------------- first implementation here +LL | impl Sweet for T { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`: + --> $DIR/coherence-overlap-downstream.rs:19:1 + | +LL | impl Foo for T where T: Bar {} + | --------------------------------------- first implementation here +LL | impl Foo for i32 {} + | ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | + = note: downstream crates may implement trait `Bar<_>` for type `i32` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr similarity index 86% rename from src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr rename to src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr index 6e5d116bce243..6fd9307754033 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.stderr +++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.old.stderr @@ -1,9 +1,9 @@ error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-issue-23516-inherent.rs:9:25 + --> $DIR/coherence-overlap-issue-23516-inherent.rs:13:25 | LL | impl Cake { fn dummy(&self) { } } | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 +... LL | impl Cake> { fn dummy(&self) { } } | ------------------- other definition for `dummy` | diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr new file mode 100644 index 0000000000000..6fd9307754033 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.re.stderr @@ -0,0 +1,14 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-issue-23516-inherent.rs:13:25 + | +LL | impl Cake { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +... +LL | impl Cake> { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + | + = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-overlap-issue-23516.stderr rename to src/test/ui/coherence/coherence-overlap-issue-23516.old.stderr index fe4c5cf3490dd..d17d67adf0eae 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516.stderr +++ b/src/test/ui/coherence/coherence-overlap-issue-23516.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>`: - --> $DIR/coherence-overlap-issue-23516.rs:8:1 + --> $DIR/coherence-overlap-issue-23516.rs:12:1 | LL | impl Sweet for T { } | ------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516.re.stderr b/src/test/ui/coherence/coherence-overlap-issue-23516.re.stderr new file mode 100644 index 0000000000000..d17d67adf0eae --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-issue-23516.re.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Sweet` for type `std::boxed::Box<_>`: + --> $DIR/coherence-overlap-issue-23516.rs:12:1 + | +LL | impl Sweet for T { } + | ------------------------- first implementation here +LL | impl Sweet for Box { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::boxed::Box<_>` + | + = note: downstream crates may implement trait `Sugar` for type `std::boxed::Box<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-messages.stderr b/src/test/ui/coherence/coherence-overlap-messages.old.stderr similarity index 60% rename from src/test/ui/coherence/coherence-overlap-messages.stderr rename to src/test/ui/coherence/coherence-overlap-messages.old.stderr index f78482fc59796..429e67573b59b 100644 --- a/src/test/ui/coherence/coherence-overlap-messages.stderr +++ b/src/test/ui/coherence/coherence-overlap-messages.old.stderr @@ -1,42 +1,42 @@ error[E0119]: conflicting implementations of trait `Foo`: - --> $DIR/coherence-overlap-messages.rs:4:1 + --> $DIR/coherence-overlap-messages.rs:8:1 | LL | impl Foo for T {} | ----------------- first implementation here -LL | impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: +LL | impl Foo for U {} | ^^^^^^^^^^^^^^^^^ conflicting implementation error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: - --> $DIR/coherence-overlap-messages.rs:9:1 + --> $DIR/coherence-overlap-messages.rs:16:1 | LL | impl Bar for (T, u8) {} | ----------------------- first implementation here -LL | impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: +LL | impl Bar for (u8, T) {} | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` error[E0119]: conflicting implementations of trait `Baz` for type `u8`: - --> $DIR/coherence-overlap-messages.rs:14:1 + --> $DIR/coherence-overlap-messages.rs:23:1 | LL | impl Baz for T {} | --------------------- first implementation here -LL | impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: +LL | impl Baz for u8 {} | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` error[E0119]: conflicting implementations of trait `Quux<_, _>`: - --> $DIR/coherence-overlap-messages.rs:19:1 + --> $DIR/coherence-overlap-messages.rs:30:1 | LL | impl Quux for T {} | ------------------------------ first implementation here -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +LL | impl Quux for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error[E0119]: conflicting implementations of trait `Quux<_, _>`: - --> $DIR/coherence-overlap-messages.rs:20:1 + --> $DIR/coherence-overlap-messages.rs:33:1 | LL | impl Quux for T {} | ------------------------------ first implementation here -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: -LL | impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +... +LL | impl Quux for T {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to 5 previous errors diff --git a/src/test/ui/coherence/coherence-overlap-messages.re.stderr b/src/test/ui/coherence/coherence-overlap-messages.re.stderr new file mode 100644 index 0000000000000..429e67573b59b --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-messages.re.stderr @@ -0,0 +1,44 @@ +error[E0119]: conflicting implementations of trait `Foo`: + --> $DIR/coherence-overlap-messages.rs:8:1 + | +LL | impl Foo for T {} + | ----------------- first implementation here +LL | impl Foo for U {} + | ^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Bar` for type `(u8, u8)`: + --> $DIR/coherence-overlap-messages.rs:16:1 + | +LL | impl Bar for (T, u8) {} + | ----------------------- first implementation here +LL | impl Bar for (u8, T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(u8, u8)` + +error[E0119]: conflicting implementations of trait `Baz` for type `u8`: + --> $DIR/coherence-overlap-messages.rs:23:1 + | +LL | impl Baz for T {} + | --------------------- first implementation here +LL | impl Baz for u8 {} + | ^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:30:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +LL | impl Quux for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error[E0119]: conflicting implementations of trait `Quux<_, _>`: + --> $DIR/coherence-overlap-messages.rs:33:1 + | +LL | impl Quux for T {} + | ------------------------------ first implementation here +... +LL | impl Quux for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr b/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr similarity index 87% rename from src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr rename to src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr index 195b7dba74d84..928b65e003918 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream-inherent.stderr +++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.old.stderr @@ -1,9 +1,9 @@ error[E0592]: duplicate definitions with name `dummy` - --> $DIR/coherence-overlap-upstream-inherent.rs:11:32 + --> $DIR/coherence-overlap-upstream-inherent.rs:15:32 | LL | impl A where T: Remote { fn dummy(&self) { } } | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` -LL | //~^ ERROR E0592 +... LL | impl A { fn dummy(&self) { } } | ------------------- other definition for `dummy` | diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr b/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr new file mode 100644 index 0000000000000..928b65e003918 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.re.stderr @@ -0,0 +1,14 @@ +error[E0592]: duplicate definitions with name `dummy` + --> $DIR/coherence-overlap-upstream-inherent.rs:15:32 + | +LL | impl A where T: Remote { fn dummy(&self) { } } + | ^^^^^^^^^^^^^^^^^^^ duplicate definitions for `dummy` +... +LL | impl A { fn dummy(&self) { } } + | ------------------- other definition for `dummy` + | + = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0592`. diff --git a/src/test/ui/coherence/coherence-overlap-upstream.stderr b/src/test/ui/coherence/coherence-overlap-upstream.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-overlap-upstream.stderr rename to src/test/ui/coherence/coherence-overlap-upstream.old.stderr index 4095949df1344..6c3484c2d8c4d 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream.stderr +++ b/src/test/ui/coherence/coherence-overlap-upstream.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i16`: - --> $DIR/coherence-overlap-upstream.rs:12:1 + --> $DIR/coherence-overlap-upstream.rs:16:1 | LL | impl Foo for T where T: Remote {} | --------------------------------- first implementation here diff --git a/src/test/ui/coherence/coherence-overlap-upstream.re.stderr b/src/test/ui/coherence/coherence-overlap-upstream.re.stderr new file mode 100644 index 0000000000000..6c3484c2d8c4d --- /dev/null +++ b/src/test/ui/coherence/coherence-overlap-upstream.re.stderr @@ -0,0 +1,13 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i16`: + --> $DIR/coherence-overlap-upstream.rs:16:1 + | +LL | impl Foo for T where T: Remote {} + | --------------------------------- first implementation here +LL | impl Foo for i16 {} + | ^^^^^^^^^^^^^^^^ conflicting implementation for `i16` + | + = note: upstream crates may add new impl of trait `coherence_lib::Remote` for type `i16` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr similarity index 91% rename from src/test/ui/coherence/coherence-overlapping-pairs.stderr rename to src/test/ui/coherence/coherence-overlapping-pairs.old.stderr index 19f283e89d1ac..b275af9668d16 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.stderr +++ b/src/test/ui/coherence/coherence-overlapping-pairs.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-overlapping-pairs.rs:8:1 + --> $DIR/coherence-overlapping-pairs.rs:11:1 | LL | impl Remote for lib::Pair { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr new file mode 100644 index 0000000000000..0f2ec6f4ce069 --- /dev/null +++ b/src/test/ui/coherence/coherence-overlapping-pairs.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-overlapping-pairs.rs:11:1 + | +LL | impl Remote for lib::Pair { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr similarity index 90% rename from src/test/ui/coherence/coherence-pair-covered-uncovered-1.stderr rename to src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr index 072a98cf35848..8b25bee6e2f82 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-pair-covered-uncovered-1.rs:11:1 + --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 | LL | impl Remote1>> for i32 { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr new file mode 100644 index 0000000000000..0c654ca41835d --- /dev/null +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-pair-covered-uncovered-1.rs:15:1 + | +LL | impl Remote1>> for i32 { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr similarity index 90% rename from src/test/ui/coherence/coherence-pair-covered-uncovered.stderr rename to src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr index 3ba53829e3494..39558d8dcc037 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.stderr +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.old.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-pair-covered-uncovered.rs:8:1 + --> $DIR/coherence-pair-covered-uncovered.rs:11:1 | LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr new file mode 100644 index 0000000000000..9bddc15390212 --- /dev/null +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-pair-covered-uncovered.rs:11:1 + | +LL | impl Remote for Pair> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-projection-conflict-orphan.stderr b/src/test/ui/coherence/coherence-projection-conflict-orphan.old.stderr similarity index 80% rename from src/test/ui/coherence/coherence-projection-conflict-orphan.stderr rename to src/test/ui/coherence/coherence-projection-conflict-orphan.old.stderr index 6929d9f3312c7..cde9360ddf2c8 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-orphan.stderr +++ b/src/test/ui/coherence/coherence-projection-conflict-orphan.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32`: - --> $DIR/coherence-projection-conflict-orphan.rs:16:1 + --> $DIR/coherence-projection-conflict-orphan.rs:19:1 | LL | impl Foo for i32 { } | --------------------- first implementation here LL | -LL | impl Foo for A { } //~ ERROR E0119 +LL | impl Foo for A { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` | = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions diff --git a/src/test/ui/coherence/coherence-projection-conflict-orphan.re.stderr b/src/test/ui/coherence/coherence-projection-conflict-orphan.re.stderr new file mode 100644 index 0000000000000..cde9360ddf2c8 --- /dev/null +++ b/src/test/ui/coherence/coherence-projection-conflict-orphan.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict-orphan.rs:19:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + | + = note: upstream crates may add new impl of trait `std::iter::Iterator` for type `i32` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr b/src/test/ui/coherence/coherence-projection-conflict-ty-param.old.stderr similarity index 78% rename from src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr rename to src/test/ui/coherence/coherence-projection-conflict-ty-param.old.stderr index 92717e3f67a0e..b53a4c973edac 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-ty-param.stderr +++ b/src/test/ui/coherence/coherence-projection-conflict-ty-param.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`: - --> $DIR/coherence-projection-conflict-ty-param.rs:10:1 + --> $DIR/coherence-projection-conflict-ty-param.rs:14:1 | LL | impl > Foo

for Option {} | ---------------------------------------- first implementation here LL | -LL | impl Foo for Option { } //~ ERROR E0119 +LL | impl Foo for Option { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-projection-conflict-ty-param.re.stderr b/src/test/ui/coherence/coherence-projection-conflict-ty-param.re.stderr new file mode 100644 index 0000000000000..b53a4c973edac --- /dev/null +++ b/src/test/ui/coherence/coherence-projection-conflict-ty-param.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo<_>` for type `std::option::Option<_>`: + --> $DIR/coherence-projection-conflict-ty-param.rs:14:1 + | +LL | impl > Foo

for Option {} + | ---------------------------------------- first implementation here +LL | +LL | impl Foo for Option { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `std::option::Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-projection-conflict.stderr b/src/test/ui/coherence/coherence-projection-conflict.old.stderr similarity index 76% rename from src/test/ui/coherence/coherence-projection-conflict.stderr rename to src/test/ui/coherence/coherence-projection-conflict.old.stderr index 1b0b4e1708f9a..c2e5fc8617512 100644 --- a/src/test/ui/coherence/coherence-projection-conflict.stderr +++ b/src/test/ui/coherence/coherence-projection-conflict.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32`: - --> $DIR/coherence-projection-conflict.rs:11:1 + --> $DIR/coherence-projection-conflict.rs:15:1 | LL | impl Foo for i32 { } | --------------------- first implementation here LL | -LL | impl Foo for A { } //~ ERROR E0119 +LL | impl Foo for A { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-projection-conflict.re.stderr b/src/test/ui/coherence/coherence-projection-conflict.re.stderr new file mode 100644 index 0000000000000..c2e5fc8617512 --- /dev/null +++ b/src/test/ui/coherence/coherence-projection-conflict.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Foo` for type `i32`: + --> $DIR/coherence-projection-conflict.rs:15:1 + | +LL | impl Foo for i32 { } + | --------------------- first implementation here +LL | +LL | impl Foo for A { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-tuple-conflict.stderr b/src/test/ui/coherence/coherence-tuple-conflict.old.stderr similarity index 79% rename from src/test/ui/coherence/coherence-tuple-conflict.stderr rename to src/test/ui/coherence/coherence-tuple-conflict.old.stderr index 4baf71ebf0998..e832bdebbddeb 100644 --- a/src/test/ui/coherence/coherence-tuple-conflict.stderr +++ b/src/test/ui/coherence/coherence-tuple-conflict.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `(_, _)`: - --> $DIR/coherence-tuple-conflict.rs:15:1 + --> $DIR/coherence-tuple-conflict.rs:19:1 | LL | impl MyTrait for (T,T) { | ------------------------- first implementation here ... -LL | impl MyTrait for (A,B) { //~ ERROR E0119 +LL | impl MyTrait for (A,B) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` error: aborting due to previous error diff --git a/src/test/ui/coherence/coherence-tuple-conflict.re.stderr b/src/test/ui/coherence/coherence-tuple-conflict.re.stderr new file mode 100644 index 0000000000000..e832bdebbddeb --- /dev/null +++ b/src/test/ui/coherence/coherence-tuple-conflict.re.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(_, _)`: + --> $DIR/coherence-tuple-conflict.rs:19:1 + | +LL | impl MyTrait for (T,T) { + | ------------------------- first implementation here +... +LL | impl MyTrait for (A,B) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence-vec-local-2.stderr b/src/test/ui/coherence/coherence-vec-local-2.old.stderr similarity index 81% rename from src/test/ui/coherence/coherence-vec-local-2.stderr rename to src/test/ui/coherence/coherence-vec-local-2.old.stderr index 3cdcd95770955..1c1118a58c6f0 100644 --- a/src/test/ui/coherence/coherence-vec-local-2.stderr +++ b/src/test/ui/coherence/coherence-vec-local-2.old.stderr @@ -1,7 +1,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-vec-local-2.rs:11:1 + --> $DIR/coherence-vec-local-2.rs:14:1 | -LL | impl Remote for Vec> { } //~ ERROR E0210 +LL | impl Remote for Vec> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-vec-local-2.re.stderr b/src/test/ui/coherence/coherence-vec-local-2.re.stderr new file mode 100644 index 0000000000000..37859f7cfa285 --- /dev/null +++ b/src/test/ui/coherence/coherence-vec-local-2.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-vec-local-2.rs:14:1 + | +LL | impl Remote for Vec> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence-vec-local.stderr b/src/test/ui/coherence/coherence-vec-local.old.stderr similarity index 81% rename from src/test/ui/coherence/coherence-vec-local.stderr rename to src/test/ui/coherence/coherence-vec-local.old.stderr index 319d2ebabd7e8..304aaaf36875c 100644 --- a/src/test/ui/coherence/coherence-vec-local.stderr +++ b/src/test/ui/coherence/coherence-vec-local.old.stderr @@ -1,7 +1,7 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence-vec-local.rs:11:1 + --> $DIR/coherence-vec-local.rs:14:1 | -LL | impl Remote for Vec { } //~ ERROR E0117 +LL | impl Remote for Vec { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence-vec-local.re.stderr b/src/test/ui/coherence/coherence-vec-local.re.stderr new file mode 100644 index 0000000000000..304aaaf36875c --- /dev/null +++ b/src/test/ui/coherence/coherence-vec-local.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-vec-local.rs:14:1 + | +LL | impl Remote for Vec { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.old.stderr similarity index 89% rename from src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr rename to src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.old.stderr index 0aa7320bc3343..12c7a1f977c3f 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>`: - --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:17:1 + --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:19:1 | LL | impl MyTrait for T { } | ---------------------------------- first implementation here ... -LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 +LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` | = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions diff --git a/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.re.stderr b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.re.stderr new file mode 100644 index 0000000000000..12c7a1f977c3f --- /dev/null +++ b/src/test/ui/coherence/coherence_copy_like_err_fundamental_struct_tuple.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>`: + --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:19:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence_copy_like_err_struct.stderr b/src/test/ui/coherence/coherence_copy_like_err_struct.old.stderr similarity index 82% rename from src/test/ui/coherence/coherence_copy_like_err_struct.stderr rename to src/test/ui/coherence/coherence_copy_like_err_struct.old.stderr index 03b4b7d807236..1b6c62e9bf3a8 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_struct.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_struct.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct`: - --> $DIR/coherence_copy_like_err_struct.rs:19:1 + --> $DIR/coherence_copy_like_err_struct.rs:22:1 | LL | impl MyTrait for T { } | ---------------------------------- first implementation here ... -LL | impl MyTrait for lib::MyStruct { } //~ ERROR E0119 +LL | impl MyTrait for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct` | = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyStruct` in future versions diff --git a/src/test/ui/coherence/coherence_copy_like_err_struct.re.stderr b/src/test/ui/coherence/coherence_copy_like_err_struct.re.stderr new file mode 100644 index 0000000000000..1b6c62e9bf3a8 --- /dev/null +++ b/src/test/ui/coherence/coherence_copy_like_err_struct.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct`: + --> $DIR/coherence_copy_like_err_struct.rs:22:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyStruct { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyStruct` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence_copy_like_err_tuple.stderr b/src/test/ui/coherence/coherence_copy_like_err_tuple.old.stderr similarity index 83% rename from src/test/ui/coherence/coherence_copy_like_err_tuple.stderr rename to src/test/ui/coherence/coherence_copy_like_err_tuple.old.stderr index 71c1a9173af31..11bd788c76153 100644 --- a/src/test/ui/coherence/coherence_copy_like_err_tuple.stderr +++ b/src/test/ui/coherence/coherence_copy_like_err_tuple.old.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `MyTrait` for type `(MyType,)`: - --> $DIR/coherence_copy_like_err_tuple.rs:18:1 + --> $DIR/coherence_copy_like_err_tuple.rs:21:1 | LL | impl MyTrait for T { } | ---------------------------------- first implementation here ... -LL | impl MyTrait for (MyType,) { } //~ ERROR E0119 +LL | impl MyTrait for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(MyType,)` | = note: upstream crates may add new impl of trait `lib::MyCopy` for type `(MyType,)` in future versions diff --git a/src/test/ui/coherence/coherence_copy_like_err_tuple.re.stderr b/src/test/ui/coherence/coherence_copy_like_err_tuple.re.stderr new file mode 100644 index 0000000000000..11bd788c76153 --- /dev/null +++ b/src/test/ui/coherence/coherence_copy_like_err_tuple.re.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(MyType,)`: + --> $DIR/coherence_copy_like_err_tuple.rs:21:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for (MyType,) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(MyType,)` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `(MyType,)` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/coherence/coherence_inherent.stderr b/src/test/ui/coherence/coherence_inherent.old.stderr similarity index 80% rename from src/test/ui/coherence/coherence_inherent.stderr rename to src/test/ui/coherence/coherence_inherent.old.stderr index 3974cfe94adbe..fa564459b2133 100644 --- a/src/test/ui/coherence/coherence_inherent.stderr +++ b/src/test/ui/coherence/coherence_inherent.old.stderr @@ -1,7 +1,7 @@ error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope - --> $DIR/coherence_inherent.rs:31:11 + --> $DIR/coherence_inherent.rs:35:11 | -LL | s.the_fn(); //~ ERROR no method named `the_fn` found +LL | s.the_fn(); | ^^^^^^ | = help: items from traits can only be used if the trait is in scope diff --git a/src/test/ui/coherence/coherence_inherent.re.stderr b/src/test/ui/coherence/coherence_inherent.re.stderr new file mode 100644 index 0000000000000..fa564459b2133 --- /dev/null +++ b/src/test/ui/coherence/coherence_inherent.re.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope + --> $DIR/coherence_inherent.rs:35:11 + | +LL | s.the_fn(); + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use Lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/coherence/coherence_inherent_cc.stderr b/src/test/ui/coherence/coherence_inherent_cc.old.stderr similarity index 81% rename from src/test/ui/coherence/coherence_inherent_cc.stderr rename to src/test/ui/coherence/coherence_inherent_cc.old.stderr index fcb3db711a0e1..4d93e699031f3 100644 --- a/src/test/ui/coherence/coherence_inherent_cc.stderr +++ b/src/test/ui/coherence/coherence_inherent_cc.old.stderr @@ -1,7 +1,7 @@ error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope - --> $DIR/coherence_inherent_cc.rs:23:11 + --> $DIR/coherence_inherent_cc.rs:26:11 | -LL | s.the_fn(); //~ ERROR no method named `the_fn` found +LL | s.the_fn(); | ^^^^^^ | = help: items from traits can only be used if the trait is in scope diff --git a/src/test/ui/coherence/coherence_inherent_cc.re.stderr b/src/test/ui/coherence/coherence_inherent_cc.re.stderr new file mode 100644 index 0000000000000..4d93e699031f3 --- /dev/null +++ b/src/test/ui/coherence/coherence_inherent_cc.re.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope + --> $DIR/coherence_inherent_cc.rs:26:11 + | +LL | s.the_fn(); + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use coherence_inherent_cc_lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/coherence/coherence_local_err_struct.stderr b/src/test/ui/coherence/coherence_local_err_struct.old.stderr similarity index 78% rename from src/test/ui/coherence/coherence_local_err_struct.stderr rename to src/test/ui/coherence/coherence_local_err_struct.old.stderr index 7ff88c55b062c..61c94c1c7cad7 100644 --- a/src/test/ui/coherence/coherence_local_err_struct.stderr +++ b/src/test/ui/coherence/coherence_local_err_struct.old.stderr @@ -1,7 +1,7 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence_local_err_struct.rs:16:1 + --> $DIR/coherence_local_err_struct.rs:17:1 | -LL | impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 +LL | impl lib::MyCopy for lib::MyStruct { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence_local_err_struct.re.stderr b/src/test/ui/coherence/coherence_local_err_struct.re.stderr new file mode 100644 index 0000000000000..61c94c1c7cad7 --- /dev/null +++ b/src/test/ui/coherence/coherence_local_err_struct.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_struct.rs:17:1 + | +LL | impl lib::MyCopy for lib::MyStruct { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/coherence_local_err_tuple.stderr b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr similarity index 80% rename from src/test/ui/coherence/coherence_local_err_tuple.stderr rename to src/test/ui/coherence/coherence_local_err_tuple.old.stderr index eab59579cb638..934e2fcb890e3 100644 --- a/src/test/ui/coherence/coherence_local_err_tuple.stderr +++ b/src/test/ui/coherence/coherence_local_err_tuple.old.stderr @@ -1,7 +1,7 @@ error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/coherence_local_err_tuple.rs:16:1 + --> $DIR/coherence_local_err_tuple.rs:17:1 | -LL | impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 +LL | impl lib::MyCopy for (MyType,) { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate diff --git a/src/test/ui/coherence/coherence_local_err_tuple.re.stderr b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr new file mode 100644 index 0000000000000..934e2fcb890e3 --- /dev/null +++ b/src/test/ui/coherence/coherence_local_err_tuple.re.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_tuple.rs:17:1 + | +LL | impl lib::MyCopy for (MyType,) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/coherence/re-rebalance-coherence.rs b/src/test/ui/coherence/re-rebalance-coherence.rs new file mode 100644 index 0000000000000..33ad4e9753661 --- /dev/null +++ b/src/test/ui/coherence/re-rebalance-coherence.rs @@ -0,0 +1,13 @@ +#![feature(re_rebalance_coherence)] + +// run-pass +// aux-build:re_rebalance_coherence_lib.rs + +extern crate re_rebalance_coherence_lib as lib; +use lib::*; + +struct Oracle; +impl Backend for Oracle {} +impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} + +fn main() {} From 794b81ea5eb11db59e1337e3a09b2b2b2480c1bd Mon Sep 17 00:00:00 2001 From: Mika Lehtinen Date: Mon, 31 Dec 2018 12:16:45 +0200 Subject: [PATCH 26/58] Rename and fix nolink-with-link-args test There are three problems with the nolink-with-link-args test: * The test fails when using MSVC. It's caused by the `linker-flavor=ld` flag which was added in #46291. * In its comment, this test tests that "link_args are indeed passed when nolink is specified", but the `nolink` attribute has been removed [a long time ago](https://github.com/rust-lang/rust/pull/12826). * Pattern has a small typo. At first I was going to completely remove this test, but there is [a closed pull request for that](https://github.com/rust-lang/rust/pull/21090). So: * rename the file as suggested in the closed PR * adjust the comment * fix typo in the pattern * add `ignore-msvc`. --- src/test/compile-fail/invalid-link-args.rs | 12 ++++++++++++ src/test/compile-fail/nolink-with-link-args.rs | 13 ------------- 2 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 src/test/compile-fail/invalid-link-args.rs delete mode 100644 src/test/compile-fail/nolink-with-link-args.rs diff --git a/src/test/compile-fail/invalid-link-args.rs b/src/test/compile-fail/invalid-link-args.rs new file mode 100644 index 0000000000000..1e68b4f8b7025 --- /dev/null +++ b/src/test/compile-fail/invalid-link-args.rs @@ -0,0 +1,12 @@ +// ignore-msvc due to linker-flavor=ld +// error-pattern:aFdEfSeVEEE +// compile-flags: -C linker-flavor=ld + +/* Make sure invalid link_args are printed to stderr. */ + +#![feature(link_args)] + +#[link_args = "aFdEfSeVEEE"] +extern {} + +fn main() { } diff --git a/src/test/compile-fail/nolink-with-link-args.rs b/src/test/compile-fail/nolink-with-link-args.rs deleted file mode 100644 index c2ca2f807426f..0000000000000 --- a/src/test/compile-fail/nolink-with-link-args.rs +++ /dev/null @@ -1,13 +0,0 @@ -// error-pattern:aFdEfSeVEE -// compile-flags: -C linker-flavor=ld - -/* We're testing that link_args are indeed passed when nolink is specified. -So we try to compile with junk link_args and make sure they are visible in -the compiler output. */ - -#![feature(link_args)] - -#[link_args = "aFdEfSeVEEE"] -extern {} - -fn main() { } From f4826abf6d04d3c468e37c3e7b670d35030ef0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 31 Dec 2018 21:48:06 +0100 Subject: [PATCH 27/58] Fix backtraces on Windows --- src/libstd/sys/windows/backtrace/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libstd/sys/windows/backtrace/mod.rs b/src/libstd/sys/windows/backtrace/mod.rs index a6bd8f8cc51cb..4bda8ac91da62 100644 --- a/src/libstd/sys/windows/backtrace/mod.rs +++ b/src/libstd/sys/windows/backtrace/mod.rs @@ -103,7 +103,7 @@ fn set_frames(StackWalk: W, frames: &mut [Frame]) -> io::Result< frames[i] = Frame { symbol_addr: addr, exact_position: addr, - inline_context: 0, + inline_context: frame.get_inline_context(), }; i += 1 @@ -209,6 +209,7 @@ trait StackFrame { fn new() -> Self; fn init(&mut self, ctx: &c::CONTEXT) -> c::DWORD; fn get_addr(&self) -> *const u8; + fn get_inline_context(&self) -> u32; } impl StackFrame for c::STACKFRAME_EX { @@ -263,6 +264,10 @@ impl StackFrame for c::STACKFRAME_EX { fn get_addr(&self) -> *const u8 { (self.AddrPC.Offset - 1) as *const u8 } + + fn get_inline_context(&self) -> u32 { + self.InlineFrameContext + } } impl StackFrame for c::STACKFRAME64 { @@ -317,6 +322,10 @@ impl StackFrame for c::STACKFRAME64 { fn get_addr(&self) -> *const u8 { (self.AddrPC.Offset - 1) as *const u8 } + + fn get_inline_context(&self) -> u32 { + 0 + } } enum StackWalkVariant { From d2c91a1a6d00949929eb9e913f199eb520f792c4 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 1 Jan 2019 12:53:07 -0500 Subject: [PATCH 28/58] Fix broken links to second edition TRPL. Fixes https://github.com/rust-lang/rust/issues/57104. --- src/libcore/marker.rs | 2 +- src/libcore/ops/deref.rs | 4 +- src/libcore/ops/drop.rs | 2 +- src/libcore/ops/function.rs | 6 +-- .../borrow_check/error_reporting.rs | 4 +- src/libstd/keyword_docs.rs | 8 ++-- src/libstd/primitive_docs.rs | 2 +- .../associated-types-unsized.stderr | 2 +- src/test/ui/bad/bad-sized.stderr | 4 +- src/test/ui/consts/const-unsized.stderr | 8 ++-- src/test/ui/dst/dst-bad-assign-2.stderr | 2 +- src/test/ui/dst/dst-bad-assign-3.stderr | 2 +- src/test/ui/dst/dst-bad-assign.stderr | 2 +- src/test/ui/dst/dst-bad-deep-2.stderr | 2 +- src/test/ui/dst/dst-bad-deep.stderr | 2 +- .../dst/dst-object-from-unsized-type.stderr | 8 ++-- src/test/ui/dst/dst-sized-trait-param.stderr | 4 +- src/test/ui/error-codes/E0277.stderr | 2 +- .../ui/extern/extern-types-unsized.stderr | 8 ++-- .../feature-gate-trivial_bounds.stderr | 6 +-- .../feature-gate-unsized_locals.stderr | 2 +- src/test/ui/generator/sized-yield.stderr | 4 +- src/test/ui/issues/issue-14366.stderr | 2 +- src/test/ui/issues/issue-15756.stderr | 2 +- src/test/ui/issues/issue-17651.stderr | 2 +- src/test/ui/issues/issue-18107.stderr | 2 +- src/test/ui/issues/issue-18919.stderr | 2 +- src/test/ui/issues/issue-20005.stderr | 2 +- src/test/ui/issues/issue-20433.stderr | 2 +- src/test/ui/issues/issue-20605.stderr | 2 +- src/test/ui/issues/issue-22874.stderr | 2 +- src/test/ui/issues/issue-23281.stderr | 2 +- src/test/ui/issues/issue-24446.stderr | 2 +- src/test/ui/issues/issue-27060-2.stderr | 2 +- src/test/ui/issues/issue-27078.stderr | 2 +- src/test/ui/issues/issue-30355.stderr | 2 +- src/test/ui/issues/issue-35988.stderr | 2 +- src/test/ui/issues/issue-38954.stderr | 2 +- src/test/ui/issues/issue-41229-ref-str.stderr | 2 +- src/test/ui/issues/issue-42312.stderr | 4 +- src/test/ui/issues/issue-54410.stderr | 2 +- src/test/ui/issues/issue-5883.stderr | 4 +- .../ui/mismatched_types/cast-rfc0401.stderr | 4 +- src/test/ui/nll/issue-52534.stderr | 4 +- src/test/ui/range/range-1.stderr | 2 +- src/test/ui/resolve/issue-5035-2.stderr | 2 +- src/test/ui/str/str-array-assignment.stderr | 2 +- src/test/ui/str/str-mut-idx.stderr | 4 +- src/test/ui/substs-ppaux.normal.stderr | 2 +- src/test/ui/substs-ppaux.verbose.stderr | 2 +- src/test/ui/suggestions/path-by-value.stderr | 2 +- .../trait-bounds-not-on-bare-trait.stderr | 2 +- .../traits/trait-suggest-where-clause.stderr | 8 ++-- .../trivial-bounds/trivial-bounds-leak.stderr | 2 +- src/test/ui/union/union-sized-field.stderr | 6 +-- src/test/ui/union/union-unsized.stderr | 4 +- .../issue-50940-with-feature.stderr | 2 +- src/test/ui/unsized-locals/issue-50940.stderr | 2 +- .../ui/unsized-locals/unsized-exprs.stderr | 6 +-- .../ui/unsized-locals/unsized-exprs3.stderr | 2 +- .../ui/unsized/unsized-bare-typaram.stderr | 2 +- src/test/ui/unsized/unsized-enum.stderr | 2 +- src/test/ui/unsized/unsized-enum2.stderr | 40 +++++++++---------- .../unsized-inherent-impl-self-type.stderr | 2 +- src/test/ui/unsized/unsized-struct.stderr | 4 +- .../unsized-trait-impl-self-type.stderr | 2 +- .../unsized-trait-impl-trait-arg.stderr | 2 +- src/test/ui/unsized3.stderr | 12 +++--- src/test/ui/unsized5.stderr | 12 +++--- src/test/ui/unsized6.stderr | 26 ++++++------ src/test/ui/unsized7.stderr | 2 +- src/test/ui/wf/wf-array-elem-sized.stderr | 2 +- src/test/ui/wf/wf-fn-where-clause.stderr | 2 +- 73 files changed, 149 insertions(+), 149 deletions(-) diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 53af924376b9d..65752ba032104 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -85,7 +85,7 @@ impl !Send for *mut T { } on(parent_trait="std::path::Path", label="borrow the `Path` instead"), message="the size for values of type `{Self}` cannot be known at compilation time", label="doesn't have a size known at compile-time", - note="to learn more, visit Deref for &mut T { /// [book] as well as the reference sections on [the dereference operator] /// [ref-deref-op], [method resolution] and [type coercions]. /// -/// [book]: ../../book/second-edition/ch15-02-deref.html +/// [book]: ../../book/ch15-02-deref.html /// [`Deref`]: trait.Deref.html /// [more]: #more-on-deref-coercion /// [ref-deref-op]: ../../reference/expressions/operator-expr.html#the-dereference-operator diff --git a/src/libcore/ops/drop.rs b/src/libcore/ops/drop.rs index 8d16fdebb3e73..eae63ea2390a8 100644 --- a/src/libcore/ops/drop.rs +++ b/src/libcore/ops/drop.rs @@ -11,7 +11,7 @@ /// Refer to [the chapter on `Drop` in *The Rust Programming Language*][book] /// for some more elaboration. /// -/// [book]: ../../book/second-edition/ch15-03-drop.html +/// [book]: ../../book/ch15-03-drop.html /// /// # Examples /// diff --git a/src/libcore/ops/function.rs b/src/libcore/ops/function.rs index ec2e53412a0a5..3a1d765f7b816 100644 --- a/src/libcore/ops/function.rs +++ b/src/libcore/ops/function.rs @@ -27,7 +27,7 @@ /// `Fn(usize, bool) -> usize`). Those interested in the technical details of /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// -/// [book]: ../../book/second-edition/ch13-01-closures.html +/// [book]: ../../book/ch13-01-closures.html /// [`FnMut`]: trait.FnMut.html /// [`FnOnce`]: trait.FnOnce.html /// [function pointers]: ../../std/primitive.fn.html @@ -95,7 +95,7 @@ pub trait Fn : FnMut { /// `Fn(usize, bool) -> usize`). Those interested in the technical details of /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// -/// [book]: ../../book/second-edition/ch13-01-closures.html +/// [book]: ../../book/ch13-01-closures.html /// [`Fn`]: trait.Fn.html /// [`FnOnce`]: trait.FnOnce.html /// [function pointers]: ../../std/primitive.fn.html @@ -173,7 +173,7 @@ pub trait FnMut : FnOnce { /// `Fn(usize, bool) -> usize`). Those interested in the technical details of /// this can refer to [the relevant section in the *Rustonomicon*][nomicon]. /// -/// [book]: ../../book/second-edition/ch13-01-closures.html +/// [book]: ../../book/ch13-01-closures.html /// [`Fn`]: trait.Fn.html /// [`FnMut`]: trait.FnMut.html /// [function pointers]: ../../std/primitive.fn.html diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 6a5b5d172bbe4..996094086af45 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -723,7 +723,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { functions can only return borrows to data passed as arguments", ); err.note( - "to learn more, visit ", ); } else { @@ -2132,7 +2132,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> { "argument and return type have the same lifetime due to lifetime elision rules", ); diag.note( - "to learn more, visit ", ); diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index 4ca62cca94bc8..262930e08c004 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -169,7 +169,7 @@ mod crate_keyword { } /// /// [Algebraic Data Types]: https://en.wikipedia.org/wiki/Algebraic_data_type /// [`Option`]: option/enum.Option.html -/// [Rust Book]: https://doc.rust-lang.org/book/second-edition/ch06-01-defining-an-enum.html +/// [Rust Book]: https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html /// [Reference]: https://doc.rust-lang.org/reference/items/enumerations.html mod enum_keyword { } @@ -211,7 +211,7 @@ mod enum_keyword { } /// For more information on FFI, check the [Rust book] or the [Reference]. /// /// [Rust book]: -/// https://doc.rust-lang.org/book/second-edition/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code +/// https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code /// [Reference]: https://doc.rust-lang.org/reference/items/external-blocks.html mod extern_keyword { } @@ -278,7 +278,7 @@ mod extern_keyword { } /// /// [`impl`]: keyword.impl.html /// [`extern`]: keyword.extern.html -/// [Rust book]: https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html +/// [Rust book]: https://doc.rust-lang.org/book/ch03-03-how-functions-work.html /// [Reference]: https://doc.rust-lang.org/reference/items/functions.html mod fn_keyword { } @@ -705,6 +705,6 @@ mod loop_keyword { } /// [Reference][reference]. /// /// [`PhantomData`]: marker/struct.PhantomData.html -/// [book]: https://doc.rust-lang.org/book/second-edition/ch05-01-defining-structs.html +/// [book]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html /// [reference]: https://doc.rust-lang.org/reference/items/structs.html mod struct_keyword { } diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 7755d9339e6f5..475c9b4aeaa4e 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -923,7 +923,7 @@ mod prim_usize { } /// For more information on how to use references, see [the book's section on "References and /// Borrowing"][book-refs]. /// -/// [book-refs]: ../book/second-edition/ch04-02-references-and-borrowing.html +/// [book-refs]: ../book/ch04-02-references-and-borrowing.html /// /// # Trait implementations /// diff --git a/src/test/ui/associated-types/associated-types-unsized.stderr b/src/test/ui/associated-types/associated-types-unsized.stderr index bc85620d1a404..c83b14374f712 100644 --- a/src/test/ui/associated-types/associated-types-unsized.stderr +++ b/src/test/ui/associated-types/associated-types-unsized.stderr @@ -5,7 +5,7 @@ LL | let x = t.get(); //~ ERROR the size for values of type | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `::Value` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where ::Value: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr index 57a204659f145..9565888dcc022 100644 --- a/src/test/ui/bad/bad-sized.stderr +++ b/src/test/ui/bad/bad-sized.stderr @@ -11,7 +11,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time @@ -21,7 +21,7 @@ LL | let x: Vec = Vec::new(); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` - = note: to learn more, visit + = note: to learn more, visit = note: required by `>::new` error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-unsized.stderr b/src/test/ui/consts/const-unsized.stderr index cc00b77114483..0f996fcd94340 100644 --- a/src/test/ui/consts/const-unsized.stderr +++ b/src/test/ui/consts/const-unsized.stderr @@ -5,7 +5,7 @@ LL | const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync)); | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/const-unsized.rs:6:18 @@ -14,7 +14,7 @@ LL | const CONST_FOO: str = *"foo"; | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `(dyn std::fmt::Debug + std::marker::Sync + 'static)` cannot be known at compilation time --> $DIR/const-unsized.rs:9:18 @@ -23,7 +23,7 @@ LL | static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync)); | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::fmt::Debug + std::marker::Sync + 'static)` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/const-unsized.rs:12:20 @@ -32,7 +32,7 @@ LL | static STATIC_BAR: str = *"bar"; | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-bad-assign-2.stderr b/src/test/ui/dst/dst-bad-assign-2.stderr index 63c95c3154066..4e1e67c7f4809 100644 --- a/src/test/ui/dst/dst-bad-assign-2.stderr +++ b/src/test/ui/dst/dst-bad-assign-2.stderr @@ -5,7 +5,7 @@ LL | f5.ptr = *z; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/dst/dst-bad-assign-3.stderr b/src/test/ui/dst/dst-bad-assign-3.stderr index d0fe27e7bc2d6..0c4f86613196d 100644 --- a/src/test/ui/dst/dst-bad-assign-3.stderr +++ b/src/test/ui/dst/dst-bad-assign-3.stderr @@ -14,7 +14,7 @@ LL | f5.2 = Bar1 {f: 36}; | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error: aborting due to 2 previous errors diff --git a/src/test/ui/dst/dst-bad-assign.stderr b/src/test/ui/dst/dst-bad-assign.stderr index 2ae732edd6893..a60d9d66f39e6 100644 --- a/src/test/ui/dst/dst-bad-assign.stderr +++ b/src/test/ui/dst/dst-bad-assign.stderr @@ -14,7 +14,7 @@ LL | f5.ptr = Bar1 {f: 36}; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn ToBar` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error: aborting due to 2 previous errors diff --git a/src/test/ui/dst/dst-bad-deep-2.stderr b/src/test/ui/dst/dst-bad-deep-2.stderr index 6198c7eba57c0..cb2735147a35b 100644 --- a/src/test/ui/dst/dst-bad-deep-2.stderr +++ b/src/test/ui/dst/dst-bad-deep-2.stderr @@ -5,7 +5,7 @@ LL | let h: &(([isize],),) = &(*g,); | ^^^^^ doesn't have a size known at compile-time | = help: within `(([isize],),)`, the trait `std::marker::Sized` is not implemented for `[isize]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `([isize],)` = note: required because it appears within the type `(([isize],),)` = note: tuples must have a statically known size to be initialized diff --git a/src/test/ui/dst/dst-bad-deep.stderr b/src/test/ui/dst/dst-bad-deep.stderr index 509dbfe8f1882..521adf601cc70 100644 --- a/src/test/ui/dst/dst-bad-deep.stderr +++ b/src/test/ui/dst/dst-bad-deep.stderr @@ -5,7 +5,7 @@ LL | let h: &Fat> = &Fat { ptr: *g }; | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Fat>`, the trait `std::marker::Sized` is not implemented for `[isize]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Fat<[isize]>` = note: required because it appears within the type `Fat>` = note: structs must have a statically known size to be initialized diff --git a/src/test/ui/dst/dst-object-from-unsized-type.stderr b/src/test/ui/dst/dst-object-from-unsized-type.stderr index 3b333ce5d28f1..4851ca108285f 100644 --- a/src/test/ui/dst/dst-object-from-unsized-type.stderr +++ b/src/test/ui/dst/dst-object-from-unsized-type.stderr @@ -5,7 +5,7 @@ LL | let u: &Foo = t; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: required for the cast to the object type `dyn Foo` @@ -16,7 +16,7 @@ LL | let v: &Foo = t as &Foo; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: required for the cast to the object type `dyn Foo` @@ -27,7 +27,7 @@ LL | let _: &[&Foo] = &["hi"]; | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time @@ -37,7 +37,7 @@ LL | let _: &Foo = x as &Foo; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error: aborting due to 4 previous errors diff --git a/src/test/ui/dst/dst-sized-trait-param.stderr b/src/test/ui/dst/dst-sized-trait-param.stderr index e01bf2499da7e..40dc9978f367b 100644 --- a/src/test/ui/dst/dst-sized-trait-param.stderr +++ b/src/test/ui/dst/dst-sized-trait-param.stderr @@ -5,7 +5,7 @@ LL | impl Foo<[isize]> for usize { } | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[isize]` - = note: to learn more, visit + = note: to learn more, visit error[E0277]: the size for values of type `[usize]` cannot be known at compilation time --> $DIR/dst-sized-trait-param.rs:10:6 @@ -14,7 +14,7 @@ LL | impl Foo for [usize] { } | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[usize]` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index 0cfe04afa2671..e5e416da883de 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -5,7 +5,7 @@ LL | fn f(p: Path) { } | ^ borrow the `Path` instead | = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `std::path::Path` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 48d0aa8c601d6..4e4f5550fe833 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -5,7 +5,7 @@ LL | assert_sized::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit note: required by `assert_sized` --> $DIR/extern-types-unsized.rs:19:1 | @@ -19,7 +19,7 @@ LL | assert_sized::(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Foo`, the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Foo` note: required by `assert_sized` --> $DIR/extern-types-unsized.rs:19:1 @@ -34,7 +34,7 @@ LL | assert_sized::>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar`, the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Bar` note: required by `assert_sized` --> $DIR/extern-types-unsized.rs:19:1 @@ -49,7 +49,7 @@ LL | assert_sized::>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar>`, the trait `std::marker::Sized` is not implemented for `A` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Bar` = note: required because it appears within the type `Bar>` note: required by `assert_sized` diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index 34c457875ec16..1f35efa59b690 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -95,7 +95,7 @@ LL | struct TwoStrs(str, str) where str: Sized; //~ ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable @@ -108,7 +108,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: within `Dst<(dyn A + 'static)>`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Dst<(dyn A + 'static)>` = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable @@ -122,7 +122,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = help: see issue #48214 = help: add #![feature(trivial_bounds)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr index 77313ed02151f..bde39cbeaeb28 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -5,7 +5,7 @@ LL | fn f(f: FnOnce()) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::FnOnce() + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr index 7e1cd95429cb4..4f59f2c1c6ab3 100644 --- a/src/test/ui/generator/sized-yield.stderr +++ b/src/test/ui/generator/sized-yield.stderr @@ -9,7 +9,7 @@ LL | | }; | |____^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the yield type of a generator must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -19,7 +19,7 @@ LL | unsafe { gen.resume(); } | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-14366.stderr b/src/test/ui/issues/issue-14366.stderr index b93f5c2588256..a3588bb8ebe12 100644 --- a/src/test/ui/issues/issue-14366.stderr +++ b/src/test/ui/issues/issue-14366.stderr @@ -5,7 +5,7 @@ LL | let _x = "test" as &::std::any::Any; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn std::any::Any` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-15756.stderr b/src/test/ui/issues/issue-15756.stderr index 9133376f6cfa3..987bc512163d6 100644 --- a/src/test/ui/issues/issue-15756.stderr +++ b/src/test/ui/issues/issue-15756.stderr @@ -5,7 +5,7 @@ LL | &mut something | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[T]` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-17651.stderr b/src/test/ui/issues/issue-17651.stderr index e2d0d3301b6a1..72c40ff4b3a0c 100644 --- a/src/test/ui/issues/issue-17651.stderr +++ b/src/test/ui/issues/issue-17651.stderr @@ -5,7 +5,7 @@ LL | (|| Box::new(*(&[0][..])))(); | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[{integer}]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `>::new` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18107.stderr b/src/test/ui/issues/issue-18107.stderr index 4bad37df2edfe..23b58c3f6df3d 100644 --- a/src/test/ui/issues/issue-18107.stderr +++ b/src/test/ui/issues/issue-18107.stderr @@ -5,7 +5,7 @@ LL | AbstractRenderer | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn AbstractRenderer + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: the return type of a function must have a statically known size error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18919.stderr b/src/test/ui/issues/issue-18919.stderr index cbad31a40cb6d..ca717a3c49b81 100644 --- a/src/test/ui/issues/issue-18919.stderr +++ b/src/test/ui/issues/issue-18919.stderr @@ -7,7 +7,7 @@ LL | | } | |_^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn for<'r> std::ops::Fn(&'r isize) -> isize` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::option::Option` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20005.stderr b/src/test/ui/issues/issue-20005.stderr index c69dfa9d89ca6..672d78f65e9f7 100644 --- a/src/test/ui/issues/issue-20005.stderr +++ b/src/test/ui/issues/issue-20005.stderr @@ -9,7 +9,7 @@ LL | | } | |_____^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Self` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Self: std::marker::Sized` bound note: required by `From` --> $DIR/issue-20005.rs:1:1 diff --git a/src/test/ui/issues/issue-20433.stderr b/src/test/ui/issues/issue-20433.stderr index cc98a775092e3..f7cb28edd6216 100644 --- a/src/test/ui/issues/issue-20433.stderr +++ b/src/test/ui/issues/issue-20433.stderr @@ -5,7 +5,7 @@ LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i32]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20605.stderr b/src/test/ui/issues/issue-20605.stderr index 472080d1091d4..f779fe51bf2d1 100644 --- a/src/test/ui/issues/issue-20605.stderr +++ b/src/test/ui/issues/issue-20605.stderr @@ -5,7 +5,7 @@ LL | for item in *things { *item = 0 } | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `dyn std::iter::Iterator` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::iter::IntoIterator::into_iter` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22874.stderr b/src/test/ui/issues/issue-22874.stderr index 26addd173912f..229f99f90640b 100644 --- a/src/test/ui/issues/issue-22874.stderr +++ b/src/test/ui/issues/issue-22874.stderr @@ -5,7 +5,7 @@ LL | rows: [[String]], | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[std::string::String]` - = note: to learn more, visit + = note: to learn more, visit = note: slice and array elements must have `Sized` type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index adc92ff7d0890..1e57774afe55a 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -5,7 +5,7 @@ LL | pub fn function(funs: Vec ()>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-24446.stderr b/src/test/ui/issues/issue-24446.stderr index 230ea4d683051..ffec73b1ab4a8 100644 --- a/src/test/ui/issues/issue-24446.stderr +++ b/src/test/ui/issues/issue-24446.stderr @@ -5,7 +5,7 @@ LL | static foo: Fn() -> u32 = || -> u32 { | ^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() -> u32 + 'static)` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to previous error diff --git a/src/test/ui/issues/issue-27060-2.stderr b/src/test/ui/issues/issue-27060-2.stderr index 6141ada5d9ab2..b95c298b6e679 100644 --- a/src/test/ui/issues/issue-27060-2.stderr +++ b/src/test/ui/issues/issue-27060-2.stderr @@ -5,7 +5,7 @@ LL | data: T, //~ ERROR the size for values of type | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: the last field of a packed struct may only have a dynamically sized type if it does not need drop to be run diff --git a/src/test/ui/issues/issue-27078.stderr b/src/test/ui/issues/issue-27078.stderr index 278c57d146d84..76cc3e7b0a36e 100644 --- a/src/test/ui/issues/issue-27078.stderr +++ b/src/test/ui/issues/issue-27078.stderr @@ -5,7 +5,7 @@ LL | fn foo(self) -> &'static i32 { | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Self` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Self: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-30355.stderr b/src/test/ui/issues/issue-30355.stderr index 5d1541918e0b7..48b151c73c956 100644 --- a/src/test/ui/issues/issue-30355.stderr +++ b/src/test/ui/issues/issue-30355.stderr @@ -5,7 +5,7 @@ LL | &X(*Y) | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-35988.stderr b/src/test/ui/issues/issue-35988.stderr index a570bd22dcc43..825c0de5e53ea 100644 --- a/src/test/ui/issues/issue-35988.stderr +++ b/src/test/ui/issues/issue-35988.stderr @@ -5,7 +5,7 @@ LL | V([Box]), | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[std::boxed::Box]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error: aborting due to previous error diff --git a/src/test/ui/issues/issue-38954.stderr b/src/test/ui/issues/issue-38954.stderr index 06093ecbc331b..a74d6353c31f4 100644 --- a/src/test/ui/issues/issue-38954.stderr +++ b/src/test/ui/issues/issue-38954.stderr @@ -5,7 +5,7 @@ LL | fn _test(ref _p: str) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-41229-ref-str.stderr b/src/test/ui/issues/issue-41229-ref-str.stderr index c4fe54e78ed95..bcca911c5a5c8 100644 --- a/src/test/ui/issues/issue-41229-ref-str.stderr +++ b/src/test/ui/issues/issue-41229-ref-str.stderr @@ -5,7 +5,7 @@ LL | pub fn example(ref s: str) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-42312.stderr b/src/test/ui/issues/issue-42312.stderr index 12a436639dddf..20c8d085cbc62 100644 --- a/src/test/ui/issues/issue-42312.stderr +++ b/src/test/ui/issues/issue-42312.stderr @@ -5,7 +5,7 @@ LL | fn baz(_: Self::Target) where Self: Deref {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `::Target` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where ::Target: std::marker::Sized` bound = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature @@ -17,7 +17,7 @@ LL | pub fn f(_: ToString) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::string::ToString + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/issues/issue-54410.stderr b/src/test/ui/issues/issue-54410.stderr index ae6888f067e68..992c691bf21ef 100644 --- a/src/test/ui/issues/issue-54410.stderr +++ b/src/test/ui/issues/issue-54410.stderr @@ -5,7 +5,7 @@ LL | pub static mut symbol: [i8]; | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i8]` - = note: to learn more, visit + = note: to learn more, visit error: aborting due to previous error diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 398d42c94fa48..ad463d4c478ca 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -5,7 +5,7 @@ LL | fn new_struct(r: A+'static) | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -16,7 +16,7 @@ LL | -> Struct { //~^ ERROR the size for values of type | ^^^^^^ doesn't have a size known at compile-time | = help: within `Struct`, the trait `std::marker::Sized` is not implemented for `(dyn A + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Struct` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index e220349c6df12..158d114616979 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -223,7 +223,7 @@ LL | let _ = fat_v as *const Foo; //~ ERROR the size for values of type | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -233,7 +233,7 @@ LL | let _ = a as *const Foo; //~ ERROR the size for values of type | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required for the cast to the object type `dyn Foo` error[E0606]: casting `&{float}` as `f32` is invalid diff --git a/src/test/ui/nll/issue-52534.stderr b/src/test/ui/nll/issue-52534.stderr index 42387c774a4f7..e83374af3b066 100644 --- a/src/test/ui/nll/issue-52534.stderr +++ b/src/test/ui/nll/issue-52534.stderr @@ -10,7 +10,7 @@ LL | } | - ...but `x` will be dropped here, when the function `bar` returns | = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments - = note: to learn more, visit + = note: to learn more, visit error[E0597]: `y` does not live long enough --> $DIR/issue-52534.rs:18:26 @@ -24,7 +24,7 @@ LL | } | - ...but `y` will be dropped here, when the function `foobar` returns | = note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments - = note: to learn more, visit + = note: to learn more, visit error: aborting due to 2 previous errors diff --git a/src/test/ui/range/range-1.stderr b/src/test/ui/range/range-1.stderr index 8e0e405a8ad03..00c0c80515557 100644 --- a/src/test/ui/range/range-1.stderr +++ b/src/test/ui/range/range-1.stderr @@ -19,7 +19,7 @@ LL | let range = *arr..; | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[{integer}]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::ops::RangeFrom` error: aborting due to 3 previous errors diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index d3e559e0f9366..89eb3d97ce0a5 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -5,7 +5,7 @@ LL | fn foo(_x: K) {} | ^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn I + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/str/str-array-assignment.stderr b/src/test/ui/str/str-array-assignment.stderr index d3bff00872288..24d8db481b468 100644 --- a/src/test/ui/str/str-array-assignment.stderr +++ b/src/test/ui/str/str-array-assignment.stderr @@ -28,7 +28,7 @@ LL | let v = s[..2]; | doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index a8ab38e5ab6a5..a0c7c2c574e4e 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -5,7 +5,7 @@ LL | s[1..2] = bot(); | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit note: required by `bot` --> $DIR/str-mut-idx.rs:1:1 | @@ -19,7 +19,7 @@ LL | s[1..2] = bot(); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the left-hand-side of an assignment must have a statically known size error[E0277]: the type `str` cannot be mutably indexed by `usize` diff --git a/src/test/ui/substs-ppaux.normal.stderr b/src/test/ui/substs-ppaux.normal.stderr index fb9e49eb10f87..567b4d9f4403e 100644 --- a/src/test/ui/substs-ppaux.normal.stderr +++ b/src/test/ui/substs-ppaux.normal.stderr @@ -41,7 +41,7 @@ LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required because of the requirements on the impl of `Foo<'_, '_, u8>` for `str` note: required by `Foo::bar` --> $DIR/substs-ppaux.rs:7:5 diff --git a/src/test/ui/substs-ppaux.verbose.stderr b/src/test/ui/substs-ppaux.verbose.stderr index 77683c1d91678..9d8a555dffe16 100644 --- a/src/test/ui/substs-ppaux.verbose.stderr +++ b/src/test/ui/substs-ppaux.verbose.stderr @@ -41,7 +41,7 @@ LL | >::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required because of the requirements on the impl of `Foo<'_#0r, '_#1r, u8>` for `str` note: required by `Foo::bar` --> $DIR/substs-ppaux.rs:7:5 diff --git a/src/test/ui/suggestions/path-by-value.stderr b/src/test/ui/suggestions/path-by-value.stderr index 338cfc990dcda..b073e10749cc1 100644 --- a/src/test/ui/suggestions/path-by-value.stderr +++ b/src/test/ui/suggestions/path-by-value.stderr @@ -5,7 +5,7 @@ LL | fn f(p: Path) { } | ^ borrow the `Path` instead | = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `std::path::Path` = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr index 43d1e1a9d3e45..5aee1e7e982a8 100644 --- a/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr +++ b/src/test/ui/traits/trait-bounds-not-on-bare-trait.stderr @@ -5,7 +5,7 @@ LL | fn foo(_x: Foo + Send) { | ^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + std::marker::Send + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/traits/trait-suggest-where-clause.stderr b/src/test/ui/traits/trait-suggest-where-clause.stderr index 161cf85d258e2..f88dae37e48e5 100644 --- a/src/test/ui/traits/trait-suggest-where-clause.stderr +++ b/src/test/ui/traits/trait-suggest-where-clause.stderr @@ -5,7 +5,7 @@ LL | mem::size_of::(); | ^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `U` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where U: std::marker::Sized` bound = note: required by `std::mem::size_of` @@ -16,7 +16,7 @@ LL | mem::size_of::>(); | ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Misc`, the trait `std::marker::Sized` is not implemented for `U` - = note: to learn more, visit + = note: to learn more, visit = 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` @@ -54,7 +54,7 @@ LL | mem::size_of::<[T]>(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[T]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::mem::size_of` error[E0277]: the size for values of type `[&U]` cannot be known at compilation time @@ -64,7 +64,7 @@ LL | mem::size_of::<[&U]>(); | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[&U]` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::mem::size_of` error: aborting due to 7 previous errors diff --git a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr index bc94aba667c38..aa055d3dc03f5 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr @@ -5,7 +5,7 @@ LL | fn cant_return_str() -> str { //~ ERROR | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: the return type of a function must have a statically known size error[E0599]: no method named `test` found for type `i32` in the current scope diff --git a/src/test/ui/union/union-sized-field.stderr b/src/test/ui/union/union-sized-field.stderr index b490be28ebfd0..8914003068385 100644 --- a/src/test/ui/union/union-sized-field.stderr +++ b/src/test/ui/union/union-sized-field.stderr @@ -5,7 +5,7 @@ LL | value: T, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: no field of a union may have a dynamically sized type @@ -16,7 +16,7 @@ LL | value: T, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type @@ -27,7 +27,7 @@ LL | Value(T), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type diff --git a/src/test/ui/union/union-unsized.stderr b/src/test/ui/union/union-unsized.stderr index cd65172c23f80..e702f2c61bee3 100644 --- a/src/test/ui/union/union-unsized.stderr +++ b/src/test/ui/union/union-unsized.stderr @@ -5,7 +5,7 @@ LL | a: str, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: no field of a union may have a dynamically sized type error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -15,7 +15,7 @@ LL | b: str, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: no field of a union may have a dynamically sized type error: aborting due to 2 previous errors diff --git a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr index f4f015fa19065..7b6c2d11ea169 100644 --- a/src/test/ui/unsized-locals/issue-50940-with-feature.stderr +++ b/src/test/ui/unsized-locals/issue-50940-with-feature.stderr @@ -5,7 +5,7 @@ LL | A as fn(str) -> A; | ^ doesn't have a size known at compile-time | = help: within `main::A`, the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `main::A` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/unsized-locals/issue-50940.stderr b/src/test/ui/unsized-locals/issue-50940.stderr index 9f3669ccf1f15..be006c09d6f5c 100644 --- a/src/test/ui/unsized-locals/issue-50940.stderr +++ b/src/test/ui/unsized-locals/issue-50940.stderr @@ -5,7 +5,7 @@ LL | A as fn(str) -> A; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/unsized-locals/unsized-exprs.stderr b/src/test/ui/unsized-locals/unsized-exprs.stderr index 0ca60e8dea0d9..43c35cdd7b5b0 100644 --- a/src/test/ui/unsized-locals/unsized-exprs.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs.stderr @@ -5,7 +5,7 @@ LL | udrop::<(i32, [u8])>((42, *foo())); | ^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `({integer}, [u8])`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `({integer}, [u8])` = note: tuples must have a statically known size to be initialized @@ -16,7 +16,7 @@ LL | udrop::>(A { 0: *foo() }); | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `A<[u8]>`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `A<[u8]>` = note: structs must have a statically known size to be initialized @@ -27,7 +27,7 @@ LL | udrop::>(A(*foo())); | ^ doesn't have a size known at compile-time | = help: within `A<[u8]>`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `A<[u8]>` = note: the return type of a function must have a statically known size diff --git a/src/test/ui/unsized-locals/unsized-exprs3.stderr b/src/test/ui/unsized-locals/unsized-exprs3.stderr index 42f91a946a851..f9a7452a5ebf2 100644 --- a/src/test/ui/unsized-locals/unsized-exprs3.stderr +++ b/src/test/ui/unsized-locals/unsized-exprs3.stderr @@ -5,7 +5,7 @@ LL | udrop as fn([u8]); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: all function arguments must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index 6f54ac579a374..cee1459c7915d 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -5,7 +5,7 @@ LL | fn foo() { bar::() } | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound note: required by `bar` --> $DIR/unsized-bare-typaram.rs:1:1 diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 7d8c09ebf4050..20857a1d65e75 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -5,7 +5,7 @@ LL | fn foo2() { not_sized::>() } | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound note: required by `Foo` --> $DIR/unsized-enum.rs:4:1 diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr index 81135c33d1d19..9109366e4fcfd 100644 --- a/src/test/ui/unsized/unsized-enum2.stderr +++ b/src/test/ui/unsized/unsized-enum2.stderr @@ -5,7 +5,7 @@ LL | VA(W), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `W` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where W: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -16,7 +16,7 @@ LL | VB{x: X}, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -27,7 +27,7 @@ LL | VC(isize, Y), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -38,7 +38,7 @@ LL | VD{u: isize, x: Z}, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Z` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Z: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -49,7 +49,7 @@ LL | VE([u8]), | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -59,7 +59,7 @@ LL | VF{x: str}, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[f32]` cannot be known at compilation time @@ -69,7 +69,7 @@ LL | VG(isize, [f32]), | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[f32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[u32]` cannot be known at compilation time @@ -79,7 +79,7 @@ LL | VH{u: isize, x: [u32]}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time @@ -89,7 +89,7 @@ LL | VM(Foo), | ^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Foo + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn Bar + 'static)` cannot be known at compilation time @@ -99,7 +99,7 @@ LL | VN{x: Bar}, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn Bar + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn FooBar + 'static)` cannot be known at compilation time @@ -109,7 +109,7 @@ LL | VO(isize, FooBar), | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn FooBar + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn BarFoo + 'static)` cannot be known at compilation time @@ -119,7 +119,7 @@ LL | VP{u: isize, x: BarFoo}, | ^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn BarFoo + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[i8]` cannot be known at compilation time @@ -129,7 +129,7 @@ LL | VQ(<&'static [i8] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i8]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[char]` cannot be known at compilation time @@ -139,7 +139,7 @@ LL | VR{x: <&'static [char] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[char]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[f64]` cannot be known at compilation time @@ -149,7 +149,7 @@ LL | VS(isize, <&'static [f64] as Deref>::Target), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[f64]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `[i32]` cannot be known at compilation time @@ -159,7 +159,7 @@ LL | VT{u: isize, x: <&'static [i32] as Deref>::Target}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[i32]` - = note: to learn more, visit + = note: to learn more, visit = note: no field of an enum variant may have a dynamically sized type error[E0277]: the size for values of type `(dyn PathHelper1 + 'static)` cannot be known at compilation time @@ -169,7 +169,7 @@ LL | VI(Path1), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path1`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper1 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path1` = note: no field of an enum variant may have a dynamically sized type @@ -180,7 +180,7 @@ LL | VJ{x: Path2}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: within `Path2`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper2 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path2` = note: no field of an enum variant may have a dynamically sized type @@ -191,7 +191,7 @@ LL | VK(isize, Path3), | ^^^^^ doesn't have a size known at compile-time | = help: within `Path3`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper3 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path3` = note: no field of an enum variant may have a dynamically sized type @@ -202,7 +202,7 @@ LL | VL{u: isize, x: Path4}, | ^^^^^^^^ doesn't have a size known at compile-time | = help: within `Path4`, the trait `std::marker::Sized` is not implemented for `(dyn PathHelper4 + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required because it appears within the type `Path4` = note: no field of an enum variant may have a dynamically sized type diff --git a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr index 1d157bf5b3654..98eecabc84cb8 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -5,7 +5,7 @@ LL | impl S5 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `S5` --> $DIR/unsized-inherent-impl-self-type.rs:5:1 diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index a72b3cf1783c7..7add65c07866b 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -5,7 +5,7 @@ LL | fn foo2() { not_sized::>() } | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound note: required by `Foo` --> $DIR/unsized-struct.rs:4:1 @@ -20,7 +20,7 @@ LL | fn bar2() { is_sized::>() } | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Bar`, the trait `std::marker::Sized` is not implemented for `T` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where T: std::marker::Sized` bound = note: required because it appears within the type `Bar` note: required by `is_sized` diff --git a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr index 53ddad9356240..c39f3652b647c 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -5,7 +5,7 @@ LL | impl T3 for S5 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `S5` --> $DIR/unsized-trait-impl-self-type.rs:8:1 diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr index e664c1d258128..ee0d5ccccfe11 100644 --- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -5,7 +5,7 @@ LL | impl T2 for S4 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound error: aborting due to previous error diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index 8c2d713d4e3bf..2c7b86c5d8284 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized3.stderr @@ -5,7 +5,7 @@ LL | f2::(x); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `f2` --> $DIR/unsized3.rs:10:1 @@ -20,7 +20,7 @@ LL | f4::(x); | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound note: required by `f4` --> $DIR/unsized3.rs:21:1 @@ -35,7 +35,7 @@ LL | f5(x1); | ^^ doesn't have a size known at compile-time | = help: within `S`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` note: required by `f5` @@ -51,7 +51,7 @@ LL | f5(&(*x1, 34)); | ^^ doesn't have a size known at compile-time | = help: within `S`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` = note: only the last element of a tuple may have a dynamically sized type @@ -63,7 +63,7 @@ LL | f5(&(32, *x1)); | ^^^^^^^^^ doesn't have a size known at compile-time | = help: within `({integer}, S)`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` = note: required because it appears within the type `({integer}, S)` @@ -76,7 +76,7 @@ LL | f5(&(32, *x1)); | ^^ doesn't have a size known at compile-time | = help: within `({integer}, S)`, the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: required because it appears within the type `S` = note: required because it appears within the type `({integer}, S)` diff --git a/src/test/ui/unsized5.stderr b/src/test/ui/unsized5.stderr index 9dc8c8f6ee14e..6dce9a046066f 100644 --- a/src/test/ui/unsized5.stderr +++ b/src/test/ui/unsized5.stderr @@ -5,7 +5,7 @@ LL | f1: X, | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type @@ -16,7 +16,7 @@ LL | g: X, | ^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: only the last field of a struct may have a dynamically sized type @@ -27,7 +27,7 @@ LL | f: str, | ^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `str` - = note: to learn more, visit + = note: to learn more, visit = note: only the last field of a struct may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time @@ -37,7 +37,7 @@ LL | f: [u8], | ^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: only the last field of a struct may have a dynamically sized type error[E0277]: the size for values of type `X` cannot be known at compilation time @@ -47,7 +47,7 @@ LL | V1(X, isize), | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type @@ -58,7 +58,7 @@ LL | V2{f1: X, f: isize}, | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: no field of an enum variant may have a dynamically sized type diff --git a/src/test/ui/unsized6.stderr b/src/test/ui/unsized6.stderr index 058c22e2145e4..a6a26573e7c59 100644 --- a/src/test/ui/unsized6.stderr +++ b/src/test/ui/unsized6.stderr @@ -5,7 +5,7 @@ LL | let y: Y; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -17,7 +17,7 @@ LL | let _: (isize, (X, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: only the last element of a tuple may have a dynamically sized type @@ -28,7 +28,7 @@ LL | let y: (isize, (Z, usize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Z` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Z: std::marker::Sized` bound = note: only the last element of a tuple may have a dynamically sized type @@ -39,7 +39,7 @@ LL | let y: X; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -51,7 +51,7 @@ LL | let y: (isize, (Y, isize)); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `Y` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where Y: std::marker::Sized` bound = note: only the last element of a tuple may have a dynamically sized type @@ -62,7 +62,7 @@ LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -74,7 +74,7 @@ LL | let y = *x2; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -86,7 +86,7 @@ LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -98,7 +98,7 @@ LL | let y: X = *x1; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -110,7 +110,7 @@ LL | let y = *x2; | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -122,7 +122,7 @@ LL | let (y, z) = (*x3, 4); | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -134,7 +134,7 @@ LL | fn g1(x: X) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature @@ -146,7 +146,7 @@ LL | fn g2(x: X) {} | ^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound = note: all local variables must have a statically known size = help: unsized locals are gated as an unstable feature diff --git a/src/test/ui/unsized7.stderr b/src/test/ui/unsized7.stderr index 90f5a1f02d6c1..bb83b1811844a 100644 --- a/src/test/ui/unsized7.stderr +++ b/src/test/ui/unsized7.stderr @@ -5,7 +5,7 @@ LL | impl T1 for S3 { | ^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `X` - = note: to learn more, visit + = note: to learn more, visit = help: consider adding a `where X: std::marker::Sized` bound error: aborting due to previous error diff --git a/src/test/ui/wf/wf-array-elem-sized.stderr b/src/test/ui/wf/wf-array-elem-sized.stderr index 249a2d0930598..69df9ea7857d5 100644 --- a/src/test/ui/wf/wf-array-elem-sized.stderr +++ b/src/test/ui/wf/wf-array-elem-sized.stderr @@ -5,7 +5,7 @@ LL | foo: [[u8]], //~ ERROR E0277 | ^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `[u8]` - = note: to learn more, visit + = note: to learn more, visit = note: slice and array elements must have `Sized` type error: aborting due to previous error diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index 62305be599e33..594ce7d2f49ca 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -20,7 +20,7 @@ LL | fn bar() where Vec:, {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::marker::Copy + 'static)` - = note: to learn more, visit + = note: to learn more, visit = note: required by `std::vec::Vec` error[E0038]: the trait `std::marker::Copy` cannot be made into an object From b903cb9d6001bf6c199f15ffc0c61fdad802f328 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 11 Dec 2018 19:56:59 +0100 Subject: [PATCH 29/58] Move the `Unevaluated` constant arm upwards in the type structure --- src/librustc/ich/impls_ty.rs | 6 +- src/librustc/mir/interpret/value.rs | 10 +-- src/librustc/mir/mod.rs | 16 +++- src/librustc/mir/tcx.rs | 2 +- src/librustc/mir/visit.rs | 4 +- src/librustc/traits/error_reporting.rs | 26 ++++--- src/librustc/traits/project.rs | 12 +-- src/librustc/traits/query/normalize.rs | 13 ++-- src/librustc/ty/codec.rs | 16 ++++ src/librustc/ty/context.rs | 25 ++++++- src/librustc/ty/error.rs | 7 +- src/librustc/ty/flags.rs | 14 +--- src/librustc/ty/fold.rs | 9 +-- src/librustc/ty/inhabitedness/mod.rs | 15 ++-- src/librustc/ty/layout.rs | 2 +- src/librustc/ty/mod.rs | 2 +- src/librustc/ty/relate.rs | 22 ++---- src/librustc/ty/structural_impls.rs | 38 +++++----- src/librustc/ty/sty.rs | 45 +++++++---- src/librustc/ty/walk.rs | 12 +-- src/librustc/ty/wf.rs | 11 +-- src/librustc/util/ppaux.rs | 9 +-- .../debuginfo/metadata.rs | 2 +- .../debuginfo/type_names.rs | 2 +- src/librustc_codegen_ssa/base.rs | 2 +- src/librustc_codegen_ssa/mir/constant.rs | 12 +-- src/librustc_codegen_ssa/mir/operand.rs | 1 - src/librustc_codegen_ssa/mir/rvalue.rs | 2 +- .../borrow_check/error_reporting.rs | 5 +- .../borrow_check/mutability_errors.rs | 4 +- src/librustc_mir/borrow_check/nll/renumber.rs | 2 +- .../borrow_check/nll/type_check/mod.rs | 15 ++-- .../borrow_check/places_conflict.rs | 2 +- src/librustc_mir/build/expr/as_rvalue.rs | 12 +-- src/librustc_mir/build/matches/test.rs | 1 + src/librustc_mir/build/misc.rs | 2 +- src/librustc_mir/build/mod.rs | 2 +- src/librustc_mir/const_eval.rs | 12 +-- src/librustc_mir/hair/cx/expr.rs | 39 +++++----- src/librustc_mir/hair/cx/mod.rs | 12 +-- src/librustc_mir/hair/mod.rs | 4 +- src/librustc_mir/hair/pattern/_match.rs | 38 +++++----- src/librustc_mir/hair/pattern/mod.rs | 4 +- src/librustc_mir/interpret/cast.rs | 2 +- src/librustc_mir/interpret/operand.rs | 19 +++-- src/librustc_mir/monomorphize/collector.rs | 75 ++++++++++--------- src/librustc_mir/monomorphize/item.rs | 2 +- src/librustc_mir/shim.rs | 14 +++- src/librustc_mir/transform/const_prop.rs | 2 +- src/librustc_mir/transform/elaborate_drops.rs | 4 +- src/librustc_mir/transform/erase_regions.rs | 2 +- src/librustc_mir/transform/generator.rs | 8 +- src/librustc_mir/transform/qualify_consts.rs | 14 ++-- .../transform/simplify_branches.rs | 25 ++++--- .../transform/uniform_array_move_out.rs | 4 +- src/librustc_mir/util/elaborate_drops.rs | 6 +- src/librustc_mir/util/pretty.rs | 19 +++-- .../chalk_context/program_clauses.rs | 2 +- src/librustc_typeck/astconv.rs | 3 +- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/mod.rs | 4 +- src/librustdoc/clean/mod.rs | 23 +++--- 62 files changed, 405 insertions(+), 316 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index b2fe4b7561c5a..57a53d3f09a2e 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -301,7 +301,6 @@ impl_stable_hash_for!(struct ty::FieldDef { impl_stable_hash_for!( impl<'tcx> for enum mir::interpret::ConstValue<'tcx> [ mir::interpret::ConstValue ] { - Unevaluated(def_id, substs), Scalar(val), ScalarPair(a, b), ByRef(id, alloc, offset), @@ -378,6 +377,11 @@ impl_stable_hash_for!(struct ty::Const<'tcx> { val }); +impl_stable_hash_for!(impl<'tcx> for enum ty::LazyConst<'tcx> [ty::LazyConst] { + Unevaluated(did, substs), + Evaluated(c) +}); + impl_stable_hash_for!(enum mir::interpret::ErrorHandled { Reported, TooGeneric diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 1e4cfedc2a6ae..26a8e63254008 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -1,7 +1,6 @@ use std::fmt; -use crate::ty::{Ty, subst::Substs, layout::{HasDataLayout, Size}}; -use crate::hir::def_id::DefId; +use crate::ty::{Ty, layout::{HasDataLayout, Size}}; use super::{EvalResult, Pointer, PointerArithmetic, Allocation, AllocId, sign_extend, truncate}; @@ -18,12 +17,6 @@ pub struct RawConst<'tcx> { /// matches the LocalValue optimizations for easy conversions between Value and ConstValue. #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)] pub enum ConstValue<'tcx> { - /// Never returned from the `const_eval` query, but the HIR contains these frequently in order - /// to allow HIR creation to happen for everything before needing to be able to run constant - /// evaluation - /// FIXME: The query should then return a type that does not even have this variant. - Unevaluated(DefId, &'tcx Substs<'tcx>), - /// Used only for types with layout::abi::Scalar ABI and ZSTs /// /// Not using the enum `Value` to encode that this must not be `Undef` @@ -43,7 +36,6 @@ impl<'tcx> ConstValue<'tcx> { #[inline] pub fn try_to_scalar(&self) -> Option { match *self { - ConstValue::Unevaluated(..) | ConstValue::ByRef(..) | ConstValue::ScalarPair(..) => None, ConstValue::Scalar(val) => Some(val), diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 2936405ebd0b7..eafae6d9c9e8d 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2154,7 +2154,9 @@ impl<'tcx> Operand<'tcx> { span, ty, user_ty: None, - literal: ty::Const::zero_sized(tcx, ty), + literal: tcx.intern_lazy_const( + ty::LazyConst::Evaluated(ty::Const::zero_sized(tcx, ty)), + ), }) } @@ -2457,7 +2459,7 @@ pub struct Constant<'tcx> { /// Needed for NLL to impose user-given type constraints. pub user_ty: Option, - pub literal: &'tcx ty::Const<'tcx>, + pub literal: &'tcx ty::LazyConst<'tcx>, } /// A collection of projections into user types. @@ -2655,7 +2657,15 @@ newtype_index! { impl<'tcx> Debug for Constant<'tcx> { fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { write!(fmt, "const ")?; - fmt_const_val(fmt, self.literal) + fmt_lazy_const_val(fmt, self.literal) + } +} + +/// Write a `ConstValue` in a way closer to the original source code than the `Debug` output. +pub fn fmt_lazy_const_val(f: &mut impl Write, const_val: &ty::LazyConst<'_>) -> fmt::Result { + match const_val { + ty::LazyConst::Unevaluated(..) => write!(f, "{:?}", const_val), + ty::LazyConst::Evaluated(c) => fmt_const_val(f, c), } } diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index c5b884525da4b..6dda1933bbafa 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { PlaceTy::Ty { ty: match ty.sty { ty::Array(inner, size) => { - let size = size.unwrap_usize(tcx); + let size = size.unwrap_evaluated().unwrap_usize(tcx); let len = size - (from as u64) - (to as u64); tcx.mk_array(inner, len) } diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 67f85fbc8679e..a0fae3aa927ce 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -233,7 +233,7 @@ macro_rules! make_mir_visitor { } fn visit_const(&mut self, - constant: & $($mutability)* &'tcx ty::Const<'tcx>, + constant: & $($mutability)* &'tcx ty::LazyConst<'tcx>, _: Location) { self.super_const(constant); } @@ -892,7 +892,7 @@ macro_rules! make_mir_visitor { fn super_region(&mut self, _region: & $($mutability)* ty::Region<'tcx>) { } - fn super_const(&mut self, _const: & $($mutability)* &'tcx ty::Const<'tcx>) { + fn super_const(&mut self, _const: & $($mutability)* &'tcx ty::LazyConst<'tcx>) { } fn super_substs(&mut self, _substs: & $($mutability)* &'tcx Substs<'tcx>) { diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 0e63ef666c75a..f66dcb8dffda5 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -418,18 +418,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { Some(format!("[{}]", self.tcx.type_of(def.did).to_string())), )); let tcx = self.tcx; - if let Some(len) = len.val.try_to_scalar().and_then(|scalar| { - scalar.to_usize(&tcx).ok() - }) { - flags.push(( - "_Self".to_owned(), - Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), - )); - } else { - flags.push(( - "_Self".to_owned(), - Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())), - )); + if let ty::LazyConst::Evaluated(len) = len { + if let Some(len) = len.val.try_to_scalar().and_then(|scalar| { + scalar.to_usize(&tcx).ok() + }) { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), + )); + } else { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())), + )); + } } } } diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index 952b37b89f2d4..87e9c3b2c888a 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -15,7 +15,6 @@ use super::util; use hir::def_id::DefId; use infer::{InferCtxt, InferOk}; use infer::type_variable::TypeVariableOrigin; -use mir::interpret::ConstValue; use mir::interpret::{GlobalId}; use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap}; use syntax::ast::Ident; @@ -410,8 +409,8 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, } } - fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { - if let ConstValue::Unevaluated(def_id, substs) = constant.val { + fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { + if let ty::LazyConst::Unevaluated(def_id, substs) = *constant { let tcx = self.selcx.tcx().global_tcx(); if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) { if substs.needs_infer() || substs.has_placeholders() { @@ -423,8 +422,9 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, promoted: None }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - let evaluated = evaluated.subst(self.tcx(), substs); - return self.fold_const(evaluated); + let substs = tcx.lift_to_global(&substs).unwrap(); + let evaluated = evaluated.subst(tcx, substs); + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } else { @@ -436,7 +436,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for AssociatedTypeNormalizer<'a, promoted: None }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - return self.fold_const(evaluated) + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index 0d126d37546d6..be05445cfc61a 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -5,7 +5,7 @@ use infer::at::At; use infer::canonical::OriginalQueryValues; use infer::{InferCtxt, InferOk}; -use mir::interpret::{ConstValue, GlobalId}; +use mir::interpret::GlobalId; use traits::project::Normalized; use traits::{Obligation, ObligationCause, PredicateObligation, Reveal}; use ty::fold::{TypeFoldable, TypeFolder}; @@ -188,8 +188,8 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx } } - fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { - if let ConstValue::Unevaluated(def_id, substs) = constant.val { + fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { + if let ty::LazyConst::Unevaluated(def_id, substs) = *constant { let tcx = self.infcx.tcx.global_tcx(); if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) { if substs.needs_infer() || substs.has_placeholders() { @@ -201,8 +201,9 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx promoted: None, }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - let evaluated = evaluated.subst(self.tcx(), substs); - return self.fold_const(evaluated); + let substs = tcx.lift_to_global(&substs).unwrap(); + let evaluated = evaluated.subst(tcx, substs); + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } else { @@ -214,7 +215,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx promoted: None, }; if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) { - return self.fold_const(evaluated) + return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated)); } } } diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 6429e3249c4c5..57b99db0c7d54 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -255,6 +255,15 @@ pub fn decode_const<'a, 'tcx, D>(decoder: &mut D) Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?)) } +#[inline] +pub fn decode_lazy_const<'a, 'tcx, D>(decoder: &mut D) + -> Result<&'tcx ty::LazyConst<'tcx>, D::Error> + where D: TyDecoder<'a, 'tcx>, + 'tcx: 'a, +{ + Ok(decoder.tcx().intern_lazy_const(Decodable::decode(decoder)?)) +} + #[inline] pub fn decode_allocation<'a, 'tcx, D>(decoder: &mut D) -> Result<&'tcx Allocation, D::Error> @@ -396,6 +405,13 @@ macro_rules! implement_ty_decoder { } } + impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::LazyConst<'tcx>> + for $DecoderName<$($typaram),*> { + fn specialized_decode(&mut self) -> Result<&'tcx ty::LazyConst<'tcx>, Self::Error> { + decode_lazy_const(self) + } + } + impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::mir::interpret::Allocation> for $DecoderName<$($typaram),*> { fn specialized_decode( diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 32348e2e5046d..715e7367fada7 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -29,7 +29,7 @@ use traits; use traits::{Clause, Clauses, GoalKind, Goal, Goals}; use ty::{self, Ty, TypeAndMut}; use ty::{TyS, TyKind, List}; -use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const}; +use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const, LazyConst}; use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate}; use ty::RegionKind; use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; @@ -1112,6 +1112,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }) } + pub fn intern_lazy_const(self, c: ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { + self.global_interners.arena.alloc(c) + } + pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails { self.layout_interner.borrow_mut().intern(layout, |layout| { self.global_arenas.layout.alloc(layout) @@ -1814,6 +1818,21 @@ impl<'a, 'tcx> Lift<'tcx> for &'a List> { } } +impl<'a, 'tcx> Lift<'tcx> for &'a LazyConst<'a> { + type Lifted = &'tcx LazyConst<'tcx>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx LazyConst<'tcx>> { + if tcx.interners.arena.in_arena(*self as *const _) { + return Some(unsafe { mem::transmute(*self) }); + } + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } + } +} + impl<'a, 'tcx> Lift<'tcx> for &'a Const<'a> { type Lifted = &'tcx Const<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Const<'tcx>> { @@ -2683,7 +2702,9 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> { - self.mk_ty(Array(ty, ty::Const::from_usize(self, n))) + self.mk_ty(Array(ty, self.intern_lazy_const( + ty::LazyConst::Evaluated(ty::Const::from_usize(self.global_tcx(), n)) + ))) } #[inline] diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index c491fdd9957e8..67ff21e2a52d6 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -167,11 +167,12 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)).into(), ty::Foreign(def_id) => format!("extern type `{}`", tcx.item_path_str(def_id)).into(), - ty::Array(_, n) => { - match n.assert_usize(tcx) { + ty::Array(_, n) => match n { + ty::LazyConst::Evaluated(n) => match n.assert_usize(tcx) { Some(n) => format!("array of {} elements", n).into(), None => "array".into(), - } + }, + ty::LazyConst::Unevaluated(..) => "array".into(), } ty::Slice(_) => "slice".into(), ty::RawPtr(_) => "*-ptr".into(), diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 6ee24187e3326..4fa13a01d5a92 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -1,4 +1,3 @@ -use mir::interpret::ConstValue; use ty::subst::Substs; use ty::{self, Ty, TypeFlags, TypeFoldable}; @@ -173,7 +172,10 @@ impl FlagComputation { &ty::Array(tt, len) => { self.add_ty(tt); - self.add_const(len); + if let ty::LazyConst::Unevaluated(_, substs) = len { + self.add_flags(TypeFlags::HAS_PROJECTION); + self.add_substs(substs); + } } &ty::Slice(tt) => { @@ -230,14 +232,6 @@ impl FlagComputation { } } - fn add_const(&mut self, constant: &ty::Const<'_>) { - self.add_ty(constant.ty); - if let ConstValue::Unevaluated(_, substs) = constant.val { - self.add_flags(TypeFlags::HAS_PROJECTION); - self.add_substs(substs); - } - } - fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection<'_>) { self.add_substs(projection.substs); self.add_ty(projection.ty); diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index 0a72f733b51e5..4495e9654c984 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -29,7 +29,6 @@ //! These methods return true to indicate that the visitor has found what it is looking for //! and does not need to visit anything else. -use mir::interpret::ConstValue; use hir::def_id::DefId; use ty::{self, Binder, Ty, TyCtxt, TypeFlags}; @@ -164,7 +163,7 @@ pub trait TypeFolder<'gcx: 'tcx, 'tcx> : Sized { r.super_fold_with(self) } - fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> { + fn fold_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> { c.super_fold_with(self) } } @@ -182,7 +181,7 @@ pub trait TypeVisitor<'tcx> : Sized { r.super_visit_with(self) } - fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool { + fn visit_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> bool { c.super_visit_with(self) } } @@ -864,8 +863,8 @@ impl<'tcx> TypeVisitor<'tcx> for HasTypeFlagsVisitor { flags.intersects(self.flags) } - fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool { - if let ConstValue::Unevaluated(..) = c.val { + fn visit_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> bool { + if let ty::LazyConst::Unevaluated(..) = c { let projection_flags = TypeFlags::HAS_NORMALIZABLE_PROJECTION | TypeFlags::HAS_PROJECTION; if projection_flags.intersects(self.flags) { diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index 29d201c1179e5..6dfc9681cfd86 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -1,6 +1,6 @@ use ty::context::TyCtxt; use ty::{AdtDef, VariantDef, FieldDef, Ty, TyS}; -use ty::{DefId, Substs}; +use ty::{self, DefId, Substs}; use ty::{AdtKind, Visibility}; use ty::TyKind::*; @@ -213,11 +213,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } Array(ty, len) => { - match len.assert_usize(tcx) { - // If the array is definitely non-empty, it's uninhabited if - // the type of its elements is uninhabited. - Some(n) if n != 0 => ty.uninhabited_from(tcx), - _ => DefIdForest::empty() + match len { + ty::LazyConst::Unevaluated(..) => DefIdForest::empty(), + ty::LazyConst::Evaluated(len) => match len.assert_usize(tcx) { + // If the array is definitely non-empty, it's uninhabited if + // the type of its elements is uninhabited. + Some(n) if n != 0 => ty.uninhabited_from(tcx), + _ => DefIdForest::empty() + }, } } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 171c53b7b20ba..1f25925a8e1d1 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -543,7 +543,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } let element = self.layout_of(element)?; - let count = count.unwrap_usize(tcx); + let count = count.unwrap_evaluated().unwrap_usize(tcx); let size = element.size.checked_mul(count, dl) .ok_or(LayoutError::SizeOverflow(ty))?; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index d40dd830e9fb9..20167bd41fb87 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -59,7 +59,7 @@ pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate}; pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut}; pub use self::sty::{TraitRef, TyKind, PolyTraitRef}; pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef}; -pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const}; +pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const, LazyConst}; pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region}; pub use self::sty::RegionKind; pub use self::sty::{TyVid, IntVid, FloatVid, RegionVid}; diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 84e15a751353e..6d310a9500a62 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -5,7 +5,6 @@ //! subtyping, type equality, etc. use hir::def_id::DefId; -use mir::interpret::ConstValue; use ty::subst::{Kind, UnpackedKind, Substs}; use ty::{self, Ty, TyCtxt, TypeFoldable}; use ty::error::{ExpectedFound, TypeError}; @@ -480,14 +479,9 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, (&ty::Array(a_t, sz_a), &ty::Array(b_t, sz_b)) => { let t = relation.relate(&a_t, &b_t)?; - assert_eq!(sz_a.ty, tcx.types.usize); - assert_eq!(sz_b.ty, tcx.types.usize); - let to_u64 = |x: &'tcx ty::Const<'tcx>| -> Result { - if let Some(s) = x.assert_usize(tcx) { - return Ok(s); - } - match x.val { - ConstValue::Unevaluated(def_id, substs) => { + let to_u64 = |x: ty::LazyConst<'tcx>| -> Result { + match x { + ty::LazyConst::Unevaluated(def_id, substs) => { // FIXME(eddyb) get the right param_env. let param_env = ty::ParamEnv::empty(); if let Some(substs) = tcx.lift_to_global(&substs) { @@ -513,14 +507,14 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, "array length could not be evaluated"); Err(ErrorReported) } - _ => { + ty::LazyConst::Evaluated(c) => c.assert_usize(tcx).ok_or_else(|| { tcx.sess.delay_span_bug(DUMMY_SP, - &format!("arrays should not have {:?} as length", x)); - Err(ErrorReported) - } + "array length could not be evaluated"); + ErrorReported + }) } }; - match (to_u64(sz_a), to_u64(sz_b)) { + match (to_u64(*sz_a), to_u64(*sz_b)) { (Ok(sz_a_u64), Ok(sz_b_u64)) => { if sz_a_u64 == sz_b_u64 { Ok(tcx.mk_ty(ty::Array(t, sz_a))) diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 4755adc4cd10d..28184725b1c81 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -53,6 +53,7 @@ CloneTypeFoldableAndLiftImpls! { ::ty::UniverseIndex, ::ty::Variance, ::syntax_pos::Span, + ConstValue<'tcx>, } /////////////////////////////////////////////////////////////////////////// @@ -1020,26 +1021,31 @@ EnumTypeFoldableImpl! { } } -impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::LazyConst<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - match *self { - ConstValue::Scalar(v) => ConstValue::Scalar(v), - ConstValue::ScalarPair(a, b) => ConstValue::ScalarPair(a, b), - ConstValue::ByRef(id, alloc, offset) => ConstValue::ByRef(id, alloc, offset), - ConstValue::Unevaluated(def_id, substs) => { - ConstValue::Unevaluated(def_id, substs.fold_with(folder)) + let new = match self { + ty::LazyConst::Evaluated(v) => ty::LazyConst::Evaluated(v.fold_with(folder)), + ty::LazyConst::Unevaluated(def_id, substs) => { + ty::LazyConst::Unevaluated(*def_id, substs.fold_with(folder)) } - } + }; + folder.tcx().intern_lazy_const(new) + } + + fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { + folder.fold_const(*self) } fn super_visit_with>(&self, visitor: &mut V) -> bool { match *self { - ConstValue::Scalar(_) | - ConstValue::ScalarPair(_, _) | - ConstValue::ByRef(_, _, _) => false, - ConstValue::Unevaluated(_, substs) => substs.visit_with(visitor), + ty::LazyConst::Evaluated(c) => c.visit_with(visitor), + ty::LazyConst::Unevaluated(_, substs) => substs.visit_with(visitor), } } + + fn visit_with>(&self, visitor: &mut V) -> bool { + visitor.visit_const(self) + } } impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> { @@ -1052,15 +1058,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> { }) } - fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - folder.fold_const(*self) - } - fn super_visit_with>(&self, visitor: &mut V) -> bool { self.ty.visit_with(visitor) || self.val.visit_with(visitor) } - - fn visit_with>(&self, visitor: &mut V) -> bool { - visitor.visit_const(self) - } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index f7adb83f8eb18..ba380dfc7c81e 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -113,7 +113,7 @@ pub enum TyKind<'tcx> { Str, /// An array with the given length. Written as `[T; n]`. - Array(Ty<'tcx>, &'tcx ty::Const<'tcx>), + Array(Ty<'tcx>, &'tcx ty::LazyConst<'tcx>), /// The pointee of an array slice. Written as `[T]`. Slice(Ty<'tcx>), @@ -2013,6 +2013,36 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } +#[derive(Copy, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)] +/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to `Evaluated` if the +/// code is monomorphic enough for that. +pub enum LazyConst<'tcx> { + Unevaluated(DefId, &'tcx Substs<'tcx>), + Evaluated(&'tcx Const<'tcx>), +} + +static_assert!(MEM_SIZE_OF_LAZY_CONST: ::std::mem::size_of::>() == 24); + +impl<'tcx> LazyConst<'tcx> { + pub fn unwrap_evaluated(self) -> &'tcx Const<'tcx> { + match self { + LazyConst::Evaluated(c) => c, + LazyConst::Unevaluated(..) => bug!("unexpected unevaluated constant"), + } + } + + pub fn map_evaluated(self, f: impl FnOnce(&'tcx Const<'tcx>) -> Option) -> Option { + match self { + LazyConst::Evaluated(c) => f(c), + LazyConst::Unevaluated(..) => None, + } + } + + pub fn assert_usize(self, tcx: TyCtxt<'_, '_, 'tcx>) -> Option { + self.map_evaluated(|c| c.assert_usize(tcx)) + } +} + /// Typed constant value. #[derive(Copy, Clone, Debug, Hash, RustcEncodable, RustcDecodable, Eq, PartialEq, Ord, PartialOrd)] pub struct Const<'tcx> { @@ -2022,18 +2052,6 @@ pub struct Const<'tcx> { } impl<'tcx> Const<'tcx> { - pub fn unevaluated( - tcx: TyCtxt<'_, '_, 'tcx>, - def_id: DefId, - substs: &'tcx Substs<'tcx>, - ty: Ty<'tcx>, - ) -> &'tcx Self { - tcx.mk_const(Const { - val: ConstValue::Unevaluated(def_id, substs), - ty, - }) - } - #[inline] pub fn from_const_value( tcx: TyCtxt<'_, '_, 'tcx>, @@ -2149,3 +2167,4 @@ impl<'tcx> Const<'tcx> { } impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Const<'tcx> {} +impl<'tcx> serialize::UseSpecializedDecodable for &'tcx LazyConst<'tcx> {} diff --git a/src/librustc/ty/walk.rs b/src/librustc/ty/walk.rs index a2cc859e4a82d..6887d092fcd62 100644 --- a/src/librustc/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -1,7 +1,6 @@ //! An iterator over the type substructure. //! WARNING: this does not keep track of the region depth. -use mir::interpret::ConstValue; use ty::{self, Ty}; use smallvec::{self, SmallVec}; @@ -75,7 +74,9 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { ty::Placeholder(..) | ty::Bound(..) | ty::Foreign(..) => { } ty::Array(ty, len) => { - push_const(stack, len); + if let ty::LazyConst::Unevaluated(_, substs) = len { + stack.extend(substs.types().rev()); + } stack.push(ty); } ty::Slice(ty) => { @@ -128,10 +129,3 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) { } } } - -fn push_const<'tcx>(stack: &mut TypeWalkerStack<'tcx>, constant: &'tcx ty::Const<'tcx>) { - if let ConstValue::Unevaluated(_, substs) = constant.val { - stack.extend(substs.types().rev()); - } - stack.push(constant.ty); -} diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index aacc63c47de61..517cfd9edfaf9 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -1,5 +1,4 @@ use hir::def_id::DefId; -use mir::interpret::ConstValue; use infer::InferCtxt; use ty::subst::Substs; use traits; @@ -202,11 +201,10 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { } } - /// Pushes the obligations required for a constant value to be WF + /// Pushes the obligations required for an array length to be WF /// into `self.out`. - fn compute_const(&mut self, constant: &'tcx ty::Const<'tcx>) { - self.require_sized(constant.ty, traits::ConstSized); - if let ConstValue::Unevaluated(def_id, substs) = constant.val { + fn compute_array_len(&mut self, constant: ty::LazyConst<'tcx>) { + if let ty::LazyConst::Unevaluated(def_id, substs) = constant { let obligations = self.nominal_obligations(def_id, substs); self.out.extend(obligations); @@ -260,8 +258,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { ty::Array(subty, len) => { self.require_sized(subty, traits::SliceOrArrayElem); - assert_eq!(len.ty, self.infcx.tcx.types.usize); - self.compute_const(len); + self.compute_array_len(*len); } ty::Tuple(ref tys) => { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 318d7adb19011..1356fbb6489cc 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -1,6 +1,5 @@ use hir::def_id::DefId; use hir::map::definitions::DefPathData; -use mir::interpret::ConstValue; use middle::region; use ty::subst::{self, Subst}; use ty::{BrAnon, BrEnv, BrFresh, BrNamed}; @@ -1272,12 +1271,12 @@ define_print! { }), Array(ty, sz) => { print!(f, cx, write("["), print(ty), write("; "))?; - match sz.val { - ConstValue::Unevaluated(_def_id, _substs) => { + match sz { + ty::LazyConst::Unevaluated(_def_id, _substs) => { write!(f, "_")?; } - _ => ty::tls::with(|tcx| { - write!(f, "{}", sz.unwrap_usize(tcx)) + ty::LazyConst::Evaluated(c) => ty::tls::with(|tcx| { + write!(f, "{}", c.unwrap_usize(tcx)) })?, } write!(f, "]") diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 0fd04e9d20393..bec0cfa0d862f 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -302,7 +302,7 @@ fn fixed_vec_metadata( let upper_bound = match array_or_slice_type.sty { ty::Array(_, len) => { - len.unwrap_usize(cx.tcx) as c_longlong + len.unwrap_evaluated().unwrap_usize(cx.tcx) as c_longlong } _ => -1 }; diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index c8cbd735e850d..c1309569c7955 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -88,7 +88,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ty::Array(inner_type, len) => { output.push('['); push_debuginfo_type_name(cx, inner_type, true, output); - output.push_str(&format!("; {}", len.unwrap_usize(cx.tcx))); + output.push_str(&format!("; {}", len.unwrap_evaluated().unwrap_usize(cx.tcx))); output.push(']'); }, ty::Slice(inner_type) => { diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index b88ec075653ba..166655f6a8061 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -171,7 +171,7 @@ pub fn unsized_info<'tcx, Cx: CodegenMethods<'tcx>>( let (source, target) = cx.tcx().struct_lockstep_tails(source, target); match (&source.sty, &target.sty) { (&ty::Array(_, len), &ty::Slice(_)) => { - cx.const_usize(len.unwrap_usize(cx.tcx())) + cx.const_usize(len.unwrap_evaluated().unwrap_usize(cx.tcx())) } (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 1a48ad87a6e15..58325e3443266 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -2,7 +2,7 @@ use rustc::mir::interpret::ErrorHandled; use rustc_mir::const_eval::const_field; use rustc::mir; use rustc_data_structures::indexed_vec::Idx; -use rustc::mir::interpret::{GlobalId, ConstValue}; +use rustc::mir::interpret::GlobalId; use rustc::ty::{self, Ty}; use rustc::ty::layout; use syntax::source_map::Span; @@ -14,10 +14,10 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn fully_evaluate( &mut self, bx: &Bx, - constant: &'tcx ty::Const<'tcx>, + constant: &'tcx ty::LazyConst<'tcx>, ) -> Result<&'tcx ty::Const<'tcx>, ErrorHandled> { - match constant.val { - ConstValue::Unevaluated(def_id, ref substs) => { + match *constant { + ty::LazyConst::Unevaluated(def_id, ref substs) => { let tcx = bx.tcx(); let param_env = ty::ParamEnv::reveal_all(); let instance = ty::Instance::resolve(tcx, param_env, def_id, substs).unwrap(); @@ -27,7 +27,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }; tcx.const_eval(param_env.and(cid)) }, - _ => Ok(constant), + ty::LazyConst::Evaluated(constant) => Ok(constant), } } @@ -52,7 +52,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { .and_then(|c| { let field_ty = c.ty.builtin_index().unwrap(); let fields = match c.ty.sty { - ty::Array(_, n) => n.unwrap_usize(bx.tcx()), + ty::Array(_, n) => n.unwrap_evaluated().unwrap_usize(bx.tcx()), ref other => bug!("invalid simd shuffle type: {}", other), }; let values: Result, ErrorHandled> = (0..fields).map(|field| { diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 1dbed30842a82..bb55bf3b46cd4 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -76,7 +76,6 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { } let val = match val.val { - ConstValue::Unevaluated(..) => bug!(), ConstValue::Scalar(x) => { let scalar = match layout.abi { layout::Abi::Scalar(ref x) => x, diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 9ca5414fa717e..404ee86c6a117 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -537,7 +537,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if let mir::Place::Local(index) = *place { if let LocalRef::Operand(Some(op)) = self.locals[index] { if let ty::Array(_, n) = op.layout.ty.sty { - let n = n.unwrap_usize(bx.cx().tcx()); + let n = n.unwrap_evaluated().unwrap_usize(bx.cx().tcx()); return bx.cx().const_usize(n); } } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 6a5b5d172bbe4..ab5a16a474437 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -1380,7 +1380,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { ); if let TerminatorKind::Call { func: Operand::Constant(box Constant { - literal: ty::Const { ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. }, .. }, + literal: ty::LazyConst::Evaluated(ty::Const { + ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. }, + .. + }), .. }), args, diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index 0be8ecffcdf38..63bf6faed40d4 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -468,13 +468,13 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { Terminator { kind: TerminatorKind::Call { func: Operand::Constant(box Constant { - literal: Const { + literal: ty::LazyConst::Evaluated(Const { ty: &TyS { sty: TyKind::FnDef(id, substs), .. }, .. - }, + }), .. }), .. diff --git a/src/librustc_mir/borrow_check/nll/renumber.rs b/src/librustc_mir/borrow_check/nll/renumber.rs index 55af7399aab8f..5c24da7621b2d 100644 --- a/src/librustc_mir/borrow_check/nll/renumber.rs +++ b/src/librustc_mir/borrow_check/nll/renumber.rs @@ -88,7 +88,7 @@ impl<'a, 'gcx, 'tcx> MutVisitor<'tcx> for NLLVisitor<'a, 'gcx, 'tcx> { debug!("visit_region: region={:?}", region); } - fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _location: Location) { + fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _location: Location) { *constant = self.renumber_regions(&*constant); } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 796a2f79f7554..3681c3d74ebd1 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -382,6 +382,11 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { constant, location ); + let literal = match constant.literal { + ty::LazyConst::Evaluated(lit) => lit, + ty::LazyConst::Unevaluated(..) => return, + }; + // FIXME(#46702) -- We need some way to get the predicates // associated with the "pre-evaluated" form of the // constant. For example, consider that the constant @@ -390,7 +395,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { // constraints on `'a` and `'b`. These constraints // would be lost if we just look at the normalized // value. - if let ty::FnDef(def_id, substs) = constant.literal.ty.sty { + if let ty::FnDef(def_id, substs) = literal.ty.sty { let tcx = self.tcx(); let type_checker = &mut self.cx; @@ -411,10 +416,10 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { ); } - debug!("sanitize_constant: expected_ty={:?}", constant.literal.ty); + debug!("sanitize_constant: expected_ty={:?}", literal.ty); if let Err(terr) = self.cx.eq_types( - constant.literal.ty, + literal.ty, constant.ty, location.to_locations(), ConstraintCategory::Boring, @@ -424,7 +429,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { constant, "constant {:?} should have type {:?} but has {:?} ({:?})", constant, - constant.literal.ty, + literal.ty, constant.ty, terr, ); @@ -563,7 +568,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { ProjectionElem::Subslice { from, to } => PlaceTy::Ty { ty: match base_ty.sty { ty::Array(inner, size) => { - let size = size.unwrap_usize(tcx); + let size = size.unwrap_evaluated().unwrap_usize(tcx); let min_size = (from as u64) + (to as u64); if let Some(rest_size) = size.checked_sub(min_size) { tcx.mk_array(inner, rest_size) diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index ac7182abb36da..88c27a869c089 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -388,7 +388,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>( (Place::Promoted(p1), Place::Promoted(p2)) => { if p1.0 == p2.0 { if let ty::Array(_, size) = p1.1.sty { - if size.unwrap_usize(tcx) == 0 { + if size.unwrap_evaluated().unwrap_usize(tcx) == 0 { // Ignore conflicts with promoted [T; 0]. debug!("place_element_conflict: IGNORE-LEN-0-PROMOTED"); return Overlap::Disjoint; diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 7dcac05e702a3..a66da50c48437 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -270,11 +270,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { span: expr_span, ty: this.hir.tcx().types.u32, user_ty: None, - literal: ty::Const::from_bits( - this.hir.tcx(), - 0, - ty::ParamEnv::empty().and(this.hir.tcx().types.u32), - ), + literal: this.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_bits( + this.hir.tcx(), + 0, + ty::ParamEnv::empty().and(this.hir.tcx().types.u32), + ), + )), })); box AggregateKind::Generator(closure_id, substs, movability) } diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 21109a223bf77..f601e38717f2d 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -302,6 +302,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } let eq_def_id = self.hir.tcx().lang_items().eq_trait().unwrap(); let (mty, method) = self.hir.trait_method(eq_def_id, "eq", ty, &[ty.into()]); + let method = self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(method)); // take the argument by reference let region_scope = self.topmost_scope(); diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index 472f05a101f9e..0689dcfceea25 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -33,7 +33,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { span, ty, user_ty: None, - literal, + literal: self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(literal)), }; Operand::Constant(constant) } diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 8acdecf6fa248..727b769cf4d44 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -202,7 +202,7 @@ impl<'a, 'gcx: 'tcx, 'tcx> MutVisitor<'tcx> for GlobalizeMir<'a, 'gcx> { } } - fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _: Location) { + fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _: Location) { if let Some(lifted) = self.tcx.lift(constant) { *constant = lifted; } else { diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index b9432997b7e19..58a0f13733ea8 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -136,12 +136,14 @@ pub fn op_to_const<'tcx>( }; Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty)) } + pub fn const_to_op<'tcx>( ecx: &CompileTimeEvalContext<'_, '_, 'tcx>, - cnst: &ty::Const<'tcx>, + cnst: ty::LazyConst<'tcx>, + ty: ty::Ty<'tcx>, ) -> EvalResult<'tcx, OpTy<'tcx>> { - let op = ecx.const_value_to_op(cnst.val)?; - Ok(OpTy { op, layout: ecx.layout_of(cnst.ty)? }) + let op = ecx.const_value_to_op(cnst)?; + Ok(OpTy { op, layout: ecx.layout_of(ty)? }) } fn eval_body_and_ecx<'a, 'mir, 'tcx>( @@ -514,7 +516,7 @@ pub fn const_field<'a, 'tcx>( let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); let result = (|| { // get the operand again - let op = const_to_op(&ecx, value)?; + let op = const_to_op(&ecx, ty::LazyConst::Evaluated(value), value.ty)?; // downcast let down = match variant { None => op, @@ -541,7 +543,7 @@ pub fn const_variant_index<'a, 'tcx>( ) -> EvalResult<'tcx, VariantIdx> { trace!("const_variant_index: {:?}, {:?}", instance, val); let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); - let op = const_to_op(&ecx, val)?; + let op = const_to_op(&ecx, ty::LazyConst::Evaluated(val), val.ty)?; Ok(ecx.read_discriminant(op)?.1) } diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 293058a0f26f5..e2d0f6b0ae625 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -356,7 +356,9 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } hir::ExprKind::Lit(ref lit) => ExprKind::Literal { - literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, false), + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + cx.const_eval_literal(&lit.node, expr_ty, lit.span, false) + )), user_ty: None, }, @@ -454,7 +456,9 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } else { if let hir::ExprKind::Lit(ref lit) = arg.node { ExprKind::Literal { - literal: cx.const_eval_literal(&lit.node, expr_ty, lit.span, true), + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + cx.const_eval_literal(&lit.node, expr_ty, lit.span, true) + )), user_ty: None, } } else { @@ -711,24 +715,22 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, temp_lifetime, ty: var_ty, span: expr.span, - kind: ExprKind::Literal { literal, user_ty: None }, + kind: ExprKind::Literal { + literal: cx.tcx.intern_lazy_const(literal), + user_ty: None + }, }.to_ref(); - let offset = mk_const(ty::Const::from_bits( + let offset = mk_const(ty::LazyConst::Evaluated(ty::Const::from_bits( cx.tcx, offset as u128, cx.param_env.and(var_ty), - )); + ))); match did { Some(did) => { // in case we are offsetting from a computed discriminant // and not the beginning of discriminants (which is always `0`) let substs = Substs::identity_for_item(cx.tcx(), did); - let lhs = mk_const(ty::Const::unevaluated( - cx.tcx(), - did, - substs, - var_ty, - )); + let lhs = mk_const(ty::LazyConst::Unevaluated(did, substs)); let bin = ExprKind::Binary { op: BinOp::Add, lhs, @@ -868,7 +870,9 @@ fn method_callee<'a, 'gcx, 'tcx>( ty, span, kind: ExprKind::Literal { - literal: ty::Const::zero_sized(cx.tcx(), ty), + literal: cx.tcx().intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::zero_sized(cx.tcx(), ty) + )), user_ty, }, } @@ -928,10 +932,10 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def); debug!("convert_path_expr: user_ty={:?}", user_ty); ExprKind::Literal { - literal: ty::Const::zero_sized( + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::zero_sized( cx.tcx, cx.tables().node_id_to_type(expr.hir_id), - ), + ))), user_ty, } }, @@ -941,12 +945,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def); debug!("convert_path_expr: (const) user_ty={:?}", user_ty); ExprKind::Literal { - literal: ty::Const::unevaluated( - cx.tcx, - def_id, - substs, - cx.tables().node_id_to_type(expr.hir_id), - ), + literal: cx.tcx.intern_lazy_const(ty::LazyConst::Unevaluated(def_id, substs)), user_ty, } }, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 60c8022a374be..5681237c14b3e 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -108,8 +108,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { self.tcx.types.usize } - pub fn usize_literal(&mut self, value: u64) -> &'tcx ty::Const<'tcx> { - ty::Const::from_usize(self.tcx, value) + pub fn usize_literal(&mut self, value: u64) -> &'tcx ty::LazyConst<'tcx> { + self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_usize(self.tcx, value))) } pub fn bool_ty(&mut self) -> Ty<'tcx> { @@ -120,12 +120,12 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { self.tcx.mk_unit() } - pub fn true_literal(&mut self) -> &'tcx ty::Const<'tcx> { - ty::Const::from_bool(self.tcx, true) + pub fn true_literal(&mut self) -> &'tcx ty::LazyConst<'tcx> { + self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, true))) } - pub fn false_literal(&mut self) -> &'tcx ty::Const<'tcx> { - ty::Const::from_bool(self.tcx, false) + pub fn false_literal(&mut self) -> &'tcx ty::LazyConst<'tcx> { + self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, false))) } pub fn const_eval_literal( diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index b56e3d4e77395..676b98457489f 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -9,7 +9,7 @@ use rustc::hir::def_id::DefId; use rustc::infer::canonical::Canonical; use rustc::middle::region; use rustc::ty::subst::Substs; -use rustc::ty::{AdtDef, UpvarSubsts, Region, Ty, Const, UserTypeAnnotation}; +use rustc::ty::{AdtDef, UpvarSubsts, Region, Ty, Const, LazyConst, UserTypeAnnotation}; use rustc::ty::layout::VariantIdx; use rustc::hir; use syntax::ast; @@ -288,7 +288,7 @@ pub enum ExprKind<'tcx> { movability: Option, }, Literal { - literal: &'tcx Const<'tcx>, + literal: &'tcx LazyConst<'tcx>, user_ty: Option>>, }, InlineAsm { diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 13838e5d85dda..176c2f6564361 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -635,7 +635,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, }).collect() } ty::Array(ref sub_ty, len) if len.assert_usize(cx.tcx).is_some() => { - let len = len.unwrap_usize(cx.tcx); + let len = len.unwrap_evaluated().unwrap_usize(cx.tcx); if len != 0 && cx.is_uninhabited(sub_ty) { vec![] } else { @@ -1310,7 +1310,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>, )]), PatternKind::Array { .. } => match pcx.ty.sty { ty::Array(_, length) => Some(vec![ - Slice(length.unwrap_usize(cx.tcx)) + Slice(length.unwrap_evaluated().unwrap_usize(cx.tcx)) ]), _ => span_bug!(pat.span, "bad ty {:?} for array pattern", pcx.ty) }, @@ -1751,23 +1751,23 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( // necessarily point to memory, they are usually just integers. The only time // they should be pointing to memory is when they are subslices of nonzero // slices - let (opt_ptr, n, ty) = match (value.val, &value.ty.sty) { - (ConstValue::ByRef(id, alloc, offset), ty::TyKind::Array(t, n)) => ( - Some(( - Pointer::new(id, offset), - alloc, - )), - n.unwrap_usize(cx.tcx), - t, - ), - (ConstValue::ScalarPair(ptr, n), ty::TyKind::Slice(t)) => ( - ptr.to_ptr().ok().map(|ptr| ( - ptr, - cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id), - )), - n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64, - t, - ), + let (opt_ptr, n, ty) = match value.ty.builtin_deref(false).unwrap().ty.sty { + ty::TyKind::Array(t, n) => + (value.to_ptr(), n.unwrap_evaluated().unwrap_usize(cx.tcx), t), + ty::TyKind::Slice(t) => { + match value.val { + ConstValue::ScalarPair(ptr, n) => ( + ptr.to_ptr().ok(), + n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64, + t, + ), + _ => span_bug!( + pat.span, + "slice pattern constant must be scalar pair but is {:?}", + value, + ), + } + }, _ => span_bug!( pat.span, "unexpected const-val {:?} with ctor {:?}", diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 10d2d7bc1b18b..d7eeaf4365102 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -650,7 +650,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ty::Array(_, len) => { // fixed-length array - let len = len.unwrap_usize(self.tcx); + let len = len.unwrap_evaluated().unwrap_usize(self.tcx); assert!(len >= prefix.len() as u64 + suffix.len() as u64); PatternKind::Array { prefix: prefix, slice: slice, suffix: suffix } } @@ -934,7 +934,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } ty::Array(_, n) => { PatternKind::Array { - prefix: (0..n.unwrap_usize(self.tcx)) + prefix: (0..n.unwrap_evaluated().unwrap_usize(self.tcx)) .map(|i| adt_subpattern(i as usize, None)) .collect(), slice: None, diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 190a381cf52a5..37c5340e0a26c 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -307,7 +307,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // u64 cast is from usize to u64, which is always good let val = Immediate::new_slice( ptr, - length.unwrap_usize(self.tcx.tcx), + length.unwrap_evaluated().unwrap_usize(self.tcx.tcx), self, ); self.write_immediate(val, dest) diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 1ea3f78c2104f..04e0955ad6172 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; -use rustc::mir; +use rustc::{mir, ty}; use rustc::ty::layout::{self, Size, LayoutOf, TyLayout, HasDataLayout, IntegerExt, VariantIdx}; use rustc::mir::interpret::{ @@ -517,7 +517,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let ty = self.monomorphize(mir_op.ty(self.mir(), *self.tcx), self.substs()); self.layout_of(ty) })?; - let op = self.const_value_to_op(constant.literal.val)?; + let op = self.const_value_to_op(*constant.literal)?; OpTy { op, layout } } }; @@ -540,17 +540,20 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // `eval_operand`, ideally). pub(crate) fn const_value_to_op( &self, - val: ConstValue<'tcx>, + val: ty::LazyConst<'tcx>, ) -> EvalResult<'tcx, Operand> { trace!("const_value_to_op: {:?}", val); - match val { - ConstValue::Unevaluated(def_id, substs) => { + let val = match val { + ty::LazyConst::Unevaluated(def_id, substs) => { let instance = self.resolve(def_id, substs)?; - Ok(*OpTy::from(self.const_eval_raw(GlobalId { + return Ok(*OpTy::from(self.const_eval_raw(GlobalId { instance, promoted: None, - })?)) - } + })?)); + }, + ty::LazyConst::Evaluated(c) => c, + }; + match val.val { ConstValue::ByRef(id, alloc, offset) => { // We rely on mutability being set correctly in that allocation to prevent writes // where none should happen -- and for `static mut`, we copy on demand anyway. diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index d81a4d6a4bc84..757f94f2076ac 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -381,7 +381,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let param_env = ty::ParamEnv::reveal_all(); if let Ok(val) = tcx.const_eval(param_env.and(cid)) { - collect_const(tcx, val, instance.substs, &mut neighbors); + collect_const(tcx, val, &mut neighbors); } } MonoItem::Fn(instance) => { @@ -583,10 +583,10 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { self.super_rvalue(rvalue, location); } - fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, location: Location) { + fn visit_const(&mut self, constant: &&'tcx ty::LazyConst<'tcx>, location: Location) { debug!("visiting const {:?} @ {:?}", *constant, location); - collect_const(self.tcx, constant, self.param_substs, self.output); + collect_lazy_const(self.tcx, constant, self.param_substs, self.output); self.super_const(constant); } @@ -987,7 +987,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> { let param_env = ty::ParamEnv::reveal_all(); if let Ok(val) = self.tcx.const_eval(param_env.and(cid)) { - collect_const(self.tcx, val, instance.substs, &mut self.output); + collect_const(self.tcx, val, &mut self.output); } } hir::ItemKind::Fn(..) => { @@ -1198,7 +1198,7 @@ fn collect_neighbours<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, promoted: Some(i), }; match tcx.const_eval(param_env.and(cid)) { - Ok(val) => collect_const(tcx, val, instance.substs, output), + Ok(val) => collect_const(tcx, val, output), Err(ErrorHandled::Reported) => {}, Err(ErrorHandled::TooGeneric) => span_bug!( mir.promoted[i].span, "collection encountered polymorphic constant", @@ -1216,43 +1216,48 @@ fn def_id_to_string<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, output } +fn collect_lazy_const<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, + constant: &ty::LazyConst<'tcx>, + param_substs: &'tcx Substs<'tcx>, + output: &mut Vec>, +) { + let (def_id, substs) = match *constant { + ty::LazyConst::Evaluated(c) => return collect_const(tcx, c, output), + ty::LazyConst::Unevaluated(did, substs) => (did, substs), + }; + let param_env = ty::ParamEnv::reveal_all(); + let substs = tcx.subst_and_normalize_erasing_regions( + param_substs, + param_env, + &substs, + ); + let instance = ty::Instance::resolve(tcx, + param_env, + def_id, + substs).unwrap(); + + let cid = GlobalId { + instance, + promoted: None, + }; + match tcx.const_eval(param_env.and(cid)) { + Ok(val) => collect_const(tcx, val, output), + Err(ErrorHandled::Reported) => {}, + Err(ErrorHandled::TooGeneric) => span_bug!( + tcx.def_span(def_id), "collection encountered polymorphic constant", + ), + } +} + fn collect_const<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, constant: &ty::Const<'tcx>, - param_substs: &'tcx Substs<'tcx>, output: &mut Vec>, ) { debug!("visiting const {:?}", *constant); - let val = match constant.val { - ConstValue::Unevaluated(def_id, substs) => { - let param_env = ty::ParamEnv::reveal_all(); - let substs = tcx.subst_and_normalize_erasing_regions( - param_substs, - param_env, - &substs, - ); - let instance = ty::Instance::resolve(tcx, - param_env, - def_id, - substs).unwrap(); - - let cid = GlobalId { - instance, - promoted: None, - }; - match tcx.const_eval(param_env.and(cid)) { - Ok(val) => val.val, - Err(ErrorHandled::Reported) => return, - Err(ErrorHandled::TooGeneric) => span_bug!( - tcx.def_span(def_id), "collection encountered polymorphic constant", - ), - } - }, - _ => constant.val, - }; - match val { - ConstValue::Unevaluated(..) => bug!("const eval yielded unevaluated const"), + match constant.val { ConstValue::ScalarPair(Scalar::Ptr(a), Scalar::Ptr(b)) => { collect_miri(tcx, a.alloc_id, output); collect_miri(tcx, b.alloc_id, output); diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index e7f4451fdd7ee..8cd8eb3ad64c2 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -295,7 +295,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { ty::Array(inner_type, len) => { output.push('['); self.push_type_name(inner_type, output); - write!(output, "; {}", len.unwrap_usize(self.tcx)).unwrap(); + write!(output, "; {}", len.unwrap_evaluated().unwrap_usize(self.tcx)).unwrap(); output.push(']'); }, ty::Slice(inner_type) => { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 4c123d4a44b05..835a5dede742f 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -318,7 +318,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match self_ty.sty { _ if is_copy => builder.copy_shim(), ty::Array(ty, len) => { - let len = len.unwrap_usize(tcx); + let len = len.unwrap_evaluated().unwrap_usize(tcx); builder.array_shim(dest, src, ty, len) } ty::Closure(def_id, substs) => { @@ -459,7 +459,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { span: self.span, ty: func_ty, user_ty: None, - literal: ty::Const::zero_sized(self.tcx, func_ty), + literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::zero_sized(self.tcx, func_ty), + )), }); let ref_loc = self.make_place( @@ -519,7 +521,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { span: self.span, ty: self.tcx.types.usize, user_ty: None, - literal: ty::Const::from_usize(self.tcx, value), + literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_usize(self.tcx, value), + )), } } @@ -755,7 +759,9 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span, ty, user_ty: None, - literal: ty::Const::zero_sized(tcx, ty), + literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::zero_sized(tcx, ty) + )), }), vec![rcvr]) } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 34f544745a787..a2a416e54d8ca 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -255,7 +255,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> { source_info: SourceInfo, ) -> Option> { self.ecx.tcx.span = source_info.span; - match const_to_op(&self.ecx, c.literal) { + match const_to_op(&self.ecx, *c.literal, c.ty) { Ok(op) => { Some((op, c.span)) }, diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index b98e3d7d8bb7a..06e16de8b43bc 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -533,7 +533,9 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> { span, ty: self.tcx.types.bool, user_ty: None, - literal: ty::Const::from_bool(self.tcx, val), + literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_bool(self.tcx, val), + )), }))) } diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index 009570c378ad2..b464b7d65e466 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -32,7 +32,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> { *region = self.tcx.types.re_erased; } - fn visit_const(&mut self, constant: &mut &'tcx ty::Const<'tcx>, _: Location) { + fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _: Location) { *constant = self.tcx.erase_regions(constant); } diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index b43e839271863..808c3aad29201 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -171,11 +171,11 @@ impl<'a, 'tcx> TransformVisitor<'a, 'tcx> { span: source_info.span, ty: self.tcx.types.u32, user_ty: None, - literal: ty::Const::from_bits( + literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bits( self.tcx, state_disc.into(), ty::ParamEnv::empty().and(self.tcx.types.u32) - ), + ))), }); Statement { source_info, @@ -717,7 +717,9 @@ fn insert_panic_block<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: mir.span, ty: tcx.types.bool, user_ty: None, - literal: ty::Const::from_bool(tcx, false), + literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_bool(tcx, false), + )), }), expected: true, msg: message, diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 7b04af62fe6cc..209c26a0c6c46 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -11,7 +11,6 @@ use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi::Abi; use rustc::hir; use rustc::hir::def_id::DefId; -use rustc::mir::interpret::ConstValue; use rustc::traits::{self, TraitEngine}; use rustc::ty::{self, TyCtxt, Ty, TypeFoldable}; use rustc::ty::cast::CastTy; @@ -625,12 +624,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } } Operand::Constant(ref constant) => { - if let ConstValue::Unevaluated(def_id, _) = constant.literal.val { + if let ty::LazyConst::Unevaluated(def_id, _) = constant.literal { // Don't peek inside trait associated constants. - if self.tcx.trait_of_item(def_id).is_some() { - self.add_type(constant.literal.ty); + if self.tcx.trait_of_item(*def_id).is_some() { + self.add_type(constant.ty); } else { - let (bits, _) = self.tcx.at(constant.span).mir_const_qualif(def_id); + let (bits, _) = self.tcx.at(constant.span).mir_const_qualif(*def_id); let qualif = Qualif::from_bits(bits).expect("invalid mir_const_qualif"); self.add(qualif); @@ -638,7 +637,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { // Just in case the type is more specific than // the definition, e.g., impl associated const // with type parameters, take it into account. - self.qualif.restrict(constant.literal.ty, self.tcx, self.param_env); + self.qualif.restrict(constant.ty, self.tcx, self.param_env); } } } @@ -713,7 +712,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } else if let ty::Array(_, len) = ty.sty { // FIXME(eddyb) the `self.mode == Mode::Fn` condition // seems unnecessary, given that this is merely a ZST. - if len.unwrap_usize(self.tcx) == 0 && self.mode == Mode::Fn { + let len = len.unwrap_evaluated().unwrap_usize(self.tcx); + if len == 0 && self.mode == Mode::Fn { forbidden_mut = false; } } diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index 6cf9f43877b17..1d5bc4f9cc31b 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -1,6 +1,6 @@ //! A pass that simplifies branches when their condition is known. -use rustc::ty::{TyCtxt, ParamEnv}; +use rustc::ty::{self, TyCtxt, ParamEnv}; use rustc::mir::*; use transform::{MirPass, MirSource}; @@ -30,23 +30,28 @@ impl MirPass for SimplifyBranches { discr: Operand::Constant(ref c), switch_ty, ref values, ref targets, .. } => { let switch_ty = ParamEnv::empty().and(switch_ty); - if let Some(constint) = c.literal.assert_bits(tcx, switch_ty) { - let (otherwise, targets) = targets.split_last().unwrap(); - let mut ret = TerminatorKind::Goto { target: *otherwise }; - for (&v, t) in values.iter().zip(targets.iter()) { - if v == constint { - ret = TerminatorKind::Goto { target: *t }; - break; + if let ty::LazyConst::Evaluated(c) = c.literal { + let c = c.assert_bits(tcx, switch_ty); + if let Some(constant) = c { + let (otherwise, targets) = targets.split_last().unwrap(); + let mut ret = TerminatorKind::Goto { target: *otherwise }; + for (&v, t) in values.iter().zip(targets.iter()) { + if v == constant { + ret = TerminatorKind::Goto { target: *t }; + break; + } } + ret + } else { + continue } - ret } else { continue } }, TerminatorKind::Assert { target, cond: Operand::Constant(ref c), expected, .. - } if (c.literal.assert_bool(tcx) == Some(true)) == expected => { + } if (c.literal.unwrap_evaluated().assert_bool(tcx) == Some(true)) == expected => { TerminatorKind::Goto { target } }, TerminatorKind::FalseEdges { real_target, .. } => { diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 5ab9669baaca0..172993daa9a1c 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -71,7 +71,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> { } else { let place_ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); if let ty::Array(item_ty, const_size) = place_ty.sty { - if let Some(size) = const_size.assert_usize(self.tcx) { + if let Some(size) = const_size.unwrap_evaluated().assert_usize(self.tcx) { assert!(size <= u32::max_value() as u64, "uniform array move out doesn't supported for array bigger then u32"); @@ -193,7 +193,7 @@ impl MirPass for RestoreSubsliceArrayMoveOut { let opt_size = opt_src_place.and_then(|src_place| { let src_ty = src_place.ty(mir, tcx).to_ty(tcx); if let ty::Array(_, ref size_o) = src_ty.sty { - size_o.assert_usize(tcx) + size_o.unwrap_evaluated().assert_usize(tcx) } else { None } diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 5a2f4be71cc2f..221c2d55eec97 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -809,7 +809,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.complete_drop(Some(DropFlagMode::Deep), succ, unwind) } ty::Array(ety, size) => { - let size = size.assert_usize(self.tcx()); + let size = size.unwrap_evaluated().assert_usize(self.tcx()); self.open_drop_for_array(ety, size) }, ty::Slice(ety) => self.open_drop_for_array(ety, None), @@ -963,7 +963,9 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> span: self.source_info.span, ty: self.tcx().types.usize, user_ty: None, - literal: ty::Const::from_usize(self.tcx(), val.into()), + literal: self.tcx().intern_lazy_const(ty::LazyConst::Evaluated( + ty::Const::from_usize(self.tcx(), val.into()) + )), }) } diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6353eab6f6553..fca208b340d2a 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -399,12 +399,21 @@ impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for ExtraComments<'cx, 'gcx, 'tcx> { self.push(&format!("+ literal: {:?}", literal)); } - fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) { + fn visit_const(&mut self, constant: &&'tcx ty::LazyConst<'tcx>, _: Location) { self.super_const(constant); - let ty::Const { ty, val, .. } = constant; - self.push("ty::Const"); - self.push(&format!("+ ty: {:?}", ty)); - self.push(&format!("+ val: {:?}", val)); + match constant { + ty::LazyConst::Evaluated(constant) => { + let ty::Const { ty, val, .. } = constant; + self.push("ty::Const"); + self.push(&format!("+ ty: {:?}", ty)); + self.push(&format!("+ val: {:?}", val)); + }, + ty::LazyConst::Unevaluated(did, substs) => { + self.push("ty::LazyConst::Unevaluated"); + self.push(&format!("+ did: {:?}", did)); + self.push(&format!("+ substs: {:?}", substs)); + }, + } } fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) { diff --git a/src/librustc_traits/chalk_context/program_clauses.rs b/src/librustc_traits/chalk_context/program_clauses.rs index 98a2f4bf0a15b..71f4945fd648d 100644 --- a/src/librustc_traits/chalk_context/program_clauses.rs +++ b/src/librustc_traits/chalk_context/program_clauses.rs @@ -239,7 +239,7 @@ fn wf_clause_for_slice<'tcx>(tcx: ty::TyCtxt<'_, '_, 'tcx>) -> Clauses<'tcx> { fn wf_clause_for_array<'tcx>( tcx: ty::TyCtxt<'_, '_, 'tcx>, - length: &'tcx ty::Const<'tcx> + length: &'tcx ty::LazyConst<'tcx> ) -> Clauses<'tcx> { let ty = generic_types::bound(tcx, 0); let array_ty = tcx.mk_ty(ty::Array(ty, length)); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 1db7141917f98..e018aa3b26d91 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1772,7 +1772,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o { hir::TyKind::Array(ref ty, ref length) => { let length_def_id = tcx.hir().local_def_id(length.id); let substs = Substs::identity_for_item(tcx, length_def_id); - let length = ty::Const::unevaluated(tcx, length_def_id, substs, tcx.types.usize); + let length = ty::LazyConst::Unevaluated(length_def_id, substs); + let length = tcx.intern_lazy_const(length); let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length)); self.normalize_ty(ast_ty.span, array_ty) } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index b66c383edb51e..13311a2efd5a3 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -377,7 +377,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let expected_ty = self.structurally_resolved_type(pat.span, expected); let (inner_ty, slice_ty) = match expected_ty.sty { ty::Array(inner_ty, size) => { - let size = size.unwrap_usize(tcx); + let size = size.unwrap_evaluated().unwrap_usize(tcx); let min_len = before.len() as u64 + after.len() as u64; if slice.is_none() { if min_len != size { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d78d7273a36e6..d664eed0a3483 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3453,7 +3453,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } ty::Array(_, len) => { if let (Some(len), Ok(user_index)) = ( - len.assert_usize(self.tcx), + len.unwrap_evaluated().assert_usize(self.tcx), field.as_str().parse::() ) { let base = self.tcx.sess.source_map() @@ -4442,7 +4442,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if element_ty.references_error() { tcx.types.err } else if let Ok(count) = count { - tcx.mk_ty(ty::Array(t, count)) + tcx.mk_ty(ty::Array(t, tcx.intern_lazy_const(ty::LazyConst::Evaluated(count)))) } else { tcx.types.err } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 38b2452b420e9..3aa752b35adcf 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -13,7 +13,6 @@ use rustc_data_structures::sync::Lrc; use rustc_target::spec::abi::Abi; use rustc_typeck::hir_ty_to_ty; use rustc::infer::region_constraints::{RegionConstraintData, Constraint}; -use rustc::mir::interpret::ConstValue; use rustc::middle::resolve_lifetime as rl; use rustc::middle::lang_items; use rustc::middle::stability; @@ -2420,10 +2419,10 @@ impl Clean for hir::Ty { instance: ty::Instance::new(def_id, substs), promoted: None }; - let length = cx.tcx.const_eval(param_env.and(cid)).unwrap_or_else(|_| { - ty::Const::unevaluated(cx.tcx, def_id, substs, cx.tcx.types.usize) - }); - let length = print_const(cx, length); + let length = match cx.tcx.const_eval(param_env.and(cid)) { + Ok(length) => print_const(cx, ty::LazyConst::Evaluated(length)), + Err(_) => "_".to_string(), + }; Array(box ty.clean(cx), length) }, TyKind::Tup(ref tys) => Tuple(tys.clean(cx)), @@ -2583,15 +2582,15 @@ impl<'tcx> Clean for Ty<'tcx> { ty::Str => Primitive(PrimitiveType::Str), ty::Slice(ty) => Slice(box ty.clean(cx)), ty::Array(ty, n) => { - let mut n = cx.tcx.lift(&n).expect("array lift failed"); - if let ConstValue::Unevaluated(def_id, substs) = n.val { + let mut n = *cx.tcx.lift(&n).expect("array lift failed"); + if let ty::LazyConst::Unevaluated(def_id, substs) = n { let param_env = cx.tcx.param_env(def_id); let cid = GlobalId { instance: ty::Instance::new(def_id, substs), promoted: None }; if let Ok(new_n) = cx.tcx.const_eval(param_env.and(cid)) { - n = new_n; + n = ty::LazyConst::Evaluated(new_n); } }; let n = print_const(cx, n); @@ -3691,16 +3690,16 @@ fn name_from_pat(p: &hir::Pat) -> String { } } -fn print_const(cx: &DocContext, n: &ty::Const) -> String { - match n.val { - ConstValue::Unevaluated(def_id, _) => { +fn print_const(cx: &DocContext, n: ty::LazyConst) -> String { + match n { + ty::LazyConst::Unevaluated(def_id, _) => { if let Some(node_id) = cx.tcx.hir().as_local_node_id(def_id) { print_const_expr(cx, cx.tcx.hir().body_owned_by(node_id)) } else { inline::print_inlined_const(cx, def_id) } }, - _ => { + ty::LazyConst::Evaluated(n) => { let mut s = String::new(); ::rustc::mir::fmt_const_val(&mut s, n).expect("fmt_const_val failed"); // array lengths are obviously usize From 88df3a2c970a8de576b31ae1ae089f6e99374484 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 12 Dec 2018 09:13:57 +0100 Subject: [PATCH 30/58] Mingw is special wrt type sizes --- src/librustc/ty/sty.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index ba380dfc7c81e..4a254fc1cd9d8 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -2021,7 +2021,7 @@ pub enum LazyConst<'tcx> { Evaluated(&'tcx Const<'tcx>), } -static_assert!(MEM_SIZE_OF_LAZY_CONST: ::std::mem::size_of::>() == 24); +static_assert!(MEM_SIZE_OF_LAZY_CONST: ::std::mem::size_of::>() <= 24); impl<'tcx> LazyConst<'tcx> { pub fn unwrap_evaluated(self) -> &'tcx Const<'tcx> { From 135132891d69dde7ff4a2a6356f9fb92b004c1f7 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Wed, 12 Dec 2018 17:19:11 +0100 Subject: [PATCH 31/58] Simplify and fix some diagnostics around arrays --- src/librustc/traits/error_reporting.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f66dcb8dffda5..bac2251013564 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -418,20 +418,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { Some(format!("[{}]", self.tcx.type_of(def.did).to_string())), )); let tcx = self.tcx; - if let ty::LazyConst::Evaluated(len) = len { - if let Some(len) = len.val.try_to_scalar().and_then(|scalar| { - scalar.to_usize(&tcx).ok() - }) { - flags.push(( - "_Self".to_owned(), - Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), - )); - } else { - flags.push(( - "_Self".to_owned(), - Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())), - )); - } + if let Some(len) = len.assert_usize(tcx) { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), + )); + } else { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())), + )); } } } From f36c6559eabef7ad74818f8f7d952a474c64feaa Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 13 Dec 2018 09:34:23 +0100 Subject: [PATCH 32/58] Add `unwrap_usize` to `LazyConst`, too --- src/librustc/mir/tcx.rs | 2 +- src/librustc/ty/layout.rs | 2 +- src/librustc/ty/sty.rs | 14 ++++++-------- src/librustc_codegen_llvm/debuginfo/metadata.rs | 2 +- src/librustc_codegen_llvm/debuginfo/type_names.rs | 2 +- src/librustc_codegen_ssa/base.rs | 2 +- src/librustc_codegen_ssa/mir/constant.rs | 2 +- src/librustc_codegen_ssa/mir/rvalue.rs | 2 +- .../borrow_check/nll/type_check/mod.rs | 2 +- src/librustc_mir/borrow_check/places_conflict.rs | 2 +- src/librustc_mir/hair/pattern/_match.rs | 6 +++--- src/librustc_mir/hair/pattern/mod.rs | 4 ++-- src/librustc_mir/interpret/cast.rs | 2 +- src/librustc_mir/monomorphize/item.rs | 2 +- src/librustc_mir/shim.rs | 2 +- src/librustc_mir/transform/qualify_consts.rs | 2 +- src/librustc_mir/transform/simplify_branches.rs | 5 ++--- .../transform/uniform_array_move_out.rs | 4 ++-- src/librustc_mir/util/elaborate_drops.rs | 2 +- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- 21 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 6dda1933bbafa..c5b884525da4b 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -114,7 +114,7 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> { PlaceTy::Ty { ty: match ty.sty { ty::Array(inner, size) => { - let size = size.unwrap_evaluated().unwrap_usize(tcx); + let size = size.unwrap_usize(tcx); let len = size - (from as u64) - (to as u64); tcx.mk_array(inner, len) } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 1f25925a8e1d1..171c53b7b20ba 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -543,7 +543,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } let element = self.layout_of(element)?; - let count = count.unwrap_evaluated().unwrap_usize(tcx); + let count = count.unwrap_usize(tcx); let size = element.size.checked_mul(count, dl) .ok_or(LayoutError::SizeOverflow(ty))?; diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 4a254fc1cd9d8..6fd3fbd7376f2 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -2024,13 +2024,6 @@ pub enum LazyConst<'tcx> { static_assert!(MEM_SIZE_OF_LAZY_CONST: ::std::mem::size_of::>() <= 24); impl<'tcx> LazyConst<'tcx> { - pub fn unwrap_evaluated(self) -> &'tcx Const<'tcx> { - match self { - LazyConst::Evaluated(c) => c, - LazyConst::Unevaluated(..) => bug!("unexpected unevaluated constant"), - } - } - pub fn map_evaluated(self, f: impl FnOnce(&'tcx Const<'tcx>) -> Option) -> Option { match self { LazyConst::Evaluated(c) => f(c), @@ -2038,9 +2031,14 @@ impl<'tcx> LazyConst<'tcx> { } } - pub fn assert_usize(self, tcx: TyCtxt<'_, '_, 'tcx>) -> Option { + pub fn assert_usize(self, tcx: TyCtxt<'_, '_, '_>) -> Option { self.map_evaluated(|c| c.assert_usize(tcx)) } + + #[inline] + pub fn unwrap_usize(&self, tcx: TyCtxt<'_, '_, '_>) -> u64 { + self.assert_usize(tcx).expect("expected `LazyConst` to contain a usize") + } } /// Typed constant value. diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index bec0cfa0d862f..0fd04e9d20393 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -302,7 +302,7 @@ fn fixed_vec_metadata( let upper_bound = match array_or_slice_type.sty { ty::Array(_, len) => { - len.unwrap_evaluated().unwrap_usize(cx.tcx) as c_longlong + len.unwrap_usize(cx.tcx) as c_longlong } _ => -1 }; diff --git a/src/librustc_codegen_llvm/debuginfo/type_names.rs b/src/librustc_codegen_llvm/debuginfo/type_names.rs index c1309569c7955..c8cbd735e850d 100644 --- a/src/librustc_codegen_llvm/debuginfo/type_names.rs +++ b/src/librustc_codegen_llvm/debuginfo/type_names.rs @@ -88,7 +88,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ty::Array(inner_type, len) => { output.push('['); push_debuginfo_type_name(cx, inner_type, true, output); - output.push_str(&format!("; {}", len.unwrap_evaluated().unwrap_usize(cx.tcx))); + output.push_str(&format!("; {}", len.unwrap_usize(cx.tcx))); output.push(']'); }, ty::Slice(inner_type) => { diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 166655f6a8061..b88ec075653ba 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -171,7 +171,7 @@ pub fn unsized_info<'tcx, Cx: CodegenMethods<'tcx>>( let (source, target) = cx.tcx().struct_lockstep_tails(source, target); match (&source.sty, &target.sty) { (&ty::Array(_, len), &ty::Slice(_)) => { - cx.const_usize(len.unwrap_evaluated().unwrap_usize(cx.tcx())) + cx.const_usize(len.unwrap_usize(cx.tcx())) } (&ty::Dynamic(..), &ty::Dynamic(..)) => { // For now, upcasts are limited to changes in marker diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 58325e3443266..35bd3a32e8182 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -52,7 +52,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { .and_then(|c| { let field_ty = c.ty.builtin_index().unwrap(); let fields = match c.ty.sty { - ty::Array(_, n) => n.unwrap_evaluated().unwrap_usize(bx.tcx()), + ty::Array(_, n) => n.unwrap_usize(bx.tcx()), ref other => bug!("invalid simd shuffle type: {}", other), }; let values: Result, ErrorHandled> = (0..fields).map(|field| { diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 404ee86c6a117..9ca5414fa717e 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -537,7 +537,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if let mir::Place::Local(index) = *place { if let LocalRef::Operand(Some(op)) = self.locals[index] { if let ty::Array(_, n) = op.layout.ty.sty { - let n = n.unwrap_evaluated().unwrap_usize(bx.cx().tcx()); + let n = n.unwrap_usize(bx.cx().tcx()); return bx.cx().const_usize(n); } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 3681c3d74ebd1..c11eae7edee08 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -568,7 +568,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { ProjectionElem::Subslice { from, to } => PlaceTy::Ty { ty: match base_ty.sty { ty::Array(inner, size) => { - let size = size.unwrap_evaluated().unwrap_usize(tcx); + let size = size.unwrap_usize(tcx); let min_size = (from as u64) + (to as u64); if let Some(rest_size) = size.checked_sub(min_size) { tcx.mk_array(inner, rest_size) diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index 88c27a869c089..ac7182abb36da 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -388,7 +388,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>( (Place::Promoted(p1), Place::Promoted(p2)) => { if p1.0 == p2.0 { if let ty::Array(_, size) = p1.1.sty { - if size.unwrap_evaluated().unwrap_usize(tcx) == 0 { + if size.unwrap_usize(tcx) == 0 { // Ignore conflicts with promoted [T; 0]. debug!("place_element_conflict: IGNORE-LEN-0-PROMOTED"); return Overlap::Disjoint; diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 176c2f6564361..0f5510a2921d7 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -635,7 +635,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, }).collect() } ty::Array(ref sub_ty, len) if len.assert_usize(cx.tcx).is_some() => { - let len = len.unwrap_evaluated().unwrap_usize(cx.tcx); + let len = len.unwrap_usize(cx.tcx); if len != 0 && cx.is_uninhabited(sub_ty) { vec![] } else { @@ -1310,7 +1310,7 @@ fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>, )]), PatternKind::Array { .. } => match pcx.ty.sty { ty::Array(_, length) => Some(vec![ - Slice(length.unwrap_evaluated().unwrap_usize(cx.tcx)) + Slice(length.unwrap_usize(cx.tcx)) ]), _ => span_bug!(pat.span, "bad ty {:?} for array pattern", pcx.ty) }, @@ -1753,7 +1753,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( // slices let (opt_ptr, n, ty) = match value.ty.builtin_deref(false).unwrap().ty.sty { ty::TyKind::Array(t, n) => - (value.to_ptr(), n.unwrap_evaluated().unwrap_usize(cx.tcx), t), + (value.to_ptr(), n.unwrap_usize(cx.tcx), t), ty::TyKind::Slice(t) => { match value.val { ConstValue::ScalarPair(ptr, n) => ( diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index d7eeaf4365102..10d2d7bc1b18b 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -650,7 +650,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { ty::Array(_, len) => { // fixed-length array - let len = len.unwrap_evaluated().unwrap_usize(self.tcx); + let len = len.unwrap_usize(self.tcx); assert!(len >= prefix.len() as u64 + suffix.len() as u64); PatternKind::Array { prefix: prefix, slice: slice, suffix: suffix } } @@ -934,7 +934,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } ty::Array(_, n) => { PatternKind::Array { - prefix: (0..n.unwrap_evaluated().unwrap_usize(self.tcx)) + prefix: (0..n.unwrap_usize(self.tcx)) .map(|i| adt_subpattern(i as usize, None)) .collect(), slice: None, diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 37c5340e0a26c..190a381cf52a5 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -307,7 +307,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // u64 cast is from usize to u64, which is always good let val = Immediate::new_slice( ptr, - length.unwrap_evaluated().unwrap_usize(self.tcx.tcx), + length.unwrap_usize(self.tcx.tcx), self, ); self.write_immediate(val, dest) diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 8cd8eb3ad64c2..e7f4451fdd7ee 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -295,7 +295,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { ty::Array(inner_type, len) => { output.push('['); self.push_type_name(inner_type, output); - write!(output, "; {}", len.unwrap_evaluated().unwrap_usize(self.tcx)).unwrap(); + write!(output, "; {}", len.unwrap_usize(self.tcx)).unwrap(); output.push(']'); }, ty::Slice(inner_type) => { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 835a5dede742f..73e26d6349340 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -318,7 +318,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, match self_ty.sty { _ if is_copy => builder.copy_shim(), ty::Array(ty, len) => { - let len = len.unwrap_evaluated().unwrap_usize(tcx); + let len = len.unwrap_usize(tcx); builder.array_shim(dest, src, ty, len) } ty::Closure(def_id, substs) => { diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 209c26a0c6c46..f35685b7b0c9d 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -712,7 +712,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } else if let ty::Array(_, len) = ty.sty { // FIXME(eddyb) the `self.mode == Mode::Fn` condition // seems unnecessary, given that this is merely a ZST. - let len = len.unwrap_evaluated().unwrap_usize(self.tcx); + let len = len.unwrap_usize(self.tcx); if len == 0 && self.mode == Mode::Fn { forbidden_mut = false; } diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index 1d5bc4f9cc31b..60a569e297d29 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -51,9 +51,8 @@ impl MirPass for SimplifyBranches { }, TerminatorKind::Assert { target, cond: Operand::Constant(ref c), expected, .. - } if (c.literal.unwrap_evaluated().assert_bool(tcx) == Some(true)) == expected => { - TerminatorKind::Goto { target } - }, + } if (c.literal.map_evaluated(|e| e.assert_bool(tcx)) == Some(true)) == expected => + TerminatorKind::Goto { target }, TerminatorKind::FalseEdges { real_target, .. } => { TerminatorKind::Goto { target: real_target } }, diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 172993daa9a1c..5ab9669baaca0 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -71,7 +71,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> { } else { let place_ty = proj.base.ty(self.mir, self.tcx).to_ty(self.tcx); if let ty::Array(item_ty, const_size) = place_ty.sty { - if let Some(size) = const_size.unwrap_evaluated().assert_usize(self.tcx) { + if let Some(size) = const_size.assert_usize(self.tcx) { assert!(size <= u32::max_value() as u64, "uniform array move out doesn't supported for array bigger then u32"); @@ -193,7 +193,7 @@ impl MirPass for RestoreSubsliceArrayMoveOut { let opt_size = opt_src_place.and_then(|src_place| { let src_ty = src_place.ty(mir, tcx).to_ty(tcx); if let ty::Array(_, ref size_o) = src_ty.sty { - size_o.unwrap_evaluated().assert_usize(tcx) + size_o.assert_usize(tcx) } else { None } diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 221c2d55eec97..8b55a4424ae29 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -809,7 +809,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> self.complete_drop(Some(DropFlagMode::Deep), succ, unwind) } ty::Array(ety, size) => { - let size = size.unwrap_evaluated().assert_usize(self.tcx()); + let size = size.assert_usize(self.tcx()); self.open_drop_for_array(ety, size) }, ty::Slice(ety) => self.open_drop_for_array(ety, None), diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 13311a2efd5a3..b66c383edb51e 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -377,7 +377,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let expected_ty = self.structurally_resolved_type(pat.span, expected); let (inner_ty, slice_ty) = match expected_ty.sty { ty::Array(inner_ty, size) => { - let size = size.unwrap_evaluated().unwrap_usize(tcx); + let size = size.unwrap_usize(tcx); let min_len = before.len() as u64 + after.len() as u64; if slice.is_none() { if min_len != size { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d664eed0a3483..4865b70687d84 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3453,7 +3453,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } ty::Array(_, len) => { if let (Some(len), Ok(user_index)) = ( - len.unwrap_evaluated().assert_usize(self.tcx), + len.assert_usize(self.tcx), field.as_str().parse::() ) { let base = self.tcx.sess.source_map() From bb9f717a80814165dcdb4fa3f9d37a6551bcb264 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 13 Dec 2018 10:04:28 +0100 Subject: [PATCH 33/58] `const_to_op` is now `lazy_const_to_op` --- src/librustc_mir/const_eval.rs | 6 +++--- src/librustc_mir/transform/const_prop.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 58a0f13733ea8..2722355b050f9 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -137,7 +137,7 @@ pub fn op_to_const<'tcx>( Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty)) } -pub fn const_to_op<'tcx>( +pub fn lazy_const_to_op<'tcx>( ecx: &CompileTimeEvalContext<'_, '_, 'tcx>, cnst: ty::LazyConst<'tcx>, ty: ty::Ty<'tcx>, @@ -516,7 +516,7 @@ pub fn const_field<'a, 'tcx>( let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); let result = (|| { // get the operand again - let op = const_to_op(&ecx, ty::LazyConst::Evaluated(value), value.ty)?; + let op = lazy_const_to_op(&ecx, ty::LazyConst::Evaluated(value), value.ty)?; // downcast let down = match variant { None => op, @@ -543,7 +543,7 @@ pub fn const_variant_index<'a, 'tcx>( ) -> EvalResult<'tcx, VariantIdx> { trace!("const_variant_index: {:?}, {:?}", instance, val); let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); - let op = const_to_op(&ecx, ty::LazyConst::Evaluated(val), val.ty)?; + let op = lazy_const_to_op(&ecx, ty::LazyConst::Evaluated(val), val.ty)?; Ok(ecx.read_discriminant(op)?.1) } diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index a2a416e54d8ca..2e72f80425d62 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -20,7 +20,7 @@ use rustc::ty::layout::{ use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind}; use const_eval::{ - CompileTimeInterpreter, const_to_op, error_to_const_error, eval_promoted, mk_borrowck_eval_cx + CompileTimeInterpreter, lazy_const_to_op, error_to_const_error, eval_promoted, mk_borrowck_eval_cx }; use transform::{MirPass, MirSource}; @@ -255,7 +255,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> { source_info: SourceInfo, ) -> Option> { self.ecx.tcx.span = source_info.span; - match const_to_op(&self.ecx, *c.literal, c.ty) { + match lazy_const_to_op(&self.ecx, *c.literal, c.ty) { Ok(op) => { Some((op, c.span)) }, From 37a0df3e9db1b934dfb698fc1d7cbf506532004f Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 13 Dec 2018 11:11:12 +0100 Subject: [PATCH 34/58] `<&'tcx ty::Const as Deref>::deref` --- src/librustc/mir/interpret/error.rs | 2 +- src/librustc/mir/mod.rs | 8 ++--- src/librustc/ty/codec.rs | 16 --------- src/librustc/ty/context.rs | 27 ++------------- src/librustc/ty/query/keys.rs | 2 +- src/librustc/ty/structural_impls.rs | 37 +++++++++++++++++--- src/librustc/ty/sty.rs | 39 ++++++++-------------- src/librustc_codegen_ssa/mir/constant.rs | 6 ++-- src/librustc_codegen_ssa/mir/operand.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 4 +-- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/build/misc.rs | 2 +- src/librustc_mir/const_eval.rs | 8 ++--- src/librustc_mir/hair/constant.rs | 4 +-- src/librustc_mir/hair/cx/expr.rs | 3 +- src/librustc_mir/hair/cx/mod.rs | 6 ++-- src/librustc_mir/hair/pattern/_match.rs | 4 +-- src/librustc_mir/hair/pattern/mod.rs | 14 ++++---- src/librustc_mir/monomorphize/collector.rs | 4 +-- src/librustc_mir/shim.rs | 4 +-- 20 files changed, 86 insertions(+), 108 deletions(-) diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 19be0c08ef13b..c3fe5d773ab16 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -37,7 +37,7 @@ impl ErrorHandled { } pub type ConstEvalRawResult<'tcx> = Result, ErrorHandled>; -pub type ConstEvalResult<'tcx> = Result<&'tcx ty::Const<'tcx>, ErrorHandled>; +pub type ConstEvalResult<'tcx> = Result, ErrorHandled>; #[derive(Clone, Debug, RustcEncodable, RustcDecodable)] pub struct ConstEvalErr<'tcx> { diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index eafae6d9c9e8d..a1a6e890b1292 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1666,7 +1666,7 @@ impl<'tcx> TerminatorKind<'tcx> { ), ty: switch_ty, }; - fmt_const_val(&mut s, &c).unwrap(); + fmt_const_val(&mut s, c).unwrap(); s.into() }).chain(iter::once("otherwise".into())) .collect() @@ -2155,7 +2155,7 @@ impl<'tcx> Operand<'tcx> { ty, user_ty: None, literal: tcx.intern_lazy_const( - ty::LazyConst::Evaluated(ty::Const::zero_sized(tcx, ty)), + ty::LazyConst::Evaluated(ty::Const::zero_sized(ty)), ), }) } @@ -2663,14 +2663,14 @@ impl<'tcx> Debug for Constant<'tcx> { /// Write a `ConstValue` in a way closer to the original source code than the `Debug` output. pub fn fmt_lazy_const_val(f: &mut impl Write, const_val: &ty::LazyConst<'_>) -> fmt::Result { - match const_val { + match *const_val { ty::LazyConst::Unevaluated(..) => write!(f, "{:?}", const_val), ty::LazyConst::Evaluated(c) => fmt_const_val(f, c), } } /// Write a `ConstValue` in a way closer to the original source code than the `Debug` output. -pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Result { +pub fn fmt_const_val(f: &mut impl Write, const_val: ty::Const<'_>) -> fmt::Result { use ty::TyKind::*; let value = const_val.val; let ty = const_val.ty; diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 57b99db0c7d54..e0e4d9c362a6c 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -246,15 +246,6 @@ pub fn decode_canonical_var_infos<'a, 'tcx, D>(decoder: &mut D) .intern_canonical_var_infos(interned?.as_slice())) } -#[inline] -pub fn decode_const<'a, 'tcx, D>(decoder: &mut D) - -> Result<&'tcx ty::Const<'tcx>, D::Error> - where D: TyDecoder<'a, 'tcx>, - 'tcx: 'a, -{ - Ok(decoder.tcx().mk_const(Decodable::decode(decoder)?)) -} - #[inline] pub fn decode_lazy_const<'a, 'tcx, D>(decoder: &mut D) -> Result<&'tcx ty::LazyConst<'tcx>, D::Error> @@ -398,13 +389,6 @@ macro_rules! implement_ty_decoder { } } - impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::Const<'tcx>> - for $DecoderName<$($typaram),*> { - fn specialized_decode(&mut self) -> Result<&'tcx ty::Const<'tcx>, Self::Error> { - decode_const(self) - } - } - impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::LazyConst<'tcx>> for $DecoderName<$($typaram),*> { fn specialized_decode(&mut self) -> Result<&'tcx ty::LazyConst<'tcx>, Self::Error> { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 715e7367fada7..108fcc1bd3f21 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -122,7 +122,6 @@ pub struct CtxtInterners<'tcx> { region: InternedSet<'tcx, RegionKind>, existential_predicates: InternedSet<'tcx, List>>, predicates: InternedSet<'tcx, List>>, - const_: InternedSet<'tcx, Const<'tcx>>, clauses: InternedSet<'tcx, List>>, goal: InternedSet<'tcx, GoalKind<'tcx>>, goal_list: InternedSet<'tcx, List>>, @@ -140,7 +139,6 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> { existential_predicates: Default::default(), canonical_var_infos: Default::default(), predicates: Default::default(), - const_: Default::default(), clauses: Default::default(), goal: Default::default(), goal_list: Default::default(), @@ -1071,24 +1069,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - pub fn alloc_const_slice(self, values: &[&'tcx ty::Const<'tcx>]) - -> &'tcx [&'tcx ty::Const<'tcx>] { - if values.is_empty() { - &[] - } else { - self.interners.arena.alloc_slice(values) - } - } - - pub fn alloc_name_const_slice(self, values: &[(ast::Name, &'tcx ty::Const<'tcx>)]) - -> &'tcx [(ast::Name, &'tcx ty::Const<'tcx>)] { - if values.is_empty() { - &[] - } else { - self.interners.arena.alloc_slice(values) - } - } - pub fn intern_const_alloc( self, alloc: Allocation, @@ -1833,9 +1813,9 @@ impl<'a, 'tcx> Lift<'tcx> for &'a LazyConst<'a> { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Const<'a> { - type Lifted = &'tcx Const<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Const<'tcx>> { +impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { + type Lifted = &'tcx mir::interpret::Allocation; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } @@ -2516,7 +2496,6 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool { direct_interners!('tcx, region: mk_region(|r: &RegionKind| r.keep_in_local_tcx()) -> RegionKind, - const_: mk_const(|c: &Const<'_>| keep_local(&c.ty) || keep_local(&c.val)) -> Const<'tcx>, goal: mk_goal(|c: &GoalKind<'_>| keep_local(c)) -> GoalKind<'tcx> ); diff --git a/src/librustc/ty/query/keys.rs b/src/librustc/ty/query/keys.rs index 959a5ff5767a3..af6f5a00dee5c 100644 --- a/src/librustc/ty/query/keys.rs +++ b/src/librustc/ty/query/keys.rs @@ -136,7 +136,7 @@ impl<'tcx> Key for ty::PolyTraitRef<'tcx>{ } } -impl<'tcx> Key for &'tcx ty::Const<'tcx> { +impl<'tcx> Key for ty::Const<'tcx> { fn query_crate(&self) -> CrateNum { LOCAL_CRATE } diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 28184725b1c81..6e599531f25ee 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -53,7 +53,6 @@ CloneTypeFoldableAndLiftImpls! { ::ty::UniverseIndex, ::ty::Variance, ::syntax_pos::Span, - ConstValue<'tcx>, } /////////////////////////////////////////////////////////////////////////// @@ -492,6 +491,26 @@ BraceStructLiftImpl! { } } +BraceStructLiftImpl! { + impl<'a, 'tcx> Lift<'tcx> for ty::Const<'a> { + type Lifted = ty::Const<'tcx>; + val, ty + } +} + +impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> { + type Lifted = ConstValue<'tcx>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + match *self { + ConstValue::Scalar(x) => Some(ConstValue::Scalar(x)), + ConstValue::ScalarPair(x, y) => Some(ConstValue::ScalarPair(x, y)), + ConstValue::ByRef(x, alloc, z) => Some(ConstValue::ByRef( + x, alloc.lift_to_tcx(tcx)?, z, + )), + } + } +} + /////////////////////////////////////////////////////////////////////////// // TypeFoldable implementations. // @@ -1048,17 +1067,27 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::LazyConst<'tcx> { } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for ty::Const<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { let ty = self.ty.fold_with(folder); let val = self.val.fold_with(folder); - folder.tcx().mk_const(ty::Const { + ty::Const { ty, val - }) + } } fn super_visit_with>(&self, visitor: &mut V) -> bool { self.ty.visit_with(visitor) || self.val.visit_with(visitor) } } + +impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> { + fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, _folder: &mut F) -> Self { + *self + } + + fn super_visit_with>(&self, _visitor: &mut V) -> bool { + false + } +} diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 6fd3fbd7376f2..be33911d4849c 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -2018,13 +2018,11 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { /// code is monomorphic enough for that. pub enum LazyConst<'tcx> { Unevaluated(DefId, &'tcx Substs<'tcx>), - Evaluated(&'tcx Const<'tcx>), + Evaluated(Const<'tcx>), } -static_assert!(MEM_SIZE_OF_LAZY_CONST: ::std::mem::size_of::>() <= 24); - impl<'tcx> LazyConst<'tcx> { - pub fn map_evaluated(self, f: impl FnOnce(&'tcx Const<'tcx>) -> Option) -> Option { + pub fn map_evaluated(self, f: impl FnOnce(Const<'tcx>) -> Option) -> Option { match self { LazyConst::Evaluated(c) => f(c), LazyConst::Unevaluated(..) => None, @@ -2050,25 +2048,15 @@ pub struct Const<'tcx> { } impl<'tcx> Const<'tcx> { - #[inline] - pub fn from_const_value( - tcx: TyCtxt<'_, '_, 'tcx>, - val: ConstValue<'tcx>, - ty: Ty<'tcx>, - ) -> &'tcx Self { - tcx.mk_const(Const { - val, - ty, - }) - } - #[inline] pub fn from_scalar( - tcx: TyCtxt<'_, '_, 'tcx>, val: Scalar, ty: Ty<'tcx>, - ) -> &'tcx Self { - Self::from_const_value(tcx, ConstValue::Scalar(val), ty) + ) -> Self { + Self { + val: ConstValue::Scalar(val), + ty, + } } #[inline] @@ -2076,7 +2064,7 @@ impl<'tcx> Const<'tcx> { tcx: TyCtxt<'_, '_, 'tcx>, bits: u128, ty: ParamEnvAnd<'tcx, Ty<'tcx>>, - ) -> &'tcx Self { + ) -> Self { let ty = tcx.lift_to_global(&ty).unwrap(); let size = tcx.layout_of(ty).unwrap_or_else(|e| { panic!("could not compute layout for {:?}: {:?}", ty, e) @@ -2084,21 +2072,21 @@ impl<'tcx> Const<'tcx> { let shift = 128 - size.bits(); let truncated = (bits << shift) >> shift; assert_eq!(truncated, bits, "from_bits called with untruncated value"); - Self::from_scalar(tcx, Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value) + Self::from_scalar(Scalar::Bits { bits, size: size.bytes() as u8 }, ty.value) } #[inline] - pub fn zero_sized(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) -> &'tcx Self { - Self::from_scalar(tcx, Scalar::Bits { bits: 0, size: 0 }, ty) + pub fn zero_sized(ty: Ty<'tcx>) -> Self { + Self::from_scalar(Scalar::Bits { bits: 0, size: 0 }, ty) } #[inline] - pub fn from_bool(tcx: TyCtxt<'_, '_, 'tcx>, v: bool) -> &'tcx Self { + pub fn from_bool(tcx: TyCtxt<'_, '_, 'tcx>, v: bool) -> Self { Self::from_bits(tcx, v as u128, ParamEnv::empty().and(tcx.types.bool)) } #[inline] - pub fn from_usize(tcx: TyCtxt<'_, '_, 'tcx>, n: u64) -> &'tcx Self { + pub fn from_usize(tcx: TyCtxt<'_, '_, 'tcx>, n: u64) -> Self { Self::from_bits(tcx, n as u128, ParamEnv::empty().and(tcx.types.usize)) } @@ -2164,5 +2152,4 @@ impl<'tcx> Const<'tcx> { } } -impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Const<'tcx> {} impl<'tcx> serialize::UseSpecializedDecodable for &'tcx LazyConst<'tcx> {} diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs index 35bd3a32e8182..e6d6ef1d7a38b 100644 --- a/src/librustc_codegen_ssa/mir/constant.rs +++ b/src/librustc_codegen_ssa/mir/constant.rs @@ -15,7 +15,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { &mut self, bx: &Bx, constant: &'tcx ty::LazyConst<'tcx>, - ) -> Result<&'tcx ty::Const<'tcx>, ErrorHandled> { + ) -> Result, ErrorHandled> { match *constant { ty::LazyConst::Unevaluated(def_id, ref substs) => { let tcx = bx.tcx(); @@ -35,7 +35,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { &mut self, bx: &Bx, constant: &mir::Constant<'tcx>, - ) -> Result<&'tcx ty::Const<'tcx>, ErrorHandled> { + ) -> Result, ErrorHandled> { let c = self.monomorphize(&constant.literal); self.fully_evaluate(bx, c) } @@ -46,7 +46,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { bx: &Bx, span: Span, ty: Ty<'tcx>, - constant: Result<&'tcx ty::Const<'tcx>, ErrorHandled>, + constant: Result, ErrorHandled>, ) -> (Bx::Value, Ty<'tcx>) { constant .and_then(|c| { diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index bb55bf3b46cd4..2026e042ef0eb 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -67,7 +67,7 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> { pub fn from_const>( bx: &mut Bx, - val: &'tcx ty::Const<'tcx> + val: ty::Const<'tcx> ) -> Result { let layout = bx.cx().layout_of(val.ty); diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index fe5bc6e19db65..409b6c038ab69 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -658,12 +658,12 @@ enum TestKind<'tcx> { SwitchInt { switch_ty: Ty<'tcx>, options: Vec, - indices: FxHashMap<&'tcx ty::Const<'tcx>, usize>, + indices: FxHashMap, usize>, }, // test for equality Eq { - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, ty: Ty<'tcx>, }, diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index f601e38717f2d..3d960a2dd288a 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -101,7 +101,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { candidate: &Candidate<'pat, 'tcx>, switch_ty: Ty<'tcx>, options: &mut Vec, - indices: &mut FxHashMap<&'tcx ty::Const<'tcx>, usize>) + indices: &mut FxHashMap, usize>) -> bool { let match_pair = match candidate.match_pairs.iter().find(|mp| mp.place == *test_place) { diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index 0689dcfceea25..b4887dada7aeb 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -27,7 +27,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { pub fn literal_operand(&mut self, span: Span, ty: Ty<'tcx>, - literal: &'tcx ty::Const<'tcx>) + literal: ty::Const<'tcx>) -> Operand<'tcx> { let constant = box Constant { span, diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 2722355b050f9..01177e5e49a0e 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -95,7 +95,7 @@ pub fn op_to_const<'tcx>( ecx: &CompileTimeEvalContext<'_, '_, 'tcx>, op: OpTy<'tcx>, may_normalize: bool, -) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> { +) -> EvalResult<'tcx, ty::Const<'tcx>> { // We do not normalize just any data. Only scalar layout and fat pointers. let normalize = may_normalize && match op.layout.abi { @@ -134,7 +134,7 @@ pub fn op_to_const<'tcx>( Ok(Immediate::ScalarPair(a, b)) => ConstValue::ScalarPair(a.not_undef()?, b.not_undef()?), }; - Ok(ty::Const::from_const_value(ecx.tcx.tcx, val, op.layout.ty)) + Ok(ty::Const { val, ty: op.layout.ty }) } pub fn lazy_const_to_op<'tcx>( @@ -510,7 +510,7 @@ pub fn const_field<'a, 'tcx>( instance: ty::Instance<'tcx>, variant: Option, field: mir::Field, - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { trace!("const_field: {:?}, {:?}, {:?}", instance, field, value); let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); @@ -539,7 +539,7 @@ pub fn const_variant_index<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, instance: ty::Instance<'tcx>, - val: &'tcx ty::Const<'tcx>, + val: ty::Const<'tcx>, ) -> EvalResult<'tcx, VariantIdx> { trace!("const_variant_index: {:?}, {:?}", instance, val); let ecx = mk_eval_cx(tcx, instance, param_env).unwrap(); diff --git a/src/librustc_mir/hair/constant.rs b/src/librustc_mir/hair/constant.rs index c98ef31c2bae2..37d741d2606d5 100644 --- a/src/librustc_mir/hair/constant.rs +++ b/src/librustc_mir/hair/constant.rs @@ -14,7 +14,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, ty: Ty<'tcx>, neg: bool, -) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> { +) -> Result, LitToConstError> { use syntax::ast::*; let trunc = |n| { @@ -64,7 +64,7 @@ crate fn lit_to_const<'a, 'gcx, 'tcx>( LitKind::Bool(b) => ConstValue::Scalar(Scalar::from_bool(b)), LitKind::Char(c) => ConstValue::Scalar(Scalar::from_char(c)), }; - Ok(ty::Const::from_const_value(tcx, lit, ty)) + Ok(ty::Const { val: lit, ty }) } fn parse_float<'tcx>( diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index e2d0f6b0ae625..532e6783f2f2b 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -871,7 +871,7 @@ fn method_callee<'a, 'gcx, 'tcx>( span, kind: ExprKind::Literal { literal: cx.tcx().intern_lazy_const(ty::LazyConst::Evaluated( - ty::Const::zero_sized(cx.tcx(), ty) + ty::Const::zero_sized(ty) )), user_ty, }, @@ -933,7 +933,6 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, debug!("convert_path_expr: user_ty={:?}", user_ty); ExprKind::Literal { literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::zero_sized( - cx.tcx, cx.tables().node_id_to_type(expr.hir_id), ))), user_ty, diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index 5681237c14b3e..25c5498b5f1e4 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -134,7 +134,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { ty: Ty<'tcx>, sp: Span, neg: bool, - ) -> &'tcx ty::Const<'tcx> { + ) -> ty::Const<'tcx> { trace!("const_eval_literal: {:#?}, {:?}, {:?}, {:?}", lit, ty, sp, neg); match lit_to_const(lit, self.tcx, ty, neg) { @@ -169,14 +169,14 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { method_name: &str, self_ty: Ty<'tcx>, params: &[Kind<'tcx>]) - -> (Ty<'tcx>, &'tcx ty::Const<'tcx>) { + -> (Ty<'tcx>, ty::Const<'tcx>) { let method_name = Symbol::intern(method_name); let substs = self.tcx.mk_substs_trait(self_ty, params); for item in self.tcx.associated_items(trait_def_id) { if item.kind == ty::AssociatedKind::Method && item.ident.name == method_name { let method_ty = self.tcx.type_of(item.def_id); let method_ty = method_ty.subst(self.tcx, substs); - return (method_ty, ty::Const::zero_sized(self.tcx, method_ty)); + return (method_ty, ty::Const::zero_sized(method_ty)); } } diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 0f5510a2921d7..57b0fb1d8be1e 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -420,7 +420,7 @@ pub enum Constructor<'tcx> { /// Enum variants. Variant(DefId), /// Literal values. - ConstantValue(&'tcx ty::Const<'tcx>), + ConstantValue(ty::Const<'tcx>), /// Ranges of literal values (`2...5` and `2..5`). ConstantRange(u128, u128, Ty<'tcx>, RangeEnd), /// Array patterns of length n. @@ -1787,7 +1787,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( &cx.tcx, ptr, layout.size, ).ok()?; let scalar = scalar.not_undef().ok()?; - let value = ty::Const::from_scalar(cx.tcx, scalar, ty); + let value = ty::Const::from_scalar(scalar, ty); let pattern = Pattern { ty, span: pat.span, diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 10d2d7bc1b18b..f52aeded19ae7 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -123,7 +123,7 @@ pub enum PatternKind<'tcx> { }, Constant { - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, }, Range(PatternRange<'tcx>), @@ -147,8 +147,8 @@ pub enum PatternKind<'tcx> { #[derive(Clone, Copy, Debug, PartialEq)] pub struct PatternRange<'tcx> { - pub lo: &'tcx ty::Const<'tcx>, - pub hi: &'tcx ty::Const<'tcx>, + pub lo: ty::Const<'tcx>, + pub hi: ty::Const<'tcx>, pub ty: Ty<'tcx>, pub end: RangeEnd, } @@ -857,7 +857,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { fn const_to_pat( &self, instance: ty::Instance<'tcx>, - cv: &'tcx ty::Const<'tcx>, + cv: ty::Const<'tcx>, id: hir::HirId, span: Span, ) -> Pattern<'tcx> { @@ -1018,7 +1018,7 @@ macro_rules! CloneImpls { } CloneImpls!{ <'tcx> - Span, Field, Mutability, ast::Name, ast::NodeId, usize, &'tcx ty::Const<'tcx>, + Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>, Region<'tcx>, Ty<'tcx>, BindingMode<'tcx>, &'tcx AdtDef, &'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserTypeAnnotation<'tcx>, UserTypeProjection<'tcx>, PatternTypeProjection<'tcx> @@ -1140,8 +1140,8 @@ impl<'tcx> PatternFoldable<'tcx> for PatternKind<'tcx> { pub fn compare_const_vals<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, - a: &'tcx ty::Const<'tcx>, - b: &'tcx ty::Const<'tcx>, + a: ty::Const<'tcx>, + b: ty::Const<'tcx>, ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, ) -> Option { trace!("compare_const_vals: {:?}, {:?}", a, b); diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 757f94f2076ac..eabfd47c9fb90 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -1252,10 +1252,10 @@ fn collect_lazy_const<'a, 'tcx>( fn collect_const<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, - constant: &ty::Const<'tcx>, + constant: ty::Const<'tcx>, output: &mut Vec>, ) { - debug!("visiting const {:?}", *constant); + debug!("visiting const {:?}", constant); match constant.val { ConstValue::ScalarPair(Scalar::Ptr(a), Scalar::Ptr(b)) => { diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 73e26d6349340..8710a09c209cf 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -460,7 +460,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { ty: func_ty, user_ty: None, literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( - ty::Const::zero_sized(self.tcx, func_ty), + ty::Const::zero_sized(func_ty), )), }); @@ -760,7 +760,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty, user_ty: None, literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated( - ty::Const::zero_sized(tcx, ty) + ty::Const::zero_sized(ty) )), }), vec![rcvr]) From 17db209d4bdf9812fcf2c2afa37ca2d3878a8d48 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 13 Dec 2018 11:15:18 +0100 Subject: [PATCH 35/58] Simplify bit inspection of a constant --- .../transform/simplify_branches.rs | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index 60a569e297d29..abaea70946383 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -1,6 +1,6 @@ //! A pass that simplifies branches when their condition is known. -use rustc::ty::{self, TyCtxt, ParamEnv}; +use rustc::ty::{TyCtxt, ParamEnv}; use rustc::mir::*; use transform::{MirPass, MirSource}; @@ -30,21 +30,17 @@ impl MirPass for SimplifyBranches { discr: Operand::Constant(ref c), switch_ty, ref values, ref targets, .. } => { let switch_ty = ParamEnv::empty().and(switch_ty); - if let ty::LazyConst::Evaluated(c) = c.literal { - let c = c.assert_bits(tcx, switch_ty); - if let Some(constant) = c { - let (otherwise, targets) = targets.split_last().unwrap(); - let mut ret = TerminatorKind::Goto { target: *otherwise }; - for (&v, t) in values.iter().zip(targets.iter()) { - if v == constant { - ret = TerminatorKind::Goto { target: *t }; - break; - } + let constant = c.literal.map_evaluated(|c| c.assert_bits(tcx, switch_ty)); + if let Some(constant) = constant { + let (otherwise, targets) = targets.split_last().unwrap(); + let mut ret = TerminatorKind::Goto { target: *otherwise }; + for (&v, t) in values.iter().zip(targets.iter()) { + if v == constant { + ret = TerminatorKind::Goto { target: *t }; + break; } - ret - } else { - continue } + ret } else { continue } From d96c4a90464b0044c0ed32124133343e72d753ec Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 13 Dec 2018 11:19:34 +0100 Subject: [PATCH 36/58] Undo a few - now unnecessary - changes --- src/librustc_mir/hair/pattern/_match.rs | 3 +-- src/librustc_mir/transform/qualify_consts.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 57b0fb1d8be1e..dc7331a2cd92d 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -1752,8 +1752,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( // they should be pointing to memory is when they are subslices of nonzero // slices let (opt_ptr, n, ty) = match value.ty.builtin_deref(false).unwrap().ty.sty { - ty::TyKind::Array(t, n) => - (value.to_ptr(), n.unwrap_usize(cx.tcx), t), + ty::TyKind::Array(t, n) => (value.to_ptr(), n.unwrap_usize(cx.tcx), t), ty::TyKind::Slice(t) => { match value.val { ConstValue::ScalarPair(ptr, n) => ( diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index f35685b7b0c9d..a04dd5bb5970f 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -712,8 +712,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } else if let ty::Array(_, len) = ty.sty { // FIXME(eddyb) the `self.mode == Mode::Fn` condition // seems unnecessary, given that this is merely a ZST. - let len = len.unwrap_usize(self.tcx); - if len == 0 && self.mode == Mode::Fn { + if len.unwrap_usize(self.tcx) == 0 && self.mode == Mode::Fn { forbidden_mut = false; } } From 089c4039c62caecf0bc58ef0672ab85de26e6186 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 13 Dec 2018 12:20:29 +0100 Subject: [PATCH 37/58] Pacify tidy --- src/librustc_mir/transform/const_prop.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 2e72f80425d62..03d6d3868c9f0 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -20,7 +20,8 @@ use rustc::ty::layout::{ use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind}; use const_eval::{ - CompileTimeInterpreter, lazy_const_to_op, error_to_const_error, eval_promoted, mk_borrowck_eval_cx + CompileTimeInterpreter, error_to_const_error, eval_promoted, mk_borrowck_eval_cx, + lazy_const_to_op, }; use transform::{MirPass, MirSource}; From cb933eff350d9ebf81ee31511f54c99e99ab509f Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sat, 15 Dec 2018 11:29:52 +0100 Subject: [PATCH 38/58] rebase fallout --- src/librustc/ty/context.rs | 7 +---- src/librustc_mir/build/matches/test.rs | 8 +++--- src/librustc_mir/hair/pattern/_match.rs | 34 +++++++++++++++++-------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 108fcc1bd3f21..dfeab9715cc01 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1745,12 +1745,7 @@ impl<'a, 'tcx> Lift<'tcx> for Goal<'a> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } + Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self))) } } diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 3d960a2dd288a..aae3de68aaae0 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -658,7 +658,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { } } - (&TestKind::Range(range), &PatternKind::Constant { ref value }) => { + (&TestKind::Range(range), &PatternKind::Constant { value }) => { if self.const_range_contains(range, value) == Some(false) { // `value` is not contained in the testing range, // so `value` can be matched only if this test fails. @@ -787,7 +787,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { fn const_range_contains( &self, range: PatternRange<'tcx>, - value: &'tcx ty::Const<'tcx>, + value: ty::Const<'tcx>, ) -> Option { use std::cmp::Ordering::*; @@ -807,9 +807,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { fn values_not_contained_in_range( &self, range: PatternRange<'tcx>, - indices: &FxHashMap<&'tcx ty::Const<'tcx>, usize>, + indices: &FxHashMap, usize>, ) -> Option { - for val in indices.keys() { + for &val in indices.keys() { if self.const_range_contains(range, val)? { return Some(false); } diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index dc7331a2cd92d..b25d47b390175 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -223,7 +223,7 @@ impl<'a, 'tcx> LiteralExpander<'a, 'tcx> { assert_eq!(t, u); ConstValue::ScalarPair( Scalar::Ptr(p), - n.val.try_to_scalar().unwrap(), + n.map_evaluated(|val| val.val.try_to_scalar()).unwrap(), ) }, // fat pointers stay the same @@ -251,11 +251,10 @@ impl<'a, 'tcx> PatternFolder<'tcx> for LiteralExpander<'a, 'tcx> { subpattern: Pattern { ty: rty, span: pat.span, - kind: box PatternKind::Constant { value: Const::from_const_value( - self.tcx, - self.fold_const_value_deref(*val, rty, crty), - rty, - ) }, + kind: box PatternKind::Constant { value: Const { + val: self.fold_const_value_deref(val, rty, crty), + ty: rty, + } }, } } } @@ -1396,7 +1395,7 @@ fn constructor_sub_pattern_tys<'a, 'tcx: 'a>(cx: &MatchCheckCtxt<'a, 'tcx>, fn slice_pat_covered_by_const<'tcx>( tcx: TyCtxt<'_, 'tcx, '_>, _span: Span, - const_val: &ty::Const<'tcx>, + const_val: ty::Const<'tcx>, prefix: &[Pattern<'tcx>], slice: &Option>, suffix: &[Pattern<'tcx>] @@ -1751,12 +1750,27 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>( // necessarily point to memory, they are usually just integers. The only time // they should be pointing to memory is when they are subslices of nonzero // slices - let (opt_ptr, n, ty) = match value.ty.builtin_deref(false).unwrap().ty.sty { - ty::TyKind::Array(t, n) => (value.to_ptr(), n.unwrap_usize(cx.tcx), t), + let (opt_ptr, n, ty) = match value.ty.sty { + ty::TyKind::Array(t, n) => { + match value.val { + ConstValue::ByRef(id, alloc, offset) => ( + Some((Pointer::new(id, offset), alloc)), + n.unwrap_usize(cx.tcx), + t, + ), + _ => span_bug!( + pat.span, + "array pattern is {:?}", value, + ), + } + }, ty::TyKind::Slice(t) => { match value.val { ConstValue::ScalarPair(ptr, n) => ( - ptr.to_ptr().ok(), + ptr.to_ptr().ok().map(|ptr| ( + ptr, + cx.tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id), + )), n.to_bits(cx.tcx.data_layout.pointer_size).unwrap() as u64, t, ), From 3d924a6252ee65c1cfe518c9cdc63870e3e62eed Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Sun, 23 Dec 2018 14:08:04 +0100 Subject: [PATCH 39/58] Git is drunk --- src/librustc/ty/context.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index dfeab9715cc01..ce9be4e84054a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1730,12 +1730,7 @@ impl<'a, 'tcx> Lift<'tcx> for Region<'a> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } + Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self))) } } @@ -1745,7 +1740,12 @@ impl<'a, 'tcx> Lift<'tcx> for Goal<'a> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } - Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self))) + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } } } From 48aa81911ceafbddfe1db90ec287aafa31047576 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 27 Dec 2018 15:21:47 +0100 Subject: [PATCH 40/58] what is going on? --- src/librustc/ty/context.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index ce9be4e84054a..dfeab9715cc01 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1730,7 +1730,12 @@ impl<'a, 'tcx> Lift<'tcx> for Region<'a> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } - Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self))) + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } } } @@ -1740,12 +1745,7 @@ impl<'a, 'tcx> Lift<'tcx> for Goal<'a> { if tcx.interners.arena.in_arena(*self as *const _) { return Some(unsafe { mem::transmute(*self) }); } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } + Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self))) } } From e42b21b522033dfd3a2807e20e789a94830ec346 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 28 Dec 2018 12:55:26 +0100 Subject: [PATCH 41/58] Properly lift `Allocations` --- src/librustc/ty/context.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index dfeab9715cc01..8ecaa42a2e91d 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1811,15 +1811,8 @@ impl<'a, 'tcx> Lift<'tcx> for &'a LazyConst<'a> { impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { type Lifted = &'tcx mir::interpret::Allocation; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } + assert!(tcx.global_interners.arena.in_arena(*self as *const _)); + Some(unsafe { mem::transmute(*self) }) } } From 72bcf92e124106e0bcf5155d0b610c6b2d848764 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 28 Dec 2018 20:30:06 +0100 Subject: [PATCH 42/58] Macrofy more `Lift` impls --- src/librustc/ty/context.rs | 248 +++++++------------------------------ 1 file changed, 48 insertions(+), 200 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 8ecaa42a2e91d..26f0ff0ffa265 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1709,104 +1709,63 @@ pub trait Lift<'tcx>: fmt::Debug { fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option; } -impl<'a, 'tcx> Lift<'tcx> for Ty<'a> { - type Lifted = Ty<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} -impl<'a, 'tcx> Lift<'tcx> for Region<'a> { - type Lifted = Region<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for Goal<'a> { - type Lifted = Goal<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); +macro_rules! nop_lift { + ($ty:ty => $lifted:ty) => { + impl<'a, 'tcx> Lift<'tcx> for $ty { + type Lifted = $lifted; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + if tcx.interners.arena.in_arena(*self as *const _) { + return Some(unsafe { mem::transmute(*self) }); + } + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } + } } - Some(tcx.intern_const_alloc(mir::interpret::Allocation::clone(self))) - } + }; } -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>( - &self, - tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } - - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None +macro_rules! nop_list_lift { + ($ty:ty => $lifted:ty) => { + impl<'a, 'tcx> Lift<'tcx> for &'a List<$ty> { + type Lifted = &'tcx List<$lifted>; + fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { + if self.is_empty() { + return Some(List::empty()); + } + if tcx.interners.arena.in_arena(*self as *const _) { + return Some(unsafe { mem::transmute(*self) }); + } + // Also try in the global tcx if we're not that. + if !tcx.is_global() { + self.lift_to_tcx(tcx.global_tcx()) + } else { + None + } + } } - } + }; } -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>( - &self, - tcx: TyCtxt<'b, 'gcx, 'tcx>, - ) -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } +nop_lift!{Ty<'a> => Ty<'tcx>} +nop_lift!{Region<'a> => Region<'tcx>} +nop_lift!{Goal<'a> => Goal<'tcx>} +nop_lift!{&'a LazyConst<'a> => &'tcx LazyConst<'tcx>} - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} +nop_list_lift!{Goal<'a> => Goal<'tcx>} +nop_list_lift!{Clause<'a> => Clause<'tcx>} +nop_list_lift!{Ty<'a> => Ty<'tcx>} +nop_list_lift!{ExistentialPredicate<'a> => ExistentialPredicate<'tcx>} +nop_list_lift!{Predicate<'a> => Predicate<'tcx>} +nop_list_lift!{CanonicalVarInfo => CanonicalVarInfo} +nop_list_lift!{ProjectionKind<'a> => ProjectionKind<'tcx>} -impl<'a, 'tcx> Lift<'tcx> for &'a LazyConst<'a> { - type Lifted = &'tcx LazyConst<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx LazyConst<'tcx>> { - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} +// this is the impl for `&'a Substs<'a>` +nop_list_lift!{Kind<'a> => Kind<'tcx>} impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { type Lifted = &'tcx mir::interpret::Allocation; @@ -1816,117 +1775,6 @@ impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { } } -impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { - type Lifted = &'tcx Substs<'tcx>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<&'tcx Substs<'tcx>> { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(&self[..] as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx List>> { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) - -> Option<&'tcx List>> { - if self.is_empty() { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List { - type Lifted = &'tcx List; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - -impl<'a, 'tcx> Lift<'tcx> for &'a List> { - type Lifted = &'tcx List>; - fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - if self.len() == 0 { - return Some(List::empty()); - } - if tcx.interners.arena.in_arena(*self as *const _) { - return Some(unsafe { mem::transmute(*self) }); - } - // Also try in the global tcx if we're not that. - if !tcx.is_global() { - self.lift_to_tcx(tcx.global_tcx()) - } else { - None - } - } -} - pub mod tls { use super::{GlobalCtxt, TyCtxt}; From 9654ae9c9973253e0e87bff9fd8f79be87492c64 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 28 Dec 2018 20:45:51 +0100 Subject: [PATCH 43/58] Remove unused function --- src/librustc/ty/context.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 26f0ff0ffa265..74fa5363fb2f6 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1061,14 +1061,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.global_arenas.adt_def.alloc(def) } - pub fn alloc_byte_array(self, bytes: &[u8]) -> &'gcx [u8] { - if bytes.is_empty() { - &[] - } else { - self.global_interners.arena.alloc_slice(bytes) - } - } - pub fn intern_const_alloc( self, alloc: Allocation, From 03b892860da5aff7a10cf4ca1364dbcacb95bfcd Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 28 Dec 2018 21:09:47 +0100 Subject: [PATCH 44/58] Check the correct arena --- src/libarena/lib.rs | 5 +++++ src/librustc/ty/context.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index b40e905620de9..9f9ded51e37ee 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -119,6 +119,11 @@ impl Default for TypedArena { } impl TypedArena { + pub fn in_arena(&self, ptr: *const T) -> bool { + let ptr = ptr as *const T as *mut T; + + self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end()) + } /// Allocates an object in the `TypedArena`, returning a reference to it. #[inline] pub fn alloc(&self, object: T) -> &mut T { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 74fa5363fb2f6..6c377941dad19 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1762,7 +1762,7 @@ nop_list_lift!{Kind<'a> => Kind<'tcx>} impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation { type Lifted = &'tcx mir::interpret::Allocation; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - assert!(tcx.global_interners.arena.in_arena(*self as *const _)); + assert!(tcx.global_arenas.const_allocs.in_arena(*self as *const _)); Some(unsafe { mem::transmute(*self) }) } } From 185636e8b059aac9bf559f8d96bb314ba4baf1c4 Mon Sep 17 00:00:00 2001 From: king6cong Date: Wed, 2 Jan 2019 15:18:13 +0800 Subject: [PATCH 45/58] Update reference of rlibc crate to compiler-builtins crate --- src/libcore/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 5ea765d3585a2..80472ab388861 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -24,7 +24,7 @@ //! often generated by LLVM. Additionally, this library can make explicit //! calls to these functions. Their signatures are the same as found in C. //! These functions are often provided by the system libc, but can also be -//! provided by the [rlibc crate](https://crates.io/crates/rlibc). +//! provided by the [compiler-builtins crate](https://crates.io/crates/compiler_builtins). //! //! * `rust_begin_panic` - This function takes four arguments, a //! `fmt::Arguments`, a `&'static str`, and two `u32`'s. These four arguments From 0fd5003b38457cdb476ad4d3d3faf9f210c1f2df Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 2 Jan 2019 16:07:42 +0100 Subject: [PATCH 46/58] src/jemalloc is gone, remove its mention from COPYRIGHT --- COPYRIGHT | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/COPYRIGHT b/COPYRIGHT index e2d0ed77224e3..6596c5a3d9aff 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -229,35 +229,3 @@ their own copyright notices and license terms: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -* jemalloc, under src/jemalloc: - - Copyright (C) 2002-2014 Jason Evans - . All rights reserved. - Copyright (C) 2007-2012 Mozilla Foundation. - All rights reserved. - Copyright (C) 2009-2014 Facebook, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice(s), - this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice(s), - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) - BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY - OF SUCH DAMAGE. From 2a02d6d714c95f59cfbc4ac9ab3e6d82022515b0 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 2 Jan 2019 17:14:24 +0300 Subject: [PATCH 47/58] Make sure feature gate errors are recoverable (take 2) --- src/librustc/ty/mod.rs | 4 +- src/librustc_driver/driver.rs | 23 +++++----- .../cfg-attr-crate-2.rs | 8 ++-- .../cfg-attr-multi-invalid-1.rs | 4 +- .../cfg-attr-multi-invalid-2.rs | 4 +- .../feature-gate-alloc-error-handler.rs | 3 ++ .../feature-gates/feature-gate-allow_fail.rs | 1 + .../feature-gate-async-await-2015-edition.rs | 2 +- ...ature-gate-async-await-2015-edition.stderr | 2 +- .../ui/feature-gates/feature-gate-const_fn.rs | 10 +++-- .../feature-gate-const_fn.stderr | 2 +- .../feature-gates/feature-gate-doc_keyword.rs | 2 + .../feature-gates/feature-gate-dropck-ugeh.rs | 5 +-- .../feature-gate-dropck-ugeh.stderr | 10 ++++- .../feature-gate-existential-type.rs | 6 ++- .../feature-gate-existential-type.stderr | 4 +- .../feature-gates/feature-gate-generators.rs | 1 + .../feature-gate-generators.stderr | 11 ++++- .../feature-gate-generic_associated_types.rs | 4 +- ...ature-gate-generic_associated_types.stderr | 4 +- .../feature-gates/feature-gate-intrinsics.rs | 8 ++-- .../feature-gate-intrinsics.stderr | 18 +++++--- .../feature-gates/feature-gate-lang-items.rs | 6 +-- .../feature-gate-lang-items.stderr | 15 +++++-- .../ui/feature-gates/feature-gate-linkage.rs | 2 + .../feature-gates/feature-gate-may-dangle.rs | 4 +- .../feature-gate-may-dangle.stderr | 6 +-- .../feature-gate-min_const_fn.rs | 10 +++-- .../feature-gate-min_const_fn.stderr | 2 +- .../feature-gate-naked_functions.rs | 2 + .../feature-gates/feature-gate-never_type.rs | 4 +- .../feature-gate-never_type.stderr | 12 +++--- .../ui/feature-gates/feature-gate-no_core.rs | 4 +- .../feature-gates/feature-gate-no_core.stderr | 2 +- .../feature-gate-optin-builtin-traits.rs | 6 +-- .../feature-gate-optin-builtin-traits.stderr | 8 ++-- .../feature-gates/feature-gate-repr-simd.rs | 2 +- .../feature-gate-repr-simd.stderr | 11 ++++- .../feature-gate-rustc-attrs-1.rs | 2 +- .../feature-gate-rustc-attrs-1.stderr | 11 ++++- .../ui/feature-gates/feature-gate-start.rs | 3 +- .../feature-gates/feature-gate-start.stderr | 4 +- .../feature-gate-thread_local.rs | 6 +-- ...ture-gate-unboxed-closures-manual-impls.rs | 6 ++- ...-gate-unboxed-closures-manual-impls.stderr | 43 ++++++++++++++++--- .../feature-gate-unboxed-closures.rs | 3 ++ .../feature-gate-unboxed-closures.stderr | 12 +++++- src/test/ui/issues/issue-51279.rs | 4 +- src/test/ui/issues/issue-51279.stderr | 6 +-- .../expected-comma-found-token.rs | 5 +-- .../expected-comma-found-token.stderr | 16 ++++++- src/test/ui/span/gated-features-attr-spans.rs | 6 +-- src/test/ui/utf8_idents.rs | 1 + src/test/ui/utf8_idents.stderr | 12 +++++- 54 files changed, 244 insertions(+), 128 deletions(-) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index d40dd830e9fb9..8768d3c5034e8 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2801,7 +2801,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.impl_polarity(def_id1) == self.impl_polarity(def_id2) && trait1_is_empty && trait2_is_empty - } else if self.features().marker_trait_attr { + } else { let is_marker_impl = |def_id: DefId| -> bool { let trait_ref = self.impl_trait_ref(def_id); trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker) @@ -2809,8 +2809,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.impl_polarity(def_id1) == self.impl_polarity(def_id2) && is_marker_impl(def_id1) && is_marker_impl(def_id2) - } else { - false } } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 9b232edc11d4a..9bb5747665600 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -1101,23 +1101,20 @@ where ast_validation::check_crate(sess, &krate) }); - time(sess, "name resolution", || -> CompileResult { + time(sess, "name resolution", || { resolver.resolve_crate(&krate); - Ok(()) - })?; + }); // Needs to go *after* expansion to be able to check the results of macro expansion. time(sess, "complete gated feature checking", || { - sess.track_errors(|| { - syntax::feature_gate::check_crate( - &krate, - &sess.parse_sess, - &sess.features_untracked(), - &attributes, - sess.opts.unstable_features, - ); - }) - })?; + syntax::feature_gate::check_crate( + &krate, + &sess.parse_sess, + &sess.features_untracked(), + &attributes, + sess.opts.unstable_features, + ); + }); // Lower ast -> hir. // First, we need to collect the dep_graph. diff --git a/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs b/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs index 9345229704a67..0dceba28b6ec3 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-crate-2.rs @@ -1,8 +1,8 @@ -// -// compile-flags: --cfg broken - // https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044 +// compile-flags: --cfg broken + +#![crate_type = "lib"] #![cfg_attr(broken, no_core)] //~ ERROR no_core is experimental -fn main() { } +pub struct S {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs index 0638f481ae569..16813a7623c77 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-1.rs @@ -1,7 +1,7 @@ -// // compile-flags: --cfg broken #![feature(cfg_attr_multi)] +#![crate_type = "lib"] #![cfg_attr(broken, no_core, no_std)] //~ ERROR no_core is experimental -fn main() { } +pub struct S {} diff --git a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs index 26b4936ac70b2..39f8fc4b8b9f1 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs +++ b/src/test/ui/conditional-compilation/cfg-attr-multi-invalid-2.rs @@ -1,7 +1,7 @@ -// // compile-flags: --cfg broken #![feature(cfg_attr_multi)] +#![crate_type = "lib"] #![cfg_attr(broken, no_std, no_core)] //~ ERROR no_core is experimental -fn main() { } +pub struct S {} diff --git a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs index fbd9291afbe03..daa2bb5d6fafc 100644 --- a/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs +++ b/src/test/ui/feature-gates/feature-gate-alloc-error-handler.rs @@ -9,3 +9,6 @@ use core::alloc::Layout; fn oom(info: Layout) -> ! { loop {} } + +#[panic_handler] +fn panic(_: &core::panic::PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/feature-gates/feature-gate-allow_fail.rs b/src/test/ui/feature-gates/feature-gate-allow_fail.rs index cd8b096294261..f9ad48551410c 100644 --- a/src/test/ui/feature-gates/feature-gate-allow_fail.rs +++ b/src/test/ui/feature-gates/feature-gate-allow_fail.rs @@ -5,3 +5,4 @@ fn ok_to_fail() { assert!(false); } +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs index 00a3103af2cbc..84dd1b9f814c2 100644 --- a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs +++ b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs @@ -6,5 +6,5 @@ async fn foo() {} //~ ERROR async fn is unstable fn main() { let _ = async {}; //~ ERROR cannot find struct, variant or union type `async` - let _ = async || {}; //~ ERROR cannot find value `async` in this scope + let _ = async || { true }; //~ ERROR cannot find value `async` in this scope } diff --git a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr index 7754dbb3b3736..450b2c42f119d 100644 --- a/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr +++ b/src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr @@ -7,7 +7,7 @@ LL | let _ = async {}; //~ ERROR cannot find struct, variant or union type ` error[E0425]: cannot find value `async` in this scope --> $DIR/feature-gate-async-await-2015-edition.rs:9:13 | -LL | let _ = async || {}; //~ ERROR cannot find value `async` in this scope +LL | let _ = async || { true }; //~ ERROR cannot find value `async` in this scope | ^^^^^ not found in this scope error[E0658]: async fn is unstable (see issue #50547) diff --git a/src/test/ui/feature-gates/feature-gate-const_fn.rs b/src/test/ui/feature-gates/feature-gate-const_fn.rs index 5a0a5ac9edc6c..f46d1dc13d3f0 100644 --- a/src/test/ui/feature-gates/feature-gate-const_fn.rs +++ b/src/test/ui/feature-gates/feature-gate-const_fn.rs @@ -9,14 +9,16 @@ trait Foo { //~| ERROR trait fns cannot be declared const } -impl Foo { - const fn baz() -> u32 { 0 } // ok -} - impl Foo for u32 { const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const } +trait Bar {} + +impl dyn Bar { + const fn baz() -> u32 { 0 } // ok +} + static FOO: usize = foo(); const BAR: usize = foo(); diff --git a/src/test/ui/feature-gates/feature-gate-const_fn.stderr b/src/test/ui/feature-gates/feature-gate-const_fn.stderr index 32a57719edbe5..b3fc587b1cf77 100644 --- a/src/test/ui/feature-gates/feature-gate-const_fn.stderr +++ b/src/test/ui/feature-gates/feature-gate-const_fn.stderr @@ -11,7 +11,7 @@ LL | const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable | ^^^^^ trait fns cannot be const error[E0379]: trait fns cannot be declared const - --> $DIR/feature-gate-const_fn.rs:17:5 + --> $DIR/feature-gate-const_fn.rs:13:5 | LL | const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const | ^^^^^ trait fns cannot be const diff --git a/src/test/ui/feature-gates/feature-gate-doc_keyword.rs b/src/test/ui/feature-gates/feature-gate-doc_keyword.rs index f417828db15ad..b08940e28f443 100644 --- a/src/test/ui/feature-gates/feature-gate-doc_keyword.rs +++ b/src/test/ui/feature-gates/feature-gate-doc_keyword.rs @@ -1,3 +1,5 @@ #[doc(keyword = "match")] //~ ERROR: #[doc(keyword = "...")] is experimental /// wonderful mod foo{} + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs index 02aa5000661d3..a2377cda9bd66 100644 --- a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs +++ b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.rs @@ -1,14 +1,11 @@ // gate-test-dropck_parametricity // Ensure that attempts to use the unsafe attribute are feature-gated. - // Example adapted from RFC 1238 text (just left out the feature gate). // https://github.com/rust-lang/rfcs/blob/master/text/1238-nonparametric-dropck.md // #example-of-the-unguarded-escape-hatch -// #![feature(dropck_parametricity)] - use std::cell::Cell; struct Concrete<'a>(u32, Cell>>); @@ -18,6 +15,7 @@ struct Foo { data: Vec } impl Drop for Foo { #[unsafe_destructor_blind_to_params] // This is the UGEH attribute //~^ ERROR unsafe_destructor_blind_to_params has been replaced + //~| WARN use of deprecated attribute `dropck_parametricity` fn drop(&mut self) { } } @@ -29,4 +27,3 @@ fn main() { foo.data[0].1.set(Some(&foo.data[1])); foo.data[1].1.set(Some(&foo.data[0])); } - diff --git a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr index 99ca454bcabab..bc62fc01b4438 100644 --- a/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr +++ b/src/test/ui/feature-gates/feature-gate-dropck-ugeh.stderr @@ -1,11 +1,19 @@ error[E0658]: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future (see issue #28498) - --> $DIR/feature-gate-dropck-ugeh.rs:19:5 + --> $DIR/feature-gate-dropck-ugeh.rs:16:5 | LL | #[unsafe_destructor_blind_to_params] // This is the UGEH attribute | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(dropck_parametricity)] to the crate attributes to enable +warning: use of deprecated attribute `dropck_parametricity`: unsafe_destructor_blind_to_params has been replaced by may_dangle and will be removed in the future. See https://github.com/rust-lang/rust/issues/34761 + --> $DIR/feature-gate-dropck-ugeh.rs:16:5 + | +LL | #[unsafe_destructor_blind_to_params] // This is the UGEH attribute + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace this attribute with `#[may_dangle]` + | + = note: #[warn(deprecated)] on by default + error: aborting due to previous error For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-existential-type.rs b/src/test/ui/feature-gates/feature-gate-existential-type.rs index e14467d6c3eb5..6dfd2d10870e0 100644 --- a/src/test/ui/feature-gates/feature-gate-existential-type.rs +++ b/src/test/ui/feature-gates/feature-gate-existential-type.rs @@ -1,15 +1,17 @@ // Check that existential types must be ungated to use the `existential` keyword - - existential type Foo: std::fmt::Debug; //~ ERROR existential types are unstable trait Bar { type Baa: std::fmt::Debug; + fn define() -> Self::Baa; } impl Bar for () { existential type Baa: std::fmt::Debug; //~ ERROR existential types are unstable + fn define() -> Self::Baa { 0 } } +fn define() -> Foo { 0 } + fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-existential-type.stderr b/src/test/ui/feature-gates/feature-gate-existential-type.stderr index e88bdc01fdc19..e83d5cdbde1e6 100644 --- a/src/test/ui/feature-gates/feature-gate-existential-type.stderr +++ b/src/test/ui/feature-gates/feature-gate-existential-type.stderr @@ -1,5 +1,5 @@ error[E0658]: existential types are unstable (see issue #34511) - --> $DIR/feature-gate-existential-type.rs:5:1 + --> $DIR/feature-gate-existential-type.rs:3:1 | LL | existential type Foo: std::fmt::Debug; //~ ERROR existential types are unstable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | existential type Foo: std::fmt::Debug; //~ ERROR existential types are unst = help: add #![feature(existential_type)] to the crate attributes to enable error[E0658]: existential types are unstable (see issue #34511) - --> $DIR/feature-gate-existential-type.rs:12:5 + --> $DIR/feature-gate-existential-type.rs:11:5 | LL | existential type Baa: std::fmt::Debug; //~ ERROR existential types are unstable | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-generators.rs b/src/test/ui/feature-gates/feature-gate-generators.rs index 88e8781d2b9ba..cee930fd785b9 100644 --- a/src/test/ui/feature-gates/feature-gate-generators.rs +++ b/src/test/ui/feature-gates/feature-gate-generators.rs @@ -1,3 +1,4 @@ fn main() { yield true; //~ ERROR yield syntax is experimental + //~^ ERROR yield statement outside of generator literal } diff --git a/src/test/ui/feature-gates/feature-gate-generators.stderr b/src/test/ui/feature-gates/feature-gate-generators.stderr index 4b90cd1c1f8e4..aea1e00d698a6 100644 --- a/src/test/ui/feature-gates/feature-gate-generators.stderr +++ b/src/test/ui/feature-gates/feature-gate-generators.stderr @@ -6,6 +6,13 @@ LL | yield true; //~ ERROR yield syntax is experimental | = help: add #![feature(generators)] to the crate attributes to enable -error: aborting due to previous error +error[E0627]: yield statement outside of generator literal + --> $DIR/feature-gate-generators.rs:2:5 + | +LL | yield true; //~ ERROR yield syntax is experimental + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0627, E0658. +For more information about an error, try `rustc --explain E0627`. diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs index 86a1f5ca4d5d5..17548d7b9e88c 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.rs @@ -11,9 +11,9 @@ trait PointerFamily { struct Foo; impl PointerFamily for Foo { - type Pointer = Box; + type Pointer = Box; //~^ ERROR generic associated types are unstable - type Pointer2 = Box; + type Pointer2 = Box; //~^ ERROR generic associated types are unstable } diff --git a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr index 392d0f1bd7e15..8a207c966cdab 100644 --- a/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr +++ b/src/test/ui/feature-gates/feature-gate-generic_associated_types.stderr @@ -25,7 +25,7 @@ LL | type Pointer2: Deref where T: Clone, U: Clone; error[E0658]: generic associated types are unstable (see issue #44265) --> $DIR/feature-gate-generic_associated_types.rs:14:5 | -LL | type Pointer = Box; +LL | type Pointer = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(generic_associated_types)] to the crate attributes to enable @@ -33,7 +33,7 @@ LL | type Pointer = Box; error[E0658]: generic associated types are unstable (see issue #44265) --> $DIR/feature-gate-generic_associated_types.rs:16:5 | -LL | type Pointer2 = Box; +LL | type Pointer2 = Box; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(generic_associated_types)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-intrinsics.rs b/src/test/ui/feature-gates/feature-gate-intrinsics.rs index 0916d7fcd36d3..d1da94338283b 100644 --- a/src/test/ui/feature-gates/feature-gate-intrinsics.rs +++ b/src/test/ui/feature-gates/feature-gate-intrinsics.rs @@ -1,9 +1,7 @@ extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change - fn bar(); + fn bar(); //~ ERROR unrecognized intrinsic function: `bar` } -extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change -} +extern "rust-intrinsic" fn baz() {} //~ ERROR intrinsics are subject to change -fn main() { -} +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-intrinsics.stderr b/src/test/ui/feature-gates/feature-gate-intrinsics.stderr index 034e2b1b588b5..092cb98a2f963 100644 --- a/src/test/ui/feature-gates/feature-gate-intrinsics.stderr +++ b/src/test/ui/feature-gates/feature-gate-intrinsics.stderr @@ -2,7 +2,7 @@ error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:1:1 | LL | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change -LL | | fn bar(); +LL | | fn bar(); //~ ERROR unrecognized intrinsic function: `bar` LL | | } | |_^ | @@ -11,12 +11,18 @@ LL | | } error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:5:1 | -LL | / extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change -LL | | } - | |_^ +LL | extern "rust-intrinsic" fn baz() {} //~ ERROR intrinsics are subject to change + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(intrinsics)] to the crate attributes to enable -error: aborting due to 2 previous errors +error[E0093]: unrecognized intrinsic function: `bar` + --> $DIR/feature-gate-intrinsics.rs:2:5 + | +LL | fn bar(); //~ ERROR unrecognized intrinsic function: `bar` + | ^^^^^^^^^ unrecognized intrinsic + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0093, E0658. +For more information about an error, try `rustc --explain E0093`. diff --git a/src/test/ui/feature-gates/feature-gate-lang-items.rs b/src/test/ui/feature-gates/feature-gate-lang-items.rs index 943ca161d678d..93262f2171bfe 100644 --- a/src/test/ui/feature-gates/feature-gate-lang-items.rs +++ b/src/test/ui/feature-gates/feature-gate-lang-items.rs @@ -1,5 +1,5 @@ -#[lang="foo"] //~ ERROR language items are subject to change +#[lang = "foo"] //~ ERROR language items are subject to change + //~^ ERROR definition of an unknown language item: `foo` trait Foo {} -fn main() { -} +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-lang-items.stderr b/src/test/ui/feature-gates/feature-gate-lang-items.stderr index 3383eaab01f32..ccbb711fe6d43 100644 --- a/src/test/ui/feature-gates/feature-gate-lang-items.stderr +++ b/src/test/ui/feature-gates/feature-gate-lang-items.stderr @@ -1,11 +1,18 @@ error[E0658]: language items are subject to change --> $DIR/feature-gate-lang-items.rs:1:1 | -LL | #[lang="foo"] //~ ERROR language items are subject to change - | ^^^^^^^^^^^^^ +LL | #[lang = "foo"] //~ ERROR language items are subject to change + | ^^^^^^^^^^^^^^^ | = help: add #![feature(lang_items)] to the crate attributes to enable -error: aborting due to previous error +error[E0522]: definition of an unknown language item: `foo` + --> $DIR/feature-gate-lang-items.rs:1:1 + | +LL | #[lang = "foo"] //~ ERROR language items are subject to change + | ^^^^^^^^^^^^^^^ definition of unknown language item `foo` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0522, E0658. +For more information about an error, try `rustc --explain E0522`. diff --git a/src/test/ui/feature-gates/feature-gate-linkage.rs b/src/test/ui/feature-gates/feature-gate-linkage.rs index 282c9a8b843f9..70f33cc0c6cc7 100644 --- a/src/test/ui/feature-gates/feature-gate-linkage.rs +++ b/src/test/ui/feature-gates/feature-gate-linkage.rs @@ -2,3 +2,5 @@ extern { #[linkage = "extern_weak"] static foo: isize; //~^ ERROR: the `linkage` attribute is experimental and not portable } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-may-dangle.rs b/src/test/ui/feature-gates/feature-gate-may-dangle.rs index 45666e90b210a..20896e426f65d 100644 --- a/src/test/ui/feature-gates/feature-gate-may-dangle.rs +++ b/src/test/ui/feature-gates/feature-gate-may-dangle.rs @@ -3,7 +3,9 @@ // Check that `may_dangle` is rejected if `dropck_eyepatch` feature gate is absent. struct Pt(A); -impl<#[may_dangle] A> Drop for Pt { +unsafe impl<#[may_dangle] A> Drop for Pt { //~^ ERROR may_dangle has unstable semantics and may be removed in the future fn drop(&mut self) { } } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-may-dangle.stderr b/src/test/ui/feature-gates/feature-gate-may-dangle.stderr index b537a5815886f..6d21147c9eeb3 100644 --- a/src/test/ui/feature-gates/feature-gate-may-dangle.stderr +++ b/src/test/ui/feature-gates/feature-gate-may-dangle.stderr @@ -1,8 +1,8 @@ error[E0658]: may_dangle has unstable semantics and may be removed in the future (see issue #34761) - --> $DIR/feature-gate-may-dangle.rs:6:6 + --> $DIR/feature-gate-may-dangle.rs:6:13 | -LL | impl<#[may_dangle] A> Drop for Pt { - | ^^^^^^^^^^^^^ +LL | unsafe impl<#[may_dangle] A> Drop for Pt { + | ^^^^^^^^^^^^^ | = help: add #![feature(dropck_eyepatch)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-min_const_fn.rs b/src/test/ui/feature-gates/feature-gate-min_const_fn.rs index e685b500ff3bb..669631df2ad17 100644 --- a/src/test/ui/feature-gates/feature-gate-min_const_fn.rs +++ b/src/test/ui/feature-gates/feature-gate-min_const_fn.rs @@ -9,14 +9,16 @@ trait Foo { //~| ERROR trait fns cannot be declared const } -impl Foo { - const fn baz() -> u32 { 0 } // stabilized -} - impl Foo for u32 { const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const } +trait Bar {} + +impl dyn Bar { + const fn baz() -> u32 { 0 } // stabilized +} + static FOO: usize = foo(); const BAR: usize = foo(); diff --git a/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr b/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr index 998a2243edcfa..bcc5b0198c319 100644 --- a/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr +++ b/src/test/ui/feature-gates/feature-gate-min_const_fn.stderr @@ -11,7 +11,7 @@ LL | const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable | ^^^^^ trait fns cannot be const error[E0379]: trait fns cannot be declared const - --> $DIR/feature-gate-min_const_fn.rs:17:5 + --> $DIR/feature-gate-min_const_fn.rs:13:5 | LL | const fn foo() -> u32 { 0 } //~ ERROR trait fns cannot be declared const | ^^^^^ trait fns cannot be const diff --git a/src/test/ui/feature-gates/feature-gate-naked_functions.rs b/src/test/ui/feature-gates/feature-gate-naked_functions.rs index 36bc636b0bb7b..16a51a1e82fc6 100644 --- a/src/test/ui/feature-gates/feature-gate-naked_functions.rs +++ b/src/test/ui/feature-gates/feature-gate-naked_functions.rs @@ -7,3 +7,5 @@ fn naked() {} fn naked_2() -> isize { 0 } + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-never_type.rs b/src/test/ui/feature-gates/feature-gate-never_type.rs index 44a3bdd2ca36b..be8c27dbb1b02 100644 --- a/src/test/ui/feature-gates/feature-gate-never_type.rs +++ b/src/test/ui/feature-gates/feature-gate-never_type.rs @@ -6,8 +6,8 @@ trait Foo { type Ma = (u32, !, i32); //~ ERROR type is experimental type Meeshka = Vec; //~ ERROR type is experimental -type Mow = &fn(!) -> !; //~ ERROR type is experimental -type Skwoz = &mut !; //~ ERROR type is experimental +type Mow = &'static fn(!) -> !; //~ ERROR type is experimental +type Skwoz = &'static mut !; //~ ERROR type is experimental impl Foo for Meeshka { type Wub = !; //~ ERROR type is experimental diff --git a/src/test/ui/feature-gates/feature-gate-never_type.stderr b/src/test/ui/feature-gates/feature-gate-never_type.stderr index 927758b67b9cc..c4f8771171e8b 100644 --- a/src/test/ui/feature-gates/feature-gate-never_type.stderr +++ b/src/test/ui/feature-gates/feature-gate-never_type.stderr @@ -15,18 +15,18 @@ LL | type Meeshka = Vec; //~ ERROR type is experimental = help: add #![feature(never_type)] to the crate attributes to enable error[E0658]: The `!` type is experimental (see issue #35121) - --> $DIR/feature-gate-never_type.rs:9:16 + --> $DIR/feature-gate-never_type.rs:9:24 | -LL | type Mow = &fn(!) -> !; //~ ERROR type is experimental - | ^ +LL | type Mow = &'static fn(!) -> !; //~ ERROR type is experimental + | ^ | = help: add #![feature(never_type)] to the crate attributes to enable error[E0658]: The `!` type is experimental (see issue #35121) - --> $DIR/feature-gate-never_type.rs:10:19 + --> $DIR/feature-gate-never_type.rs:10:27 | -LL | type Skwoz = &mut !; //~ ERROR type is experimental - | ^ +LL | type Skwoz = &'static mut !; //~ ERROR type is experimental + | ^ | = help: add #![feature(never_type)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-no_core.rs b/src/test/ui/feature-gates/feature-gate-no_core.rs index 03b237867aa91..40178edd74b8d 100644 --- a/src/test/ui/feature-gates/feature-gate-no_core.rs +++ b/src/test/ui/feature-gates/feature-gate-no_core.rs @@ -1,3 +1,5 @@ +#![crate_type = "rlib"] + #![no_core] //~ ERROR no_core is experimental -fn main() {} +pub struct S {} diff --git a/src/test/ui/feature-gates/feature-gate-no_core.stderr b/src/test/ui/feature-gates/feature-gate-no_core.stderr index cb8fe25df58a2..7390051b95da2 100644 --- a/src/test/ui/feature-gates/feature-gate-no_core.stderr +++ b/src/test/ui/feature-gates/feature-gate-no_core.stderr @@ -1,5 +1,5 @@ error[E0658]: no_core is experimental (see issue #29639) - --> $DIR/feature-gate-no_core.rs:1:1 + --> $DIR/feature-gate-no_core.rs:3:1 | LL | #![no_core] //~ ERROR no_core is experimental | ^^^^^^^^^^^ diff --git a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs index 9d70cbee53b09..35c05b75d365c 100644 --- a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs +++ b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.rs @@ -3,14 +3,10 @@ struct DummyStruct; -trait DummyTrait { - fn dummy(&self) {} -} - auto trait AutoDummyTrait {} //~^ ERROR auto traits are experimental and possibly buggy -impl !DummyTrait for DummyStruct {} +impl !AutoDummyTrait for DummyStruct {} //~^ ERROR negative trait bounds are not yet fully implemented; use marker types for now fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr index c523147611a81..e5d0a8681fb45 100644 --- a/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr +++ b/src/test/ui/feature-gates/feature-gate-optin-builtin-traits.stderr @@ -1,5 +1,5 @@ error[E0658]: auto traits are experimental and possibly buggy (see issue #13231) - --> $DIR/feature-gate-optin-builtin-traits.rs:10:1 + --> $DIR/feature-gate-optin-builtin-traits.rs:6:1 | LL | auto trait AutoDummyTrait {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,10 +7,10 @@ LL | auto trait AutoDummyTrait {} = help: add #![feature(optin_builtin_traits)] to the crate attributes to enable error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now (see issue #13231) - --> $DIR/feature-gate-optin-builtin-traits.rs:13:1 + --> $DIR/feature-gate-optin-builtin-traits.rs:9:1 | -LL | impl !DummyTrait for DummyStruct {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl !AutoDummyTrait for DummyStruct {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(optin_builtin_traits)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-repr-simd.rs b/src/test/ui/feature-gates/feature-gate-repr-simd.rs index 67ae538e22c9d..9d28f437415c9 100644 --- a/src/test/ui/feature-gates/feature-gate-repr-simd.rs +++ b/src/test/ui/feature-gates/feature-gate-repr-simd.rs @@ -1,7 +1,7 @@ #[repr(simd)] //~ error: SIMD types are experimental struct Foo(u64, u64); -#[repr(C)] +#[repr(C)] //~ warn: conflicting representation hints #[repr(simd)] //~ error: SIMD types are experimental struct Bar(u64, u64); diff --git a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr index 161cc67e81344..20cdbceeb689a 100644 --- a/src/test/ui/feature-gates/feature-gate-repr-simd.stderr +++ b/src/test/ui/feature-gates/feature-gate-repr-simd.stderr @@ -14,6 +14,15 @@ LL | #[repr(simd)] //~ error: SIMD types are experimental | = help: add #![feature(repr_simd)] to the crate attributes to enable +warning[E0566]: conflicting representation hints + --> $DIR/feature-gate-repr-simd.rs:4:8 + | +LL | #[repr(C)] //~ warn: conflicting representation hints + | ^ +LL | #[repr(simd)] //~ error: SIMD types are experimental + | ^^^^ + error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0566, E0658. +For more information about an error, try `rustc --explain E0566`. diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs index f7ff3eb3ac9ff..2b23388fdc96d 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs @@ -5,4 +5,4 @@ #[rustc_variance] //~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable #[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable -fn main() {} +fn main() {} //~ ERROR [] diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr index 2b90699384b48..31e24f5b99f1e 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs-1.stderr @@ -14,6 +14,13 @@ LL | #[rustc_error] //~ ERROR the `#[rustc_error]` attribute is just used for ru | = help: add #![feature(rustc_attrs)] to the crate attributes to enable -error: aborting due to 2 previous errors +error[E0208]: [] + --> $DIR/feature-gate-rustc-attrs-1.rs:8:1 + | +LL | fn main() {} //~ ERROR [] + | ^^^^^^^^^^^^ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0208, E0658. +For more information about an error, try `rustc --explain E0208`. diff --git a/src/test/ui/feature-gates/feature-gate-start.rs b/src/test/ui/feature-gates/feature-gate-start.rs index bf097c8203156..46a1279a3fb16 100644 --- a/src/test/ui/feature-gates/feature-gate-start.rs +++ b/src/test/ui/feature-gates/feature-gate-start.rs @@ -1,2 +1,3 @@ #[start] -fn foo() {} //~ ERROR: a #[start] function is an experimental feature +fn foo(_: isize, _: *const *const u8) -> isize { 0 } +//~^ ERROR a #[start] function is an experimental feature diff --git a/src/test/ui/feature-gates/feature-gate-start.stderr b/src/test/ui/feature-gates/feature-gate-start.stderr index 255703d767388..d39e5f3555537 100644 --- a/src/test/ui/feature-gates/feature-gate-start.stderr +++ b/src/test/ui/feature-gates/feature-gate-start.stderr @@ -1,8 +1,8 @@ error[E0658]: a #[start] function is an experimental feature whose signature may change over time (see issue #29633) --> $DIR/feature-gate-start.rs:2:1 | -LL | fn foo() {} //~ ERROR: a #[start] function is an experimental feature - | ^^^^^^^^^^^ +LL | fn foo(_: isize, _: *const *const u8) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(start)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-thread_local.rs b/src/test/ui/feature-gates/feature-gate-thread_local.rs index c47bdc1006c72..0efae1f6bc356 100644 --- a/src/test/ui/feature-gates/feature-gate-thread_local.rs +++ b/src/test/ui/feature-gates/feature-gate-thread_local.rs @@ -8,8 +8,4 @@ #[thread_local] //~ ERROR `#[thread_local]` is an experimental feature static FOO: i32 = 3; -pub fn main() { - FOO.with(|x| { - println!("x: {}", x); - }); -} +pub fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs index fc5902721d788..ff6e2b8290389 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.rs @@ -3,25 +3,29 @@ // never triggers (yet), because they encounter other problems around // angle bracket vs parentheses notation. -#![allow(dead_code)] +#![feature(fn_traits)] struct Foo; impl Fn<()> for Foo { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change extern "rust-call" fn call(self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } struct Foo1; impl FnOnce() for Foo1 { +//~^ ERROR associated type bindings are not allowed here extern "rust-call" fn call_once(self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } struct Bar; impl FnMut<()> for Bar { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change extern "rust-call" fn call_mut(&self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } struct Baz; impl FnOnce<()> for Baz { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change extern "rust-call" fn call_once(&self, args: ()) -> () {} //~^ ERROR rust-call ABI is subject to change } diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index 0e40e1fddb0c7..865b87e7dd5d7 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -1,5 +1,5 @@ error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:10:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:11:5 | LL | extern "rust-call" fn call(self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | extern "rust-call" fn call(self, args: ()) -> () {} = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:15:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:17:5 | LL | extern "rust-call" fn call_once(self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | extern "rust-call" fn call_once(self, args: ()) -> () {} = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:20:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:23:5 | LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,13 +23,44 @@ LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} = help: add #![feature(unboxed_closures)] to the crate attributes to enable error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:25:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:29:5 | LL | extern "rust-call" fn call_once(&self, args: ()) -> () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(unboxed_closures)] to the crate attributes to enable -error: aborting due to 4 previous errors +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:9:6 + | +LL | impl Fn<()> for Foo { + | ^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error[E0229]: associated type bindings are not allowed here + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:15:12 + | +LL | impl FnOnce() for Foo1 { + | ^^ associated type not allowed here + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:21:6 + | +LL | impl FnMut<()> for Bar { + | ^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:27:6 + | +LL | impl FnOnce<()> for Baz { + | ^^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error: aborting due to 8 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors occurred: E0229, E0658. +For more information about an error, try `rustc --explain E0229`. diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs b/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs index 4c0d7d14a5064..c3f5c99dcb482 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures.rs @@ -1,6 +1,9 @@ +#![feature(fn_traits)] + struct Test; impl FnOnce<(u32, u32)> for Test { +//~^ ERROR the precise format of `Fn`-family traits' type parameters is subject to change type Output = u32; extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr index 420b331ccccb3..e7b1fc589bb4a 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr @@ -1,5 +1,5 @@ error[E0658]: rust-call ABI is subject to change (see issue #29625) - --> $DIR/feature-gate-unboxed-closures.rs:6:5 + --> $DIR/feature-gate-unboxed-closures.rs:9:5 | LL | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { LL | | a + b @@ -8,6 +8,14 @@ LL | | } | = help: add #![feature(unboxed_closures)] to the crate attributes to enable -error: aborting due to previous error +error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead (see issue #29625) + --> $DIR/feature-gate-unboxed-closures.rs:5:6 + | +LL | impl FnOnce<(u32, u32)> for Test { + | ^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(unboxed_closures)] to the crate attributes to enable + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-51279.rs b/src/test/ui/issues/issue-51279.rs index ad5438fbd46cb..f8f3626caabe7 100644 --- a/src/test/ui/issues/issue-51279.rs +++ b/src/test/ui/issues/issue-51279.rs @@ -15,7 +15,7 @@ pub struct Y<#[cfg(none)] T>(T); // shouldn't care when the entire item is strip struct M(*const T); -unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { +impl<#[cfg_attr(none, may_dangle)] T> Drop for M { //~^ ERROR #[cfg_attr] cannot be applied on a generic parameter fn drop(&mut self) {} } @@ -23,3 +23,5 @@ unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { type Z<#[ignored] 'a, #[cfg(none)] T> = X<'a, T>; //~^ ERROR #[cfg] cannot be applied on a generic parameter //~| ERROR attribute `ignored` is currently unknown to the compiler + +fn main() {} diff --git a/src/test/ui/issues/issue-51279.stderr b/src/test/ui/issues/issue-51279.stderr index 1706e98e83b63..bc33eacac9994 100644 --- a/src/test/ui/issues/issue-51279.stderr +++ b/src/test/ui/issues/issue-51279.stderr @@ -35,10 +35,10 @@ LL | pub fn f<#[cfg(none)] 'a, #[cfg(none)] T>(_: &'a T) {} | ^^^^^^^^^^^^ error: #[cfg_attr] cannot be applied on a generic parameter - --> $DIR/issue-51279.rs:18:13 + --> $DIR/issue-51279.rs:18:6 | -LL | unsafe impl<#[cfg_attr(none, may_dangle)] T> Drop for M { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl<#[cfg_attr(none, may_dangle)] T> Drop for M { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: #[cfg] cannot be applied on a generic parameter --> $DIR/issue-51279.rs:23:23 diff --git a/src/test/ui/on-unimplemented/expected-comma-found-token.rs b/src/test/ui/on-unimplemented/expected-comma-found-token.rs index a3e6609f98215..a4e2a1754f013 100644 --- a/src/test/ui/on-unimplemented/expected-comma-found-token.rs +++ b/src/test/ui/on-unimplemented/expected-comma-found-token.rs @@ -4,11 +4,10 @@ #![feature(on_unimplemented)] -#[rustc_on_unimplemented( +#[rustc_on_unimplemented( //~ ERROR `#[rustc_on_unimplemented]` requires a value message="the message" - label="the label" + label="the label" //~ ERROR expected one of `)` or `,`, found `label` )] trait T {} -//~^^^ ERROR expected one of `)` or `,`, found `label` fn main() { } diff --git a/src/test/ui/on-unimplemented/expected-comma-found-token.stderr b/src/test/ui/on-unimplemented/expected-comma-found-token.stderr index 5bbdbe29416c1..aa1b520e01529 100644 --- a/src/test/ui/on-unimplemented/expected-comma-found-token.stderr +++ b/src/test/ui/on-unimplemented/expected-comma-found-token.stderr @@ -3,8 +3,20 @@ error: expected one of `)` or `,`, found `label` | LL | message="the message" | - expected one of `)` or `,` here -LL | label="the label" +LL | label="the label" //~ ERROR expected one of `)` or `,`, found `label` | ^^^^^ unexpected token -error: aborting due to previous error +error[E0232]: `#[rustc_on_unimplemented]` requires a value + --> $DIR/expected-comma-found-token.rs:7:1 + | +LL | / #[rustc_on_unimplemented( //~ ERROR `#[rustc_on_unimplemented]` requires a value +LL | | message="the message" +LL | | label="the label" //~ ERROR expected one of `)` or `,`, found `label` +LL | | )] + | |__^ value required here + | + = note: eg `#[rustc_on_unimplemented(message="foo")]` + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0232`. diff --git a/src/test/ui/span/gated-features-attr-spans.rs b/src/test/ui/span/gated-features-attr-spans.rs index ff722a5352079..69511ab8e1fc7 100644 --- a/src/test/ui/span/gated-features-attr-spans.rs +++ b/src/test/ui/span/gated-features-attr-spans.rs @@ -1,7 +1,7 @@ #[repr(simd)] //~ ERROR are experimental -struct Weapon { - name: String, - damage: u32 +struct Coord { + x: u32, + y: u32, } fn main() {} diff --git a/src/test/ui/utf8_idents.rs b/src/test/ui/utf8_idents.rs index c9f433c3c3b3d..bed0d9bb2be54 100644 --- a/src/test/ui/utf8_idents.rs +++ b/src/test/ui/utf8_idents.rs @@ -3,6 +3,7 @@ fn foo< 'β, //~ ERROR non-ascii idents are not fully supported γ //~ ERROR non-ascii idents are not fully supported + //~^ WARN type parameter `γ` should have a camel case name such as `Γ` >() {} struct X { diff --git a/src/test/ui/utf8_idents.stderr b/src/test/ui/utf8_idents.stderr index b1bb4a3001557..1ccf767491cdb 100644 --- a/src/test/ui/utf8_idents.stderr +++ b/src/test/ui/utf8_idents.stderr @@ -15,7 +15,7 @@ LL | γ //~ ERROR non-ascii idents are not fully supported = help: add #![feature(non_ascii_idents)] to the crate attributes to enable error[E0658]: non-ascii idents are not fully supported. (see issue #55467) - --> $DIR/utf8_idents.rs:9:5 + --> $DIR/utf8_idents.rs:10:5 | LL | δ: usize //~ ERROR non-ascii idents are not fully supported | ^ @@ -23,13 +23,21 @@ LL | δ: usize //~ ERROR non-ascii idents are not fully supported = help: add #![feature(non_ascii_idents)] to the crate attributes to enable error[E0658]: non-ascii idents are not fully supported. (see issue #55467) - --> $DIR/utf8_idents.rs:13:9 + --> $DIR/utf8_idents.rs:14:9 | LL | let α = 0.00001f64; //~ ERROR non-ascii idents are not fully supported | ^ | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable +warning: type parameter `γ` should have a camel case name such as `Γ` + --> $DIR/utf8_idents.rs:5:5 + | +LL | γ //~ ERROR non-ascii idents are not fully supported + | ^ + | + = note: #[warn(non_camel_case_types)] on by default + error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. From 0a6fb8473872b2a6dd7fe66697f90dceac667ec4 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Tue, 4 Dec 2018 14:10:32 -0500 Subject: [PATCH 48/58] make `panictry!` private to libsyntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit completely removes usage of the `panictry!` macro from outside libsyntax. The macro causes parse errors to be fatal, so using it in libsyntax_ext caused parse failures *within* a syntax extension to be fatal, which is probably not intended. Furthermore, this commit adds spans to diagnostics emitted by empty extensions if they were missing, à la #56491. --- src/librustdoc/core.rs | 10 +- src/librustdoc/lib.rs | 2 +- src/librustdoc/test.rs | 13 +- src/libsyntax/lib.rs | 2 - src/libsyntax_ext/asm.rs | 116 +++++++++++------- src/libsyntax_ext/assert.rs | 68 ++++++---- src/libsyntax_ext/cfg.rs | 35 +++++- src/libsyntax_ext/format.rs | 48 ++++---- src/libsyntax_ext/global_asm.rs | 57 ++++++--- .../rustdoc-ui/failed-doctest-output.stdout | 4 +- src/test/ui/asm/asm-parse-errors.rs | 15 +++ src/test/ui/asm/asm-parse-errors.stderr | 68 ++++++++++ src/test/ui/issues/issue-22644.rs | 4 +- src/test/ui/issues/issue-22644.stderr | 18 +-- src/test/ui/macros/assert.rs | 2 + src/test/ui/macros/assert.stderr | 16 ++- src/test/ui/macros/cfg.rs | 5 + src/test/ui/macros/cfg.stderr | 21 ++++ src/test/ui/macros/format-parse-errors.rs | 10 ++ src/test/ui/macros/format-parse-errors.stderr | 44 +++++++ src/test/ui/macros/global-asm.rs | 7 ++ src/test/ui/macros/global-asm.stderr | 20 +++ 22 files changed, 451 insertions(+), 134 deletions(-) create mode 100644 src/test/ui/asm/asm-parse-errors.rs create mode 100644 src/test/ui/asm/asm-parse-errors.stderr create mode 100644 src/test/ui/macros/cfg.rs create mode 100644 src/test/ui/macros/cfg.stderr create mode 100644 src/test/ui/macros/format-parse-errors.rs create mode 100644 src/test/ui/macros/format-parse-errors.stderr create mode 100644 src/test/ui/macros/global-asm.rs create mode 100644 src/test/ui/macros/global-asm.stderr diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 3fa2d085ece94..032b0fc974845 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -23,7 +23,7 @@ use syntax::json::JsonEmitter; use syntax::ptr::P; use syntax::symbol::keywords; use syntax_pos::DUMMY_SP; -use errors; +use errors::{self, FatalError}; use errors::emitter::{Emitter, EmitterWriter}; use parking_lot::ReentrantMutex; @@ -429,7 +429,13 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt let control = &driver::CompileController::basic(); - let krate = panictry!(driver::phase_1_parse_input(control, &sess, &input)); + let krate = match driver::phase_1_parse_input(control, &sess, &input) { + Ok(krate) => krate, + Err(mut e) => { + e.emit(); + FatalError.raise(); + } + }; let name = match crate_name { Some(ref crate_name) => crate_name.clone(), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 67d512ed71d37..1b6d7e87192d6 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -32,7 +32,7 @@ extern crate rustc_metadata; extern crate rustc_target; extern crate rustc_typeck; extern crate serialize; -#[macro_use] extern crate syntax; +extern crate syntax; extern crate syntax_pos; extern crate test as testing; #[macro_use] extern crate log; diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 24bb00f411242..dd9fbbb254662 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -1,4 +1,4 @@ -use errors; +use errors::{self, FatalError}; use errors::emitter::ColorConfig; use rustc_data_structures::sync::Lrc; use rustc_lint; @@ -84,9 +84,14 @@ pub fn run(mut options: Options) -> isize { target_features::add_configuration(&mut cfg, &sess, &*codegen_backend); sess.parse_sess.config = cfg; - let krate = panictry!(driver::phase_1_parse_input(&driver::CompileController::basic(), - &sess, - &input)); + let krate = + match driver::phase_1_parse_input(&driver::CompileController::basic(), &sess, &input) { + Ok(krate) => krate, + Err(mut e) => { + e.emit(); + FatalError.raise(); + } + }; let driver::ExpansionResult { defs, mut hir_forest, .. } = { phase_2_configure_and_expand( &sess, diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index f1345d0e6f16e..ea943e16a46e8 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -44,8 +44,6 @@ use ast::AttrId; // way towards a non-panic!-prone parser. It should be used for fatal parsing // errors; eventually we plan to convert all code using panictry to just use // normal try. -// Exported for syntax_ext, not meant for general use. -#[macro_export] macro_rules! panictry { ($e:expr) => ({ use std::result::Result::{Ok, Err}; diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index a8f3c40db609c..41ee6e91b3dc9 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -4,6 +4,7 @@ use self::State::*; use rustc_data_structures::thin_vec::ThinVec; +use errors::DiagnosticBuilder; use syntax::ast; use syntax::ext::base; use syntax::ext::base::*; @@ -51,6 +52,34 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, feature_gate::EXPLAIN_ASM); } + let mut inline_asm = match parse_inline_asm(cx, sp, tts) { + Ok(Some(inline_asm)) => inline_asm, + Ok(None) => return DummyResult::expr(sp), + Err(mut err) => { + err.emit(); + return DummyResult::expr(sp); + } + }; + + // If there are no outputs, the inline assembly is executed just for its side effects, + // so ensure that it is volatile + if inline_asm.outputs.is_empty() { + inline_asm.volatile = true; + } + + MacEager::expr(P(ast::Expr { + id: ast::DUMMY_NODE_ID, + node: ast::ExprKind::InlineAsm(P(inline_asm)), + span: sp, + attrs: ThinVec::new(), + })) +} + +fn parse_inline_asm<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree], +) -> Result, DiagnosticBuilder<'a>> { // Split the tts before the first colon, to avoid `asm!("x": y)` being // parsed as `asm!(z)` with `z = "x": y` which is type ascription. let first_colon = tts.iter() @@ -80,22 +109,33 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, if asm_str_style.is_some() { // If we already have a string with instructions, // ending up in Asm state again is an error. - span_err!(cx, sp, E0660, "malformed inline assembly"); - return DummyResult::expr(sp); + return Err(struct_span_err!( + cx.parse_sess.span_diagnostic, + sp, + E0660, + "malformed inline assembly" + )); } // Nested parser, stop before the first colon (see above). let mut p2 = cx.new_parser_from_tts(&tts[..first_colon]); - let (s, style) = match expr_to_string(cx, - panictry!(p2.parse_expr()), - "inline assembly must be a string literal") { - Some((s, st)) => (s, st), - // let compilation continue - None => return DummyResult::expr(sp), - }; + + if p2.token == token::Eof { + let mut err = + cx.struct_span_err(sp, "macro requires a string literal as an argument"); + err.span_label(sp, "string literal required"); + return Err(err); + } + + let expr = p2.parse_expr()?; + let (s, style) = + match expr_to_string(cx, expr, "inline assembly must be a string literal") { + Some((s, st)) => (s, st), + None => return Ok(None), + }; // This is most likely malformed. if p2.token != token::Eof { - let mut extra_tts = panictry!(p2.parse_all_token_trees()); + let mut extra_tts = p2.parse_all_token_trees()?; extra_tts.extend(tts[first_colon..].iter().cloned()); p = parse::stream_to_parser(cx.parse_sess, extra_tts.into_iter().collect()); } @@ -105,18 +145,17 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } Outputs => { while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep { - if !outputs.is_empty() { p.eat(&token::Comma); } - let (constraint, _str_style) = panictry!(p.parse_str()); + let (constraint, _) = p.parse_str()?; let span = p.prev_span; - panictry!(p.expect(&token::OpenDelim(token::Paren))); - let out = panictry!(p.parse_expr()); - panictry!(p.expect(&token::CloseDelim(token::Paren))); + p.expect(&token::OpenDelim(token::Paren))?; + let expr = p.parse_expr()?; + p.expect(&token::CloseDelim(token::Paren))?; // Expands a read+write operand into two operands. // @@ -143,7 +182,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, let is_indirect = constraint_str.contains("*"); outputs.push(ast::InlineAsmOutput { constraint: output.unwrap_or(constraint), - expr: out, + expr, is_rw, is_indirect, }); @@ -151,12 +190,11 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } Inputs => { while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep { - if !inputs.is_empty() { p.eat(&token::Comma); } - let (constraint, _str_style) = panictry!(p.parse_str()); + let (constraint, _) = p.parse_str()?; if constraint.as_str().starts_with("=") { span_err!(cx, p.prev_span, E0662, @@ -166,21 +204,20 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, "input operand constraint contains '+'"); } - panictry!(p.expect(&token::OpenDelim(token::Paren))); - let input = panictry!(p.parse_expr()); - panictry!(p.expect(&token::CloseDelim(token::Paren))); + p.expect(&token::OpenDelim(token::Paren))?; + let input = p.parse_expr()?; + p.expect(&token::CloseDelim(token::Paren))?; inputs.push((constraint, input)); } } Clobbers => { while p.token != token::Eof && p.token != token::Colon && p.token != token::ModSep { - if !clobs.is_empty() { p.eat(&token::Comma); } - let (s, _str_style) = panictry!(p.parse_str()); + let (s, _) = p.parse_str()?; if OPTIONS.iter().any(|&opt| s == opt) { cx.span_warn(p.prev_span, "expected a clobber, found an option"); @@ -193,7 +230,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } } Options => { - let (option, _str_style) = panictry!(p.parse_str()); + let (option, _) = p.parse_str()?; if option == "volatile" { // Indicates that the inline assembly has side effects @@ -234,26 +271,15 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } } - // If there are no outputs, the inline assembly is executed just for its side effects, - // so ensure that it is volatile - if outputs.is_empty() { - volatile = true; - } - - MacEager::expr(P(ast::Expr { - id: ast::DUMMY_NODE_ID, - node: ast::ExprKind::InlineAsm(P(ast::InlineAsm { - asm, - asm_str_style: asm_str_style.unwrap(), - outputs, - inputs, - clobbers: clobs, - volatile, - alignstack, - dialect, - ctxt: cx.backtrace(), - })), - span: sp, - attrs: ThinVec::new(), + Ok(Some(ast::InlineAsm { + asm, + asm_str_style: asm_str_style.unwrap(), + outputs, + inputs, + clobbers: clobs, + volatile, + alignstack, + dialect, + ctxt: cx.backtrace(), })) } diff --git a/src/libsyntax_ext/assert.rs b/src/libsyntax_ext/assert.rs index 2f5743e5e9b3d..b27f495322a42 100644 --- a/src/libsyntax_ext/assert.rs +++ b/src/libsyntax_ext/assert.rs @@ -1,9 +1,11 @@ -use syntax::ast::*; +use errors::DiagnosticBuilder; +use syntax::ast::{self, *}; use syntax::source_map::Spanned; use syntax::ext::base::*; use syntax::ext::build::AstBuilder; use syntax::parse::token; use syntax::print::pprust; +use syntax::ptr::P; use syntax::symbol::Symbol; use syntax::tokenstream::{TokenStream, TokenTree}; use syntax_pos::{Span, DUMMY_SP}; @@ -13,33 +15,18 @@ pub fn expand_assert<'cx>( sp: Span, tts: &[TokenTree], ) -> Box { - let mut parser = cx.new_parser_from_tts(tts); - - if parser.token == token::Eof { - cx.struct_span_err(sp, "macro requires a boolean expression as an argument") - .span_label(sp, "boolean expression required") - .emit(); - return DummyResult::expr(sp); - } - - let cond_expr = panictry!(parser.parse_expr()); - let custom_msg_args = if parser.eat(&token::Comma) { - let ts = parser.parse_tokens(); - if !ts.is_empty() { - Some(ts) - } else { - None + let Assert { cond_expr, custom_message } = match parse_assert(cx, sp, tts) { + Ok(assert) => assert, + Err(mut err) => { + err.emit(); + return DummyResult::expr(sp); } - } else { - None }; let sp = sp.apply_mark(cx.current_expansion.mark); let panic_call = Mac_ { path: Path::from_ident(Ident::new(Symbol::intern("panic"), sp)), - tts: if let Some(ts) = custom_msg_args { - ts.into() - } else { + tts: custom_message.unwrap_or_else(|| { TokenStream::from(TokenTree::Token( DUMMY_SP, token::Literal( @@ -49,8 +36,8 @@ pub fn expand_assert<'cx>( ))), None, ), - )).into() - }, + )) + }).into(), delim: MacDelimiter::Parenthesis, }; let if_expr = cx.expr_if( @@ -67,3 +54,36 @@ pub fn expand_assert<'cx>( ); MacEager::expr(if_expr) } + +struct Assert { + cond_expr: P, + custom_message: Option, +} + +fn parse_assert<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[TokenTree] +) -> Result> { + let mut parser = cx.new_parser_from_tts(tts); + + if parser.token == token::Eof { + let mut err = cx.struct_span_err(sp, "macro requires a boolean expression as an argument"); + err.span_label(sp, "boolean expression required"); + return Err(err); + } + + Ok(Assert { + cond_expr: parser.parse_expr()?, + custom_message: if parser.eat(&token::Comma) { + let ts = parser.parse_tokens(); + if !ts.is_empty() { + Some(ts) + } else { + None + } + } else { + None + }, + }) +} diff --git a/src/libsyntax_ext/cfg.rs b/src/libsyntax_ext/cfg.rs index 7e3c1bbddf525..3b47b03cbe8dc 100644 --- a/src/libsyntax_ext/cfg.rs +++ b/src/libsyntax_ext/cfg.rs @@ -2,6 +2,8 @@ /// a literal `true` or `false` based on whether the given cfg matches the /// current compilation environment. +use errors::DiagnosticBuilder; +use syntax::ast; use syntax::ext::base::*; use syntax::ext::base; use syntax::ext::build::AstBuilder; @@ -15,16 +17,39 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt, tts: &[tokenstream::TokenTree]) -> Box { let sp = sp.apply_mark(cx.current_expansion.mark); + + match parse_cfg(cx, sp, tts) { + Ok(cfg) => { + let matches_cfg = attr::cfg_matches(&cfg, cx.parse_sess, cx.ecfg.features); + MacEager::expr(cx.expr_bool(sp, matches_cfg)) + } + Err(mut err) => { + err.emit(); + DummyResult::expr(sp) + } + } +} + +fn parse_cfg<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree], +) -> Result> { let mut p = cx.new_parser_from_tts(tts); - let cfg = panictry!(p.parse_meta_item()); + + if p.token == token::Eof { + let mut err = cx.struct_span_err(sp, "macro requires a cfg-pattern as an argument"); + err.span_label(sp, "cfg-pattern required"); + return Err(err); + } + + let cfg = p.parse_meta_item()?; let _ = p.eat(&token::Comma); if !p.eat(&token::Eof) { - cx.span_err(sp, "expected 1 cfg-pattern"); - return DummyResult::expr(sp); + return Err(cx.struct_span_err(sp, "expected 1 cfg-pattern")); } - let matches_cfg = attr::cfg_matches(&cfg, cx.parse_sess, cx.ecfg.features); - MacEager::expr(cx.expr_bool(sp, matches_cfg)) + Ok(cfg) } diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index c11f27f3ed589..61722ba551653 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -3,6 +3,7 @@ use self::Position::*; use fmt_macros as parse; +use errors::DiagnosticBuilder; use syntax::ast; use syntax::ext::base::{self, *}; use syntax::ext::build::AstBuilder; @@ -112,7 +113,7 @@ struct Context<'a, 'b: 'a> { is_literal: bool, } -/// Parses the arguments from the given list of tokens, returning None +/// Parses the arguments from the given list of tokens, returning the diagnostic /// if there's a parse error so we can continue parsing other format! /// expressions. /// @@ -121,27 +122,26 @@ struct Context<'a, 'b: 'a> { /// ```text /// Some((fmtstr, parsed arguments, index map for named arguments)) /// ``` -fn parse_args(ecx: &mut ExtCtxt, - sp: Span, - tts: &[tokenstream::TokenTree]) - -> Option<(P, Vec>, FxHashMap)> { +fn parse_args<'a>( + ecx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree] +) -> Result<(P, Vec>, FxHashMap), DiagnosticBuilder<'a>> { let mut args = Vec::>::new(); let mut names = FxHashMap::::default(); let mut p = ecx.new_parser_from_tts(tts); if p.token == token::Eof { - ecx.span_err(sp, "requires at least a format string argument"); - return None; + return Err(ecx.struct_span_err(sp, "requires at least a format string argument")); } - let fmtstr = panictry!(p.parse_expr()); + let fmtstr = p.parse_expr()?; let mut named = false; while p.token != token::Eof { if !p.eat(&token::Comma) { - ecx.span_err(p.span, "expected token: `,`"); - return None; + return Err(ecx.struct_span_err(p.span, "expected token: `,`")); } if p.token == token::Eof { break; @@ -152,16 +152,15 @@ fn parse_args(ecx: &mut ExtCtxt, p.bump(); i } else { - ecx.span_err( + return Err(ecx.struct_span_err( p.span, "expected ident, positional arguments cannot follow named arguments", - ); - return None; + )); }; let name: &str = &ident.as_str(); - panictry!(p.expect(&token::Eq)); - let e = panictry!(p.parse_expr()); + p.expect(&token::Eq).unwrap(); + let e = p.parse_expr()?; if let Some(prev) = names.get(name) { ecx.struct_span_err(e.span, &format!("duplicate argument named `{}`", name)) .span_note(args[*prev].span, "previously here") @@ -177,10 +176,11 @@ fn parse_args(ecx: &mut ExtCtxt, names.insert(name.to_string(), slot); args.push(e); } else { - args.push(panictry!(p.parse_expr())); + let e = p.parse_expr()?; + args.push(e); } } - Some((fmtstr, args, names)) + Ok((fmtstr, args, names)) } impl<'a, 'b> Context<'a, 'b> { @@ -689,10 +689,13 @@ pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt, -> Box { sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { - Some((efmt, args, names)) => { + Ok((efmt, args, names)) => { MacEager::expr(expand_preparsed_format_args(ecx, sp, efmt, args, names, false)) } - None => DummyResult::expr(sp), + Err(mut err) => { + err.emit(); + DummyResult::expr(sp) + } } } @@ -716,10 +719,13 @@ pub fn expand_format_args_nl<'cx>( } sp = sp.apply_mark(ecx.current_expansion.mark); match parse_args(ecx, sp, tts) { - Some((efmt, args, names)) => { + Ok((efmt, args, names)) => { MacEager::expr(expand_preparsed_format_args(ecx, sp, efmt, args, names, true)) } - None => DummyResult::expr(sp), + Err(mut err) => { + err.emit(); + DummyResult::expr(sp) + } } } diff --git a/src/libsyntax_ext/global_asm.rs b/src/libsyntax_ext/global_asm.rs index a58c267ab4fae..0a12e27c4fc21 100644 --- a/src/libsyntax_ext/global_asm.rs +++ b/src/libsyntax_ext/global_asm.rs @@ -8,11 +8,13 @@ /// LLVM's `module asm "some assembly here"`. All of LLVM's caveats /// therefore apply. +use errors::DiagnosticBuilder; use syntax::ast; use syntax::source_map::respan; use syntax::ext::base; use syntax::ext::base::*; use syntax::feature_gate; +use syntax::parse::token; use syntax::ptr::P; use syntax::symbol::Symbol; use syntax_pos::Span; @@ -31,24 +33,47 @@ pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt, feature_gate::EXPLAIN_GLOBAL_ASM); } + match parse_global_asm(cx, sp, tts) { + Ok(Some(global_asm)) => { + MacEager::items(smallvec![P(ast::Item { + ident: ast::Ident::with_empty_ctxt(Symbol::intern("")), + attrs: Vec::new(), + id: ast::DUMMY_NODE_ID, + node: ast::ItemKind::GlobalAsm(P(global_asm)), + vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited), + span: sp, + tokens: None, + })]) + } + Ok(None) => DummyResult::any(sp), + Err(mut err) => { + err.emit(); + DummyResult::any(sp) + } + } +} + +fn parse_global_asm<'a>( + cx: &mut ExtCtxt<'a>, + sp: Span, + tts: &[tokenstream::TokenTree] +) -> Result, DiagnosticBuilder<'a>> { let mut p = cx.new_parser_from_tts(tts); - let (asm, _) = match expr_to_string(cx, - panictry!(p.parse_expr()), - "inline assembly must be a string literal") { + + if p.token == token::Eof { + let mut err = cx.struct_span_err(sp, "macro requires a string literal as an argument"); + err.span_label(sp, "string literal required"); + return Err(err); + } + + let expr = p.parse_expr()?; + let (asm, _) = match expr_to_string(cx, expr, "inline assembly must be a string literal") { Some((s, st)) => (s, st), - None => return DummyResult::any(sp), + None => return Ok(None), }; - MacEager::items(smallvec![P(ast::Item { - ident: ast::Ident::with_empty_ctxt(Symbol::intern("")), - attrs: Vec::new(), - id: ast::DUMMY_NODE_ID, - node: ast::ItemKind::GlobalAsm(P(ast::GlobalAsm { - asm, - ctxt: cx.backtrace(), - })), - vis: respan(sp.shrink_to_lo(), ast::VisibilityKind::Inherited), - span: sp, - tokens: None, - })]) + Ok(Some(ast::GlobalAsm { + asm, + ctxt: cx.backtrace(), + })) } diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 54830dceb8f17..9fd46e94f030a 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope 3 | no | ^^ not found in this scope -thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:316:13 +thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:321:13 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. ---- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ---- @@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. -', src/librustdoc/test.rs:351:17 +', src/librustdoc/test.rs:356:17 failures: diff --git a/src/test/ui/asm/asm-parse-errors.rs b/src/test/ui/asm/asm-parse-errors.rs new file mode 100644 index 0000000000000..e712ac5826e2c --- /dev/null +++ b/src/test/ui/asm/asm-parse-errors.rs @@ -0,0 +1,15 @@ +#![feature(asm)] + +fn main() { + asm!(); //~ ERROR requires a string literal as an argument + asm!("nop" : struct); //~ ERROR expected string literal + asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal + asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(` + asm!("mov %eax, $$0x2" : "={eax}"(struct)); //~ ERROR expected expression + asm!("in %dx, %al" : "={al}"(result) : struct); //~ ERROR expected string literal + asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct); //~ ERROR expected `(` + asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct)); //~ ERROR expected expression + asm!("mov $$0x200, %eax" : : : struct); //~ ERROR expected string literal + asm!("mov eax, 2" : "={eax}"(foo) : : : struct); //~ ERROR expected string literal + asm!(123); //~ ERROR inline assembly must be a string literal +} diff --git a/src/test/ui/asm/asm-parse-errors.stderr b/src/test/ui/asm/asm-parse-errors.stderr new file mode 100644 index 0000000000000..37b61b80b2b89 --- /dev/null +++ b/src/test/ui/asm/asm-parse-errors.stderr @@ -0,0 +1,68 @@ +error: macro requires a string literal as an argument + --> $DIR/asm-parse-errors.rs:4:5 + | +LL | asm!(); //~ ERROR requires a string literal as an argument + | ^^^^^^^ string literal required + +error: expected string literal + --> $DIR/asm-parse-errors.rs:5:18 + | +LL | asm!("nop" : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected string literal + --> $DIR/asm-parse-errors.rs:6:30 + | +LL | asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected `(`, found keyword `struct` + --> $DIR/asm-parse-errors.rs:7:39 + | +LL | asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(` + | ^^^^^^ expected `(` + +error: expected expression, found keyword `struct` + --> $DIR/asm-parse-errors.rs:8:39 + | +LL | asm!("mov %eax, $$0x2" : "={eax}"(struct)); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected string literal + --> $DIR/asm-parse-errors.rs:9:44 + | +LL | asm!("in %dx, %al" : "={al}"(result) : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected `(`, found keyword `struct` + --> $DIR/asm-parse-errors.rs:10:51 + | +LL | asm!("in %dx, %al" : "={al}"(result) : "{dx}" struct); //~ ERROR expected `(` + | ^^^^^^ expected `(` + +error: expected expression, found keyword `struct` + --> $DIR/asm-parse-errors.rs:11:51 + | +LL | asm!("in %dx, %al" : "={al}"(result) : "{dx}"(struct)); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected string literal + --> $DIR/asm-parse-errors.rs:12:36 + | +LL | asm!("mov $$0x200, %eax" : : : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: expected string literal + --> $DIR/asm-parse-errors.rs:13:45 + | +LL | asm!("mov eax, 2" : "={eax}"(foo) : : : struct); //~ ERROR expected string literal + | ^^^^^^ expected string literal + +error: inline assembly must be a string literal + --> $DIR/asm-parse-errors.rs:14:10 + | +LL | asm!(123); //~ ERROR inline assembly must be a string literal + | ^^^ + +error: aborting due to 11 previous errors + diff --git a/src/test/ui/issues/issue-22644.rs b/src/test/ui/issues/issue-22644.rs index c87a927e55008..9244ff5931d3e 100644 --- a/src/test/ui/issues/issue-22644.rs +++ b/src/test/ui/issues/issue-22644.rs @@ -1,5 +1,7 @@ +#![feature(type_ascription)] + fn main() { - let a : u32 = 0; + let a : usize = 0; let long_name : usize = 0; println!("{}", a as usize > long_name); diff --git a/src/test/ui/issues/issue-22644.stderr b/src/test/ui/issues/issue-22644.stderr index ea5c9c5ad239e..de97b2271b10a 100644 --- a/src/test/ui/issues/issue-22644.stderr +++ b/src/test/ui/issues/issue-22644.stderr @@ -1,5 +1,5 @@ error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:6:31 + --> $DIR/issue-22644.rs:8:31 | LL | println!("{}", a as usize < long_name); //~ ERROR `<` is interpreted as a start of generic | ---------- ^ --------- interpreted as generic arguments @@ -8,7 +8,7 @@ LL | println!("{}", a as usize < long_name); //~ ERROR `<` is interpreted as | help: try comparing the cast value: `(a as usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:7:33 + --> $DIR/issue-22644.rs:9:33 | LL | println!("{}{}", a as usize < long_name, long_name); | ---------- ^ -------------------- interpreted as generic arguments @@ -17,7 +17,7 @@ LL | println!("{}{}", a as usize < long_name, long_name); | help: try comparing the cast value: `(a as usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:9:31 + --> $DIR/issue-22644.rs:11:31 | LL | println!("{}", a as usize < 4); //~ ERROR `<` is interpreted as a start of generic | ---------- ^ - interpreted as generic arguments @@ -26,7 +26,7 @@ LL | println!("{}", a as usize < 4); //~ ERROR `<` is interpreted as a start | help: try comparing the cast value: `(a as usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:11:31 + --> $DIR/issue-22644.rs:13:31 | LL | println!("{}{}", a: usize < long_name, long_name); | -------- ^ -------------------- interpreted as generic arguments @@ -35,7 +35,7 @@ LL | println!("{}{}", a: usize < long_name, long_name); | help: try comparing the cast value: `(a: usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:13:29 + --> $DIR/issue-22644.rs:15:29 | LL | println!("{}", a: usize < 4); //~ ERROR `<` is interpreted as a start of generic | -------- ^ - interpreted as generic arguments @@ -44,7 +44,7 @@ LL | println!("{}", a: usize < 4); //~ ERROR `<` is interpreted as a start o | help: try comparing the cast value: `(a: usize)` error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:18:20 + --> $DIR/issue-22644.rs:20:20 | LL | < //~ ERROR `<` is interpreted as a start of generic | ^ not interpreted as comparison @@ -58,7 +58,7 @@ LL | usize) | error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison - --> $DIR/issue-22644.rs:27:20 + --> $DIR/issue-22644.rs:29:20 | LL | < //~ ERROR `<` is interpreted as a start of generic | ^ not interpreted as comparison @@ -75,7 +75,7 @@ LL | ... error: `<` is interpreted as a start of generic arguments for `usize`, not a shift - --> $DIR/issue-22644.rs:30:31 + --> $DIR/issue-22644.rs:32:31 | LL | println!("{}", a as usize << long_name); //~ ERROR `<` is interpreted as a start of generic | ---------- ^^ --------- interpreted as generic arguments @@ -84,7 +84,7 @@ LL | println!("{}", a as usize << long_name); //~ ERROR `<` is interpreted a | help: try shifting the cast value: `(a as usize)` error: expected type, found `4` - --> $DIR/issue-22644.rs:32:28 + --> $DIR/issue-22644.rs:34:28 | LL | println!("{}", a: &mut 4); //~ ERROR expected type, found `4` | ^ expecting a type here because of type ascription diff --git a/src/test/ui/macros/assert.rs b/src/test/ui/macros/assert.rs index 8732cb58d74a6..71b0dbb19e262 100644 --- a/src/test/ui/macros/assert.rs +++ b/src/test/ui/macros/assert.rs @@ -1,4 +1,6 @@ fn main() { assert!(); //~ ERROR requires a boolean expression + assert!(struct); //~ ERROR expected expression debug_assert!(); //~ ERROR requires a boolean expression + debug_assert!(struct); //~ ERROR expected expression } diff --git a/src/test/ui/macros/assert.stderr b/src/test/ui/macros/assert.stderr index 89faba0cf63dd..2cfcebabcb931 100644 --- a/src/test/ui/macros/assert.stderr +++ b/src/test/ui/macros/assert.stderr @@ -4,13 +4,25 @@ error: macro requires a boolean expression as an argument LL | assert!(); //~ ERROR requires a boolean expression | ^^^^^^^^^^ boolean expression required +error: expected expression, found keyword `struct` + --> $DIR/assert.rs:3:13 + | +LL | assert!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + error: macro requires a boolean expression as an argument - --> $DIR/assert.rs:3:5 + --> $DIR/assert.rs:4:5 | LL | debug_assert!(); //~ ERROR requires a boolean expression | ^^^^^^^^^^^^^^^^ boolean expression required | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: aborting due to 2 previous errors +error: expected expression, found keyword `struct` + --> $DIR/assert.rs:5:19 + | +LL | debug_assert!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: aborting due to 4 previous errors diff --git a/src/test/ui/macros/cfg.rs b/src/test/ui/macros/cfg.rs new file mode 100644 index 0000000000000..222161a8183a2 --- /dev/null +++ b/src/test/ui/macros/cfg.rs @@ -0,0 +1,5 @@ +fn main() { + cfg!(); //~ ERROR macro requires a cfg-pattern + cfg!(123); //~ ERROR expected identifier + cfg!(foo = 123); //~ ERROR literal in `cfg` predicate value must be a string +} diff --git a/src/test/ui/macros/cfg.stderr b/src/test/ui/macros/cfg.stderr new file mode 100644 index 0000000000000..a7aca88f3e56e --- /dev/null +++ b/src/test/ui/macros/cfg.stderr @@ -0,0 +1,21 @@ +error: macro requires a cfg-pattern as an argument + --> $DIR/cfg.rs:2:5 + | +LL | cfg!(); //~ ERROR macro requires a cfg-pattern + | ^^^^^^^ cfg-pattern required + +error: expected identifier, found `123` + --> $DIR/cfg.rs:3:10 + | +LL | cfg!(123); //~ ERROR expected identifier + | ^^^ expected identifier + +error[E0565]: literal in `cfg` predicate value must be a string + --> $DIR/cfg.rs:4:16 + | +LL | cfg!(foo = 123); //~ ERROR literal in `cfg` predicate value must be a string + | ^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0565`. diff --git a/src/test/ui/macros/format-parse-errors.rs b/src/test/ui/macros/format-parse-errors.rs new file mode 100644 index 0000000000000..ba1e441fe339f --- /dev/null +++ b/src/test/ui/macros/format-parse-errors.rs @@ -0,0 +1,10 @@ +fn main() { + format!(); //~ ERROR requires at least a format string argument + format!(struct); //~ ERROR expected expression + format!("s", name =); //~ ERROR expected expression + format!("s", foo = struct); //~ ERROR expected expression + format!("s", struct); //~ ERROR expected expression + + // This error should come after parsing errors to ensure they are non-fatal. + format!(123); //~ ERROR format argument must be a string literal +} diff --git a/src/test/ui/macros/format-parse-errors.stderr b/src/test/ui/macros/format-parse-errors.stderr new file mode 100644 index 0000000000000..0463c54890177 --- /dev/null +++ b/src/test/ui/macros/format-parse-errors.stderr @@ -0,0 +1,44 @@ +error: requires at least a format string argument + --> $DIR/format-parse-errors.rs:2:5 + | +LL | format!(); //~ ERROR requires at least a format string argument + | ^^^^^^^^^^ + | + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +error: expected expression, found keyword `struct` + --> $DIR/format-parse-errors.rs:3:13 + | +LL | format!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected expression, found `` + --> $DIR/format-parse-errors.rs:4:23 + | +LL | format!("s", name =); //~ ERROR expected expression + | ^ expected expression + +error: expected expression, found keyword `struct` + --> $DIR/format-parse-errors.rs:5:24 + | +LL | format!("s", foo = struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: expected expression, found keyword `struct` + --> $DIR/format-parse-errors.rs:6:18 + | +LL | format!("s", struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: format argument must be a string literal + --> $DIR/format-parse-errors.rs:9:13 + | +LL | format!(123); //~ ERROR format argument must be a string literal + | ^^^ +help: you might be missing a string literal to format with + | +LL | format!("{}", 123); //~ ERROR format argument must be a string literal + | ^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/macros/global-asm.rs b/src/test/ui/macros/global-asm.rs new file mode 100644 index 0000000000000..8402afa50857a --- /dev/null +++ b/src/test/ui/macros/global-asm.rs @@ -0,0 +1,7 @@ +#![feature(global_asm)] + +fn main() { + global_asm!(); //~ ERROR requires a string literal as an argument + global_asm!(struct); //~ ERROR expected expression + global_asm!(123); //~ ERROR inline assembly must be a string literal +} diff --git a/src/test/ui/macros/global-asm.stderr b/src/test/ui/macros/global-asm.stderr new file mode 100644 index 0000000000000..94664c96db391 --- /dev/null +++ b/src/test/ui/macros/global-asm.stderr @@ -0,0 +1,20 @@ +error: macro requires a string literal as an argument + --> $DIR/global-asm.rs:4:5 + | +LL | global_asm!(); //~ ERROR requires a string literal as an argument + | ^^^^^^^^^^^^^^ string literal required + +error: expected expression, found keyword `struct` + --> $DIR/global-asm.rs:5:17 + | +LL | global_asm!(struct); //~ ERROR expected expression + | ^^^^^^ expected expression + +error: inline assembly must be a string literal + --> $DIR/global-asm.rs:6:17 + | +LL | global_asm!(123); //~ ERROR inline assembly must be a string literal + | ^^^ + +error: aborting due to 3 previous errors + From 0b6d217fd9d0f8c4611adbf0bebbf4496988232e Mon Sep 17 00:00:00 2001 From: Jethro Beekman Date: Wed, 2 Jan 2019 23:56:55 +0530 Subject: [PATCH 49/58] Update compiler_builtins 0.1.2 -> 0.1.3 --- Cargo.lock | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 328c145edc4dd..2800bcc74e5cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ name = "alloc" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -98,7 +98,7 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -409,7 +409,7 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", @@ -665,7 +665,7 @@ name = "dlmalloc" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -823,7 +823,7 @@ name = "fortanix-sgx-abi" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -1516,7 +1516,7 @@ dependencies = [ name = "panic_abort" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1526,7 +1526,7 @@ name = "panic_unwind" version = "0.0.0" dependencies = [ "alloc 0.0.0", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", "unwind 0.0.0", @@ -1679,7 +1679,7 @@ name = "profiler_builtins" version = "0.0.0" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -1810,7 +1810,7 @@ name = "rand_chacha" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1832,7 +1832,7 @@ name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1857,7 +1857,7 @@ name = "rand_xorshift" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2198,7 +2198,7 @@ name = "rustc-demangle" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-std-workspace-core 1.0.0", ] @@ -2296,7 +2296,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2490,7 +2490,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2542,7 +2542,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2655,7 +2655,7 @@ dependencies = [ "alloc 0.0.0", "build_helper 0.1.0", "cmake 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", ] @@ -2891,7 +2891,7 @@ dependencies = [ "alloc 0.0.0", "backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3232,7 +3232,7 @@ dependencies = [ name = "unwind" version = "0.0.0" dependencies = [ - "compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "core 0.0.0", "libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3412,7 +3412,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc" "checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" "checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -"checksum compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8ad611263b9f31bdb66e66227d3b781600fd1e68d5deee29b23f5e2ac9cb4892" +"checksum compiler_builtins 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e066bf05ea052f9891699abcf8c3025256e3f29b50b741441be1e614b10d9c4a" "checksum compiletest_rs 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "89747fe073b7838343bd2c2445e7a7c2e0d415598f8925f0fa9205b9cdfc48cb" "checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887" "checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" From 3852dc8fe9a21950c923e4815c475497eee3e653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 2 Jan 2019 20:03:43 +0100 Subject: [PATCH 50/58] Add Clippy to config.toml.example --- config.toml.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.toml.example b/config.toml.example index 33ad9147ce059..433043e924bc1 100644 --- a/config.toml.example +++ b/config.toml.example @@ -161,7 +161,7 @@ # Installs chosen set of extended tools if enables. By default builds all. # If chosen tool failed to build the installation fails. -#tools = ["cargo", "rls", "rustfmt", "analysis", "src"] +#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"] # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose #verbose = 0 From ea7fef1ccf4b44effbc3bbc902f9b0b9dbd251a4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 17 Dec 2018 21:10:59 -0800 Subject: [PATCH 51/58] bootstrap: Link LLVM as a dylib with ThinLTO When building a distributed compiler on Linux where we use ThinLTO to create the LLVM shared object this commit switches the compiler to dynamically linking that LLVM artifact instead of statically linking to LLVM. The primary goal here is to reduce CI compile times, avoiding two+ ThinLTO builds of all of LLVM. By linking dynamically to LLVM we'll reuse the one ThinLTO step done by LLVM's build itself. Lots of discussion about this change can be found [here] and down. A perf run will show whether this is worth it or not! [here]: https://github.com/rust-lang/rust/pull/53245#issuecomment-417015334 --- src/bootstrap/check.rs | 5 ---- src/bootstrap/compile.rs | 49 +++++++------------------------------- src/bootstrap/dist.rs | 8 +++---- src/bootstrap/tool.rs | 2 +- src/librustc_llvm/build.rs | 4 ++++ 5 files changed, 17 insertions(+), 51 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 050db936daab1..cc539d4c89571 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -38,7 +38,6 @@ impl Step for Std { builder.info(&format!("Checking std artifacts ({} -> {})", &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libstd_stamp(builder, compiler, target), true); @@ -85,7 +84,6 @@ impl Step for Rustc { builder.info(&format!("Checking compiler artifacts ({} -> {})", &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &librustc_stamp(builder, compiler, target), true); @@ -136,7 +134,6 @@ impl Step for CodegenBackend { let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage)); run_cargo(builder, &mut cargo, - vec![], &codegen_backend_stamp(builder, compiler, target, backend), true); } @@ -174,7 +171,6 @@ impl Step for Test { builder.info(&format!("Checking test artifacts ({} -> {})", &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libtest_stamp(builder, compiler, target), true); @@ -222,7 +218,6 @@ impl Step for Rustdoc { println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target); run_cargo(builder, &mut cargo, - vec![], &rustdoc_stamp(builder, compiler, target), true); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 821bd002e95b3..0d2546a0e9ca9 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -19,6 +19,7 @@ use build_helper::{output, mtime, up_to_date}; use filetime::FileTime; use serde_json; +use crate::dist; use crate::util::{exe, libdir, is_dylib}; use crate::{Compiler, Mode, GitRepo}; use crate::native; @@ -104,7 +105,6 @@ impl Step for Std { &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libstd_stamp(builder, compiler, target), false); @@ -365,7 +365,6 @@ impl Step for Test { &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &libtest_stamp(builder, compiler, target), false); @@ -493,7 +492,6 @@ impl Step for Rustc { compiler.stage, &compiler.host, target)); run_cargo(builder, &mut cargo, - vec![], &librustc_stamp(builder, compiler, target), false); @@ -636,47 +634,18 @@ impl Step for CodegenBackend { let out_dir = builder.cargo_out(compiler, Mode::Codegen, target); - let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "rustc"); + let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "build"); cargo.arg("--manifest-path") .arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml")); rustc_cargo_env(builder, &mut cargo); let features = build_codegen_backend(&builder, &mut cargo, &compiler, target, backend); - let mut cargo_tails_args = vec![]; - - if builder.config.llvm_thin_lto { - cargo_tails_args.push("--".to_string()); - - let num_jobs = builder.jobs(); - - if !target.contains("msvc") { - // Here we assume that the linker is clang. If it's not, there'll - // be linker errors. - cargo_tails_args.push("-Clink-arg=-fuse-ld=lld".to_string()); - cargo_tails_args.push("-Clink-arg=-flto=thin".to_string()); - - if builder.config.llvm_optimize { - cargo_tails_args.push("-Clink-arg=-O2".to_string()); - } - - // Let's make LLD respect the `-j` option. - let num_jobs_arg = format!("-Clink-arg=-Wl,--thinlto-jobs={}", num_jobs); - cargo_tails_args.push(num_jobs_arg); - } else { - // Here we assume that the linker is lld-link.exe. lld-link.exe - // does not need the extra arguments except for num_jobs - let num_jobs_arg = format!("-Clink-arg=/opt:lldltojobs={}", num_jobs); - cargo_tails_args.push(num_jobs_arg); - } - } - let tmp_stamp = out_dir.join(".tmp.stamp"); let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage)); let files = run_cargo(builder, cargo.arg("--features").arg(features), - cargo_tails_args, &tmp_stamp, false); if builder.config.dry_run { @@ -749,7 +718,9 @@ pub fn build_codegen_backend(builder: &Builder, "libstdc++.a"); cargo.env("LLVM_STATIC_STDCPP", file); } - if builder.config.llvm_link_shared { + if builder.config.llvm_link_shared || + (builder.config.llvm_thin_lto && backend != "emscripten") + { cargo.env("LLVM_LINK_SHARED", "1"); } } @@ -989,6 +960,8 @@ impl Step for Assemble { copy_lld_to_sysroot(builder, target_compiler, &lld_install); } + dist::maybe_install_llvm_dylib(builder, target_compiler.host, &sysroot); + // Link the compiler binary itself into place let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host); let rustc = out_dir.join(exe("rustc_binary", &*host)); @@ -1015,7 +988,6 @@ pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) { pub fn run_cargo(builder: &Builder, cargo: &mut Command, - tail_args: Vec, stamp: &Path, is_check: bool) -> Vec @@ -1038,7 +1010,7 @@ pub fn run_cargo(builder: &Builder, // files we need to probe for later. let mut deps = Vec::new(); let mut toplevel = Vec::new(); - let ok = stream_cargo(builder, cargo, tail_args, &mut |msg| { + let ok = stream_cargo(builder, cargo, &mut |msg| { let filenames = match msg { CargoMessage::CompilerArtifact { filenames, .. } => filenames, _ => return, @@ -1163,7 +1135,6 @@ pub fn run_cargo(builder: &Builder, pub fn stream_cargo( builder: &Builder, cargo: &mut Command, - tail_args: Vec, cb: &mut dyn FnMut(CargoMessage), ) -> bool { if builder.config.dry_run { @@ -1174,10 +1145,6 @@ pub fn stream_cargo( cargo.arg("--message-format").arg("json") .stdout(Stdio::piped()); - for arg in tail_args { - cargo.arg(arg); - } - builder.verbose(&format!("running: {:?}", cargo)); let mut child = match cargo.spawn() { Ok(child) => child, diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 9f97e57b4562e..97a359639cb83 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -1877,13 +1877,13 @@ impl Step for HashSign { // LLVM tools are linked dynamically. // Note: This function does no yet support Windows but we also don't support // linking LLVM tools dynamically on Windows yet. -fn maybe_install_llvm_dylib(builder: &Builder, - target: Interned, - image: &Path) { +pub fn maybe_install_llvm_dylib(builder: &Builder, + target: Interned, + sysroot: &Path) { let src_libdir = builder .llvm_out(target) .join("lib"); - let dst_libdir = image.join("lib/rustlib").join(&*target).join("lib"); + let dst_libdir = sysroot.join("lib/rustlib").join(&*target).join("lib"); t!(fs::create_dir_all(&dst_libdir)); if target.contains("apple-darwin") { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 7782351a552d4..d31ea0f845873 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -77,7 +77,7 @@ impl Step for ToolBuild { let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool)); builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target)); let mut duplicates = Vec::new(); - let is_expected = compile::stream_cargo(builder, &mut cargo, vec![], &mut |msg| { + let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| { // Only care about big things like the RLS/Cargo for now match tool { | "rls" diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 238e79dfd22e1..98cf20a7ba7f4 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -132,6 +132,10 @@ fn main() { continue; } + if flag.starts_with("-flto") { + continue; + } + // -Wdate-time is not supported by the netbsd cross compiler if is_crossed && target.contains("netbsd") && flag.contains("date-time") { continue; From a175969b293ccb9db3aefbe2cc1656a816295025 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 18 Dec 2018 13:01:23 -0800 Subject: [PATCH 52/58] Avoid using open_global_now --- src/librustc_driver/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index e9f309373008b..62f4895354fd0 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -207,7 +207,7 @@ fn load_backend_from_dylib(path: &Path) -> fn() -> Box { // available for future dynamic libraries opened. This is currently used by // loading LLVM and then making its symbols available for other dynamic // libraries. - let lib = DynamicLibrary::open_global_now(path).unwrap_or_else(|err| { + let lib = DynamicLibrary::open(Some(path)).unwrap_or_else(|err| { let err = format!("couldn't load codegen backend {:?}: {:?}", path, err); early_error(ErrorOutputType::default(), &err); }); From 82a1bb331438f0a1432f13a08cb431475dab9907 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 18 Dec 2018 19:03:12 -0800 Subject: [PATCH 53/58] Remove no longer working test --- src/test/run-make-fulldeps/llvm-pass/Makefile | 28 ----------- .../llvm-pass/llvm-function-pass.so.cc | 46 ------------------- .../llvm-pass/llvm-module-pass.so.cc | 45 ------------------ src/test/run-make-fulldeps/llvm-pass/main.rs | 4 -- .../run-make-fulldeps/llvm-pass/plugin.rs | 18 -------- 5 files changed, 141 deletions(-) delete mode 100644 src/test/run-make-fulldeps/llvm-pass/Makefile delete mode 100644 src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc delete mode 100644 src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc delete mode 100644 src/test/run-make-fulldeps/llvm-pass/main.rs delete mode 100644 src/test/run-make-fulldeps/llvm-pass/plugin.rs diff --git a/src/test/run-make-fulldeps/llvm-pass/Makefile b/src/test/run-make-fulldeps/llvm-pass/Makefile deleted file mode 100644 index 8a18aadf36a8b..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/Makefile +++ /dev/null @@ -1,28 +0,0 @@ --include ../tools.mk - -ifeq ($(UNAME),Darwin) -PLUGIN_FLAGS := -C link-args=-Wl,-undefined,dynamic_lookup -endif - -ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) -# ignore stage1 -all: - -else -# Windows doesn't correctly handle include statements with escaping paths, -# so this test will not get run on Windows. -ifdef IS_WINDOWS -all: -else -all: $(call NATIVE_STATICLIB,llvm-function-pass) $(call NATIVE_STATICLIB,llvm-module-pass) - $(RUSTC) plugin.rs -C prefer-dynamic $(PLUGIN_FLAGS) - $(RUSTC) main.rs - -$(TMPDIR)/libllvm-function-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-function-pass.so.cc -o $(TMPDIR)/libllvm-function-pass.o - -$(TMPDIR)/libllvm-module-pass.o: - $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o -endif - -endif diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc deleted file mode 100644 index 267c68853ac43..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/llvm-function-pass.so.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include - -#include "llvm/Pass.h" -#include "llvm/IR/Function.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public FunctionPass { - - public: - - static char ID; - TestLLVMPass() : FunctionPass(ID) { } - - bool runOnFunction(Function &F) override; - - StringRef getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnFunction(Function &F) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto N = F.begin(); N != F.end(); ++N) { - /* code */ - } - - LLVMContext &C = F.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-function-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc b/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc deleted file mode 100644 index b3ee0c1a6c10b..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/llvm-module-pass.so.cc +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -#include - -#include "llvm/IR/Module.h" - -using namespace llvm; - -namespace { - - class TestLLVMPass : public ModulePass { - - public: - - static char ID; - TestLLVMPass() : ModulePass(ID) { } - - bool runOnModule(Module &M) override; - - StringRef getPassName() const override { - return "Some LLVM pass"; - } - - }; - -} - -bool TestLLVMPass::runOnModule(Module &M) { - // A couple examples of operations that previously caused segmentation faults - // https://github.com/rust-lang/rust/issues/31067 - - for (auto F = M.begin(); F != M.end(); ++F) { - /* code */ - } - - LLVMContext &C = M.getContext(); - IntegerType *Int8Ty = IntegerType::getInt8Ty(C); - PointerType::get(Int8Ty, 0); - return true; -} - -char TestLLVMPass::ID = 0; - -static RegisterPass RegisterAFLPass( - "some-llvm-module-pass", "Some LLVM pass"); diff --git a/src/test/run-make-fulldeps/llvm-pass/main.rs b/src/test/run-make-fulldeps/llvm-pass/main.rs deleted file mode 100644 index 0c13b890c6e3a..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/main.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(plugin)] -#![plugin(some_plugin)] - -fn main() {} diff --git a/src/test/run-make-fulldeps/llvm-pass/plugin.rs b/src/test/run-make-fulldeps/llvm-pass/plugin.rs deleted file mode 100644 index f0e4800046cf4..0000000000000 --- a/src/test/run-make-fulldeps/llvm-pass/plugin.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(plugin_registrar, rustc_private)] -#![crate_type = "dylib"] -#![crate_name = "some_plugin"] - -extern crate rustc; -extern crate rustc_plugin; - -#[link(name = "llvm-function-pass", kind = "static")] -#[link(name = "llvm-module-pass", kind = "static")] -extern {} - -use rustc_plugin::registry::Registry; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_llvm_pass("some-llvm-function-pass"); - reg.register_llvm_pass("some-llvm-module-pass"); -} From fa4f014110fdd111742d75f7976ffc754f7720da Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 18 Dec 2018 20:33:10 -0800 Subject: [PATCH 54/58] Remove now stray comment --- src/librustc_driver/lib.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 62f4895354fd0..1ec14fbb06c79 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -200,13 +200,6 @@ pub fn run(run_compiler: F) -> isize } fn load_backend_from_dylib(path: &Path) -> fn() -> Box { - // Note that we're specifically using `open_global_now` here rather than - // `open`, namely we want the behavior on Unix of RTLD_GLOBAL and RTLD_NOW, - // where NOW means "bind everything right now" because we don't want - // surprises later on and RTLD_GLOBAL allows the symbols to be made - // available for future dynamic libraries opened. This is currently used by - // loading LLVM and then making its symbols available for other dynamic - // libraries. let lib = DynamicLibrary::open(Some(path)).unwrap_or_else(|err| { let err = format!("couldn't load codegen backend {:?}: {:?}", path, err); early_error(ErrorOutputType::default(), &err); From c0662a033e53106465c75b44adfa6a14304ea1ac Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 Jan 2019 09:52:46 -0800 Subject: [PATCH 55/58] Update the stdsimd submodule Add a new cmpxchg16b intrinsics for x86_64! --- src/libcore/lib.rs | 1 + src/stdsimd | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 5ea765d3585a2..19bf4ab15bfc4 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -110,6 +110,7 @@ #![feature(aarch64_target_feature)] #![feature(wasm_target_feature)] #![feature(avx512_target_feature)] +#![cfg_attr(not(stage0), feature(cmpxchg16b_target_feature))] #![feature(const_slice_len)] #![feature(const_str_as_bytes)] #![feature(const_str_len)] diff --git a/src/stdsimd b/src/stdsimd index 513e067908f3e..ddb30221d7985 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 513e067908f3e2eb8b31ad1c12b2e0a62817e557 +Subproject commit ddb30221d7985e813b4214d14c2a560ed6ee0991 From 71fed3a8ab479ec46d9fd9a7c5c8f4ffb97786dc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 Jan 2019 13:07:26 -0800 Subject: [PATCH 56/58] Don't package up libLLVM.so with libstd It's only meant for rustc, so we should only install it once! --- src/bootstrap/dist.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 97a359639cb83..38869bf441a82 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -671,10 +671,18 @@ impl Step for Std { let mut src = builder.sysroot_libdir(compiler, target).to_path_buf(); src.pop(); // Remove the trailing /lib folder from the sysroot_libdir builder.cp_filtered(&src, &dst, &|path| { - let name = path.file_name().and_then(|s| s.to_str()); - name != Some(builder.config.rust_codegen_backends_dir.as_str()) && - name != Some("bin") - + if let Some(name) = path.file_name().and_then(|s| s.to_str()) { + if name == builder.config.rust_codegen_backends_dir.as_str() { + return false + } + if name == "bin" { + return false + } + if name.contains("LLVM") { + return false + } + } + true }); let mut cmd = rust_installer(builder); From a944ecfa15c3c3918aa41552d38043d6c22af3a0 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Wed, 2 Jan 2019 18:06:49 -0800 Subject: [PATCH 57/58] Fix 'be be' constructs I noticed a duplicated "be" somewhere in the code. A search for it manifested a couple more locations with the same problem. This change removes one of the "be"s. --- src/librustc/lint/levels.rs | 4 ++-- src/librustc/ty/query/plumbing.rs | 2 +- src/librustc_typeck/check/closure.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 1ae12fec50661..fe113494316b4 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -173,8 +173,8 @@ impl<'a> LintLevelsBuilder<'a> { /// Pushes a list of AST lint attributes onto this context. /// - /// This function will return a `BuilderPush` object which should be be - /// passed to `pop` when this scope for the attributes provided is exited. + /// This function will return a `BuilderPush` object which should be passed + /// to `pop` when this scope for the attributes provided is exited. /// /// This function will perform a number of tasks: /// diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 6887f480f72e0..2f23f1e30295b 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -974,7 +974,7 @@ macro_rules! define_queries_inner { // HACK(eddyb) it's possible crates may be loaded after // the query engine is created, and because crate loading // is not yet integrated with the query engine, such crates - // would be be missing appropriate entries in `providers`. + // would be missing appropriate entries in `providers`. .unwrap_or(&tcx.queries.fallback_extern_providers) .$name; provider(tcx.global_tcx(), key) diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 25b1c0836c28b..5b2550713dbcb 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -494,7 +494,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.infcx.commit_if_ok(|_| { let mut all_obligations = vec![]; - // The liberated version of this signature should be be a subtype + // The liberated version of this signature should be a subtype // of the liberated form of the expectation. for ((hir_ty, &supplied_ty), expected_ty) in decl.inputs.iter() .zip(*supplied_sig.inputs().skip_binder()) // binder moved to (*) below From 32118a9f1acce6407464c3b52cce95b7cb4261c9 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Thu, 3 Jan 2019 13:25:49 +0100 Subject: [PATCH 58/58] More test deduplication --- .../auxiliary/re_rebalance_coherence_lib.rs | 0 .../coherence/coherence-bigint-int.rs | 3 ++ .../coherence/coherence-bigint-vecint.rs | 3 ++ .../run-pass/coherence/coherence-blanket.rs | 3 ++ .../coherence-covered-type-parameter.rs | 3 ++ .../coherence/coherence-impl-in-fn.rs | 3 ++ .../coherence-iterator-vec-any-elem.rs | 3 ++ .../coherence/coherence-iterator-vec.rs | 3 ++ .../coherence-multidispatch-tuple.rs | 3 ++ .../coherence-negative-impls-safe.rs | 3 ++ .../coherence/coherence-rfc447-constrained.rs | 3 ++ .../run-pass/coherence/coherence-subtyping.rs | 3 ++ .../coherence/coherence-where-clause.rs | 4 ++ .../run-pass/coherence/coherence_copy_like.rs | 3 ++ .../re-rebalance-coherence.rs | 1 + .../auxiliary/coherence_copy_like_lib.rs | 20 -------- .../auxiliary/coherence_lib.rs | 25 --------- .../coherence-bigint-int.rs | 25 --------- .../coherence-bigint-vecint.rs | 25 --------- .../coherence-blanket.rs | 27 ---------- .../coherence-covered-type-parameter.rs | 25 --------- .../coherence-impl-in-fn.rs | 25 --------- .../coherence-iterator-vec-any-elem.rs | 25 --------- .../coherence-iterator-vec.rs | 25 --------- .../coherence-multidispatch-tuple.rs | 35 ------------- .../coherence-negative-impls-safe.rs | 24 --------- .../coherence-rfc447-constrained.rs | 34 ------------- .../coherence-subtyping.rs | 51 ------------------- .../coherence-where-clause.rs | 49 ------------------ .../coherence_copy_like.rs | 31 ----------- 30 files changed, 41 insertions(+), 446 deletions(-) rename src/test/run-pass/{re_rebalance_coherence => coherence}/auxiliary/re_rebalance_coherence_lib.rs (100%) rename src/test/run-pass/{re_rebalance_coherence => coherence}/re-rebalance-coherence.rs (93%) delete mode 100644 src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs delete mode 100644 src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs diff --git a/src/test/run-pass/re_rebalance_coherence/auxiliary/re_rebalance_coherence_lib.rs b/src/test/run-pass/coherence/auxiliary/re_rebalance_coherence_lib.rs similarity index 100% rename from src/test/run-pass/re_rebalance_coherence/auxiliary/re_rebalance_coherence_lib.rs rename to src/test/run-pass/coherence/auxiliary/re_rebalance_coherence_lib.rs diff --git a/src/test/run-pass/coherence/coherence-bigint-int.rs b/src/test/run-pass/coherence/coherence-bigint-int.rs index 02945e9dade3a..0c9abdc15e620 100644 --- a/src/test/run-pass/coherence/coherence-bigint-int.rs +++ b/src/test/run-pass/coherence/coherence-bigint-int.rs @@ -1,5 +1,8 @@ // run-pass // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-bigint-vecint.rs b/src/test/run-pass/coherence/coherence-bigint-vecint.rs index a5dba90be5c59..38e0be0aa9ab9 100644 --- a/src/test/run-pass/coherence/coherence-bigint-vecint.rs +++ b/src/test/run-pass/coherence/coherence-bigint-vecint.rs @@ -1,5 +1,8 @@ // run-pass // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-blanket.rs b/src/test/run-pass/coherence/coherence-blanket.rs index 55fa89d75070a..5d310cc2c6ac5 100644 --- a/src/test/run-pass/coherence/coherence-blanket.rs +++ b/src/test/run-pass/coherence/coherence-blanket.rs @@ -1,6 +1,9 @@ // run-pass #![allow(unused_imports)] // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-covered-type-parameter.rs b/src/test/run-pass/coherence/coherence-covered-type-parameter.rs index bb95c59d183f9..1cf039f0831f5 100644 --- a/src/test/run-pass/coherence/coherence-covered-type-parameter.rs +++ b/src/test/run-pass/coherence/coherence-covered-type-parameter.rs @@ -1,6 +1,9 @@ // run-pass #![allow(dead_code)] // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-impl-in-fn.rs b/src/test/run-pass/coherence/coherence-impl-in-fn.rs index b97197317488c..09e2c1e5a4edd 100644 --- a/src/test/run-pass/coherence/coherence-impl-in-fn.rs +++ b/src/test/run-pass/coherence/coherence-impl-in-fn.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] #![allow(non_camel_case_types)] diff --git a/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs b/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs index 43a0a5c427774..051cc280b2d12 100644 --- a/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs +++ b/src/test/run-pass/coherence/coherence-iterator-vec-any-elem.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // aux-build:coherence_lib.rs diff --git a/src/test/run-pass/coherence/coherence-iterator-vec.rs b/src/test/run-pass/coherence/coherence-iterator-vec.rs index 386fe40ac3ca8..df6e808f7dec5 100644 --- a/src/test/run-pass/coherence/coherence-iterator-vec.rs +++ b/src/test/run-pass/coherence/coherence-iterator-vec.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // aux-build:coherence_lib.rs diff --git a/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs b/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs index fa1d4bbb49665..6a816664c4832 100644 --- a/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs +++ b/src/test/run-pass/coherence/coherence-multidispatch-tuple.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(unused_imports)] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-negative-impls-safe.rs b/src/test/run-pass/coherence/coherence-negative-impls-safe.rs index 695a71cbd2d7c..98b04489ac4de 100644 --- a/src/test/run-pass/coherence/coherence-negative-impls-safe.rs +++ b/src/test/run-pass/coherence/coherence-negative-impls-safe.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/coherence/coherence-rfc447-constrained.rs b/src/test/run-pass/coherence/coherence-rfc447-constrained.rs index 9d1d86883259f..4da54d386fd35 100644 --- a/src/test/run-pass/coherence/coherence-rfc447-constrained.rs +++ b/src/test/run-pass/coherence/coherence-rfc447-constrained.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // check that trait matching can handle impls whose types are only // constrained by a projection. diff --git a/src/test/run-pass/coherence/coherence-subtyping.rs b/src/test/run-pass/coherence/coherence-subtyping.rs index b7aa57b5c31f7..1baecad71752c 100644 --- a/src/test/run-pass/coherence/coherence-subtyping.rs +++ b/src/test/run-pass/coherence/coherence-subtyping.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] // Test that two distinct impls which match subtypes of one another // yield coherence errors (or not) depending on the variance. diff --git a/src/test/run-pass/coherence/coherence-where-clause.rs b/src/test/run-pass/coherence/coherence-where-clause.rs index 9f8a1b9bd1671..283974203858d 100644 --- a/src/test/run-pass/coherence/coherence-where-clause.rs +++ b/src/test/run-pass/coherence/coherence-where-clause.rs @@ -1,4 +1,8 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; diff --git a/src/test/run-pass/coherence/coherence_copy_like.rs b/src/test/run-pass/coherence/coherence_copy_like.rs index 92af341ccb529..653f76264c110 100644 --- a/src/test/run-pass/coherence/coherence_copy_like.rs +++ b/src/test/run-pass/coherence/coherence_copy_like.rs @@ -1,4 +1,7 @@ // run-pass +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![allow(dead_code)] // Test that we are able to introduce a negative constraint that // `MyType: !MyTrait` along with other "fundamental" wrappers. diff --git a/src/test/run-pass/re_rebalance_coherence/re-rebalance-coherence.rs b/src/test/run-pass/coherence/re-rebalance-coherence.rs similarity index 93% rename from src/test/run-pass/re_rebalance_coherence/re-rebalance-coherence.rs rename to src/test/run-pass/coherence/re-rebalance-coherence.rs index 33ad4e9753661..bacd3b89fad29 100644 --- a/src/test/run-pass/re_rebalance_coherence/re-rebalance-coherence.rs +++ b/src/test/run-pass/coherence/re-rebalance-coherence.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] #![feature(re_rebalance_coherence)] // run-pass diff --git a/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs b/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs deleted file mode 100644 index d3d389c6a8bd5..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rlib"] -#![feature(fundamental)] - -pub trait MyCopy { } -impl MyCopy for i32 { } - -pub struct MyStruct(T); - -#[fundamental] -pub struct MyFundamentalStruct(T); diff --git a/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs b/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs deleted file mode 100644 index daa123849e4e7..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/auxiliary/coherence_lib.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type="lib"] - -pub trait Remote { - fn foo(&self) { } -} - -pub trait Remote1 { - fn foo(&self, t: T) { } -} - -pub trait Remote2 { - fn foo(&self, t: T, u: U) { } -} - -pub struct Pair(T,U); diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs b/src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs deleted file mode 100644 index c436901a34f08..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-bigint-int.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub struct BigInt; - -impl Remote1 for isize { } - -fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs b/src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs deleted file mode 100644 index 67fb9d1d335cb..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-bigint-vecint.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// run-pass -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub struct BigInt; - -impl Remote1 for Vec { } - -fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs b/src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs deleted file mode 100644 index 7f8f27f39b1b1..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-blanket.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_imports)] -#![feature(re_rebalance_coherence)] -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -pub trait Local { - fn foo(&self) { } -} - -impl Local for T { } - -fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs b/src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs deleted file mode 100644 index 5e0d61884f917..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-covered-type-parameter.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote; - -struct Foo(T); - -impl Remote for Foo { } - -fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs b/src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs deleted file mode 100644 index 2f8cbc032f2fb..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-impl-in-fn.rs +++ /dev/null @@ -1,25 +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. - -// run-pass -#![allow(dead_code)] -#![allow(non_camel_case_types)] -#![feature(re_rebalance_coherence)] - -pub fn main() { - #[derive(Copy, Clone)] - enum x { foo } - impl ::std::cmp::PartialEq for x { - fn eq(&self, other: &x) -> bool { - (*self) as isize == (*other) as isize - } - fn ne(&self, other: &x) -> bool { !(*self).eq(other) } - } -} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs b/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs deleted file mode 100644 index b19bede744106..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec-any-elem.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -struct Foo(T); - -impl Remote1 for Foo { } - -fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs b/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs deleted file mode 100644 index 5ce71f5d42273..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-iterator-vec.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] -// aux-build:coherence_lib.rs - -// pretty-expanded FIXME #23616 - -extern crate coherence_lib as lib; -use lib::Remote1; - -struct Foo(T); - -impl Remote1 for Foo { } - -fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs b/src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs deleted file mode 100644 index 6dc1da3376b15..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-multidispatch-tuple.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(unused_imports)] -#![feature(re_rebalance_coherence)] -// pretty-expanded FIXME #23616 - -use std::fmt::Debug; -use std::default::Default; - -// Test that an impl for homogeneous pairs does not conflict with a -// heterogeneous pair. - -trait MyTrait { - fn get(&self) -> usize; -} - -impl MyTrait for (T,T) { - fn get(&self) -> usize { 0 } -} - -impl MyTrait for (usize,isize) { - fn get(&self) -> usize { 0 } -} - -fn main() { -} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs b/src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs deleted file mode 100644 index 5e1a0e39e234e..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-negative-impls-safe.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] -// pretty-expanded FIXME #23616 - -#![feature(optin_builtin_traits)] -#![feature(re_rebalance_coherence)] - -use std::marker::Send; - -struct TestType; - -impl !Send for TestType {} - -fn main() {} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs b/src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs deleted file mode 100644 index 651e595bde120..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-rfc447-constrained.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// run-pass -// check that trait matching can handle impls whose types are only -// constrained by a projection. - -trait IsU32 {} -impl IsU32 for u32 {} - -trait Mirror { type Image: ?Sized; } -impl Mirror for T { type Image = T; } - -trait Bar {} -impl, L: Mirror> Bar for V - where U::Image: IsU32 {} - -trait Foo { fn name() -> &'static str; } -impl Foo for u64 { fn name() -> &'static str { "u64" } } -impl Foo for T { fn name() -> &'static str { "Bar" }} - -fn main() { - assert_eq!(::name(), "u64"); - assert_eq!(::name(), "Bar"); -} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs b/src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs deleted file mode 100644 index d9a9f580cfaf6..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-subtyping.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// run-pass -// Test that two distinct impls which match subtypes of one another -// yield coherence errors (or not) depending on the variance. - -trait Contravariant { - fn foo(&self) { } -} - -impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { -} - -impl Contravariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { -} - -/////////////////////////////////////////////////////////////////////////// - -trait Covariant { - fn foo(&self) { } -} - -impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { -} - -impl Covariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { -} - -/////////////////////////////////////////////////////////////////////////// - -trait Invariant { - fn foo(&self) { } -} - -impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) -> &'a u8 { -} - -impl Invariant for for<'a> fn(&'a u8, &'a u8) -> &'a u8 { -} - -fn main() { } diff --git a/src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs b/src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs deleted file mode 100644 index a7d3602a3cc6b..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence-where-clause.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(re_rebalance_coherence)] - -// run-pass -use std::fmt::Debug; -use std::default::Default; - -trait MyTrait { - fn get(&self) -> Self; -} - -impl MyTrait for T - where T : Default -{ - fn get(&self) -> T { - Default::default() - } -} - -#[derive(Clone, Copy, Debug, PartialEq)] -struct MyType { - dummy: usize -} - -impl MyTrait for MyType { - fn get(&self) -> MyType { (*self).clone() } -} - -fn test_eq(m: M, n: M) -where M : MyTrait + Debug + PartialEq -{ - assert_eq!(m.get(), n); -} - -pub fn main() { - test_eq(0_usize, 0_usize); - - let value = MyType { dummy: 256 + 22 }; - test_eq(value, value); -} diff --git a/src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs b/src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs deleted file mode 100644 index 221095b148e0c..0000000000000 --- a/src/test/run-pass/re_rebalance_coherence/coherence_copy_like.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -#![allow(dead_code)] -#![feature(re_rebalance_coherence)] - -// Test that we are able to introduce a negative constraint that -// `MyType: !MyTrait` along with other "fundamental" wrappers. - -// aux-build:coherence_copy_like_lib.rs - -extern crate coherence_copy_like_lib as lib; - -struct MyType { x: i32 } - -trait MyTrait { } -impl MyTrait for T { } -impl MyTrait for MyType { } -impl<'a> MyTrait for &'a MyType { } -impl MyTrait for Box { } -impl<'a> MyTrait for &'a Box { } - -fn main() { }

{} + +pub trait Bar { + type Output: 'static; +} + +impl Foo for i32 { } + +impl Foo for A { } + +impl Bar for i32 { + type Output = u32; +} + + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs b/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs new file mode 100644 index 0000000000000..c6dda7f277316 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +use std::fmt::Debug; +use std::default::Default; + +// Test that a blank impl for all T conflicts with an impl for some +// specific T. + +trait MyTrait { + fn get(&self) -> usize; +} + +impl MyTrait for (T,T) { + fn get(&self) -> usize { 0 } +} + +impl MyTrait for (A,B) { //~ ERROR E0119 + fn get(&self) -> usize { self.dummy } +} + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr b/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr new file mode 100644 index 0000000000000..bd4f2908cdfe7 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(_, _)`: + --> $DIR/coherence-tuple-conflict.rs:27:1 + | +LL | impl MyTrait for (T,T) { + | ------------------------- first implementation here +... +LL | impl MyTrait for (A,B) { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs b/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs new file mode 100644 index 0000000000000..6849f004c635d --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that a local, generic type appearing within a +// *non-fundamental* remote type like `Vec` is not considered local. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Local(T); + +impl Remote for Vec> { } //~ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr b/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr new file mode 100644 index 0000000000000..d507edbb0bde9 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-vec-local-2.rs:23:1 + | +LL | impl Remote for Vec> { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local.rs b/src/test/ui/re_rebalance_coherence/coherence-vec-local.rs new file mode 100644 index 0000000000000..24a00febfd8f4 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-vec-local.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that a local type (with no type parameters) appearing within a +// *non-fundamental* remote type like `Vec` is not considered local. + +// aux-build:coherence_lib.rs + +extern crate coherence_lib as lib; +use lib::Remote; + +struct Local; + +impl Remote for Vec { } //~ ERROR E0117 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr b/src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr new file mode 100644 index 0000000000000..fc400da711551 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence-vec-local.rs:23:1 + | +LL | impl Remote for Vec { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs new file mode 100644 index 0000000000000..5e09cf69a61af --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs +// compile-pass +// skip-codgen +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// `MyFundamentalStruct` is declared fundamental, so we can test that +// +// MyFundamentalStruct: !MyTrait +// +// Huzzah. +impl MyTrait for lib::MyFundamentalStruct { } + + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs new file mode 100644 index 0000000000000..8e5d2bf4cf7b6 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs @@ -0,0 +1,35 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs +// compile-pass +// skip-codegen +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// `MyFundamentalStruct` is declared fundamental, so we can test that +// +// MyFundamentalStruct<&MyTrait>: !MyTrait +// +// Huzzah. +impl<'a> MyTrait for lib::MyFundamentalStruct<&'a MyType> { } + + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs new file mode 100644 index 0000000000000..e7a8edbd22147 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + + + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } + +impl MyTrait for T { } + +// Tuples are not fundamental. +impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 + + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr new file mode 100644 index 0000000000000..e6adc08c28c37 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyFundamentalStruct<(MyType,)>`: + --> $DIR/coherence_copy_like_err_fundamental_struct_tuple.rs:29:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyFundamentalStruct<(MyType,)> { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyFundamentalStruct<(MyType,)>` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyFundamentalStruct<(MyType,)>` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs new file mode 100644 index 0000000000000..3f91750104b9a --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs @@ -0,0 +1,33 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// aux-build:coherence_copy_like_lib.rs + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// `MyStruct` is not declared fundamental, therefore this would +// require that +// +// MyStruct: !MyTrait +// +// which we cannot approve. +impl MyTrait for lib::MyStruct { } //~ ERROR E0119 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr new file mode 100644 index 0000000000000..a40ae4fc4488d --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `lib::MyStruct`: + --> $DIR/coherence_copy_like_err_struct.rs:31:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for lib::MyStruct { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `lib::MyStruct` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `lib::MyStruct` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs new file mode 100644 index 0000000000000..0e7eef6fe6de2 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs @@ -0,0 +1,32 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +trait MyTrait { fn foo() {} } +impl MyTrait for T { } + +// Tuples are not fundamental, therefore this would require that +// +// (MyType,): !MyTrait +// +// which we cannot approve. +impl MyTrait for (MyType,) { } //~ ERROR E0119 + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr new file mode 100644 index 0000000000000..82e43f6d721eb --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr @@ -0,0 +1,14 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `(MyType,)`: + --> $DIR/coherence_copy_like_err_tuple.rs:30:1 + | +LL | impl MyTrait for T { } + | ---------------------------------- first implementation here +... +LL | impl MyTrait for (MyType,) { } //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(MyType,)` + | + = note: upstream crates may add new impl of trait `lib::MyCopy` for type `(MyType,)` in future versions + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent.rs b/src/test/ui/re_rebalance_coherence/coherence_inherent.rs new file mode 100644 index 0000000000000..d4d29326e4f78 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_inherent.rs @@ -0,0 +1,47 @@ +// 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. + +#![feature(re_rebalance_coherence)] + +// Tests that methods that implement a trait cannot be invoked +// unless the trait is imported. + +mod Lib { + pub trait TheTrait { + fn the_fn(&self); + } + + pub struct TheStruct; + + impl TheTrait for TheStruct { + fn the_fn(&self) {} + } +} + +mod Import { + // Trait is in scope here: + use Lib::TheStruct; + use Lib::TheTrait; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); + } +} + +mod NoImport { + // Trait is not in scope here: + use Lib::TheStruct; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); //~ ERROR no method named `the_fn` found + } +} + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent.stderr b/src/test/ui/re_rebalance_coherence/coherence_inherent.stderr new file mode 100644 index 0000000000000..9294899bfee54 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_inherent.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&Lib::TheStruct` in the current scope + --> $DIR/coherence_inherent.rs:43:11 + | +LL | s.the_fn(); //~ ERROR no method named `the_fn` found + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use Lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs b/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs new file mode 100644 index 0000000000000..beb60f57a2a2c --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs @@ -0,0 +1,39 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(re_rebalance_coherence)] + +// aux-build:coherence_inherent_cc_lib.rs + +// Tests that methods that implement a trait cannot be invoked +// unless the trait is imported. + +extern crate coherence_inherent_cc_lib; + +mod Import { + // Trait is in scope here: + use coherence_inherent_cc_lib::TheStruct; + use coherence_inherent_cc_lib::TheTrait; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); + } +} + +mod NoImport { + // Trait is not in scope here: + use coherence_inherent_cc_lib::TheStruct; + + fn call_the_fn(s: &TheStruct) { + s.the_fn(); //~ ERROR no method named `the_fn` found + } +} + +fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr b/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr new file mode 100644 index 0000000000000..bf67313879b7e --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `the_fn` found for type `&coherence_inherent_cc_lib::TheStruct` in the current scope + --> $DIR/coherence_inherent_cc.rs:35:11 + | +LL | s.the_fn(); //~ ERROR no method named `the_fn` found + | ^^^^^^ + | + = help: items from traits can only be used if the trait is in scope + = note: the following trait is implemented but not in scope, perhaps add a `use` for it: + `use coherence_inherent_cc_lib::TheTrait;` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_local.rs b/src/test/ui/re_rebalance_coherence/coherence_local.rs new file mode 100644 index 0000000000000..7f72ff7af8887 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_local.rs @@ -0,0 +1,34 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs +// compile-pass +// skip-codegen +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// These are all legal because they are all fundamental types: + +impl lib::MyCopy for MyType { } +impl<'a> lib::MyCopy for &'a MyType { } +impl<'a> lib::MyCopy for &'a Box { } +impl lib::MyCopy for Box { } +impl lib::MyCopy for lib::MyFundamentalStruct { } +impl lib::MyCopy for lib::MyFundamentalStruct> { } + + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs b/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs new file mode 100644 index 0000000000000..3d7145e489d18 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(re_rebalance_coherence)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// These are all legal because they are all fundamental types: + +// MyStruct is not fundamental. +impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 + + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr b/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr new file mode 100644 index 0000000000000..c35e95040de15 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_struct.rs:26:1 + | +LL | impl lib::MyCopy for lib::MyStruct { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs b/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs new file mode 100644 index 0000000000000..f2c9008dd8ca9 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs @@ -0,0 +1,29 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs + +#![feature(re_rebalance_coherence)] +#![allow(dead_code)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// These are all legal because they are all fundamental types: + +// Tuples are not fundamental, so this is not a local impl. +impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 + + +fn main() { } diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr b/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr new file mode 100644 index 0000000000000..a3f9f2d32b8f9 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr @@ -0,0 +1,12 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence_local_err_tuple.rs:26:1 + | +LL | impl lib::MyCopy for (MyType,) { } //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/src/test/ui/re_rebalance_coherence/coherence_local_ref.rs b/src/test/ui/re_rebalance_coherence/coherence_local_ref.rs new file mode 100644 index 0000000000000..b15a5cc245bf4 --- /dev/null +++ b/src/test/ui/re_rebalance_coherence/coherence_local_ref.rs @@ -0,0 +1,28 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that we are able to introduce a negative constraint that +// `MyType: !MyTrait` along with other "fundamental" wrappers. + +// aux-build:coherence_copy_like_lib.rs +// compile-pass +// skip-codegen +#![allow(dead_code)] +#![feature(re_rebalance_coherence)] + +extern crate coherence_copy_like_lib as lib; + +struct MyType { x: i32 } + +// naturally, legal +impl lib::MyCopy for MyType { } + + +fn main() { } From e869e5f58abbaabacc3348341ac300aee627eb8f Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Wed, 21 Nov 2018 21:37:09 +0100 Subject: [PATCH 17/58] Add some docs about the new feature to the unstable book --- .../re-rebalance-coherence.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/doc/unstable-book/src/language-features/re-rebalance-coherence.md diff --git a/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md b/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md new file mode 100644 index 0000000000000..608f0ed86f0d4 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md @@ -0,0 +1,23 @@ +# `re_rebalance_coherence` + +The tracking issue for this feature is: [#55437] + +[#55437]: https://github.com/rust-lang/rust/issues/55437 + +------------------------ + +The `re_rebalance_coherence` feature tweaks the rules which trait +impls are allowed in crates. +The following rule is used: + +Given `impl Trait for T0`, an impl is valid only if at +least one of the following is true: +- `Trait` is a local trait +- All of + - At least one of the types `T0..=Tn` must be a local type. Let `Ti` be the + first such type. + - No uncovered type parameters `P1..=Pn` may appear in `T0..Ti` (excluding + `Ti`) + + +See the [RFC](https://github.com/rust-lang/rfcs/blob/master/text/2451-re-rebalancing-coherence.md) for details. From cae96b1789ffa01674a46ff051b966c4f6e03892 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Thu, 22 Nov 2018 00:14:35 +0100 Subject: [PATCH 18/58] Fix tidy --- src/librustc/traits/coherence.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index e7636f5b3e0a3..3b19c63b1cf1e 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -369,10 +369,10 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, debug!("orphan_check_trait_ref: no local type"); Err(OrphanCheckErr::NoLocalInputType) } else { - // First, create an ordered iterator over all the type parameters to the trait, with the self - // type appearing first. - // Find the first input type that either references a type parameter OR - // some local type. + // First, create an ordered iterator over all the type + // parameters to the trait, with the self type appearing + // first. Find the first input type that either references a + // type parameter OR some local type. for input_ty in trait_ref.input_types() { if ty_is_local(tcx, input_ty, in_crate) { debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); From eee09d5ba7652f01d79b76130ff4fcb1976c5745 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 22 Nov 2018 22:00:19 +0000 Subject: [PATCH 19/58] Update src/doc/unstable-book/src/language-features/re-rebalance-coherence.md Co-Authored-By: weiznich --- .../src/language-features/re-rebalance-coherence.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md b/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md index 608f0ed86f0d4..1e74652a890f6 100644 --- a/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md +++ b/src/doc/unstable-book/src/language-features/re-rebalance-coherence.md @@ -6,7 +6,7 @@ The tracking issue for this feature is: [#55437] ------------------------ -The `re_rebalance_coherence` feature tweaks the rules which trait +The `re_rebalance_coherence` feature tweaks the rules regarding which trait impls are allowed in crates. The following rule is used: From 6912b2d572d24889bb7f7e9c779b058186e3c06d Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 23 Nov 2018 10:45:17 +0100 Subject: [PATCH 20/58] Directly check if input_ty is a type parameter and therefore a uncoverd type --- src/librustc/traits/coherence.rs | 42 +------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 3b19c63b1cf1e..2050dbc91c93e 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -360,7 +360,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, if ty_is_local(tcx, input_ty, in_crate) { debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); return Ok(()); - } else if is_uncovered_ty(input_ty) { + } else if let ty::Param(_) = input_ty.sty { debug!("orphan_check_trait_ref: uncovered ty: `{:?}`", input_ty); return Err(OrphanCheckErr::UncoveredTy(input_ty)) } @@ -408,46 +408,6 @@ fn orphan_check_trait_ref<'tcx>(tcx: TyCtxt<'_, '_, '_>, } } -fn is_uncovered_ty(ty: Ty<'_>) -> bool { - match ty.sty { - ty::Bool | - ty::Char | - ty::Int(..) | - ty::Uint(..) | - ty::Float(..) | - ty::Str | - ty::FnDef(..) | - ty::FnPtr(_) | - ty::Array(..) | - ty::Slice(..) | - ty::RawPtr(..) | - ty::Ref(..) | - ty::Never | - ty::Tuple(..) | - ty::Bound(..) | - ty::Infer(..) | - ty::Adt(..) | - ty::Foreign(..) | - ty::Dynamic(..) | - ty::Error | - ty::Projection(..) => { - false - } - - ty::Param(..) => { - true - } - - ty::UnnormalizedProjection(..) | - ty::Closure(..) | - ty::Generator(..) | - ty::GeneratorWitness(..) | - ty::Opaque(..) => { - bug!("is_uncovered_ty invoked on unexpected type: {:?}", ty) - } - } -} - fn uncovered_tys<'tcx>(tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>, in_crate: InCrate) -> Vec> { if ty_is_local_constructor(ty, in_crate) { From 44089c8c26ec8bb05af29b61d1ea95caf45abd50 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 14 Dec 2018 12:18:29 +0100 Subject: [PATCH 21/58] Fix failing compile tests --- .../ui/feature-gates/feature-gate-re-rebalance-coherence.rs | 2 +- .../coherence-pair-covered-uncovered-1.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs index 7031e6061edd3..c702b92f042a2 100644 --- a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.rs @@ -8,6 +8,6 @@ use lib::*; struct Oracle; impl Backend for Oracle {} impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} -// ~^ ERROR E0210 +//~^ ERROR E0210 fn main() {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs index 4edfd5e122704..002b422f704c5 100644 --- a/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs +++ b/src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs @@ -21,5 +21,6 @@ use lib::{Remote1, Pair}; pub struct Local(T); impl Remote1>> for i32 { } +//~^ ERROR E0117 fn main() { } From ad7d0150224546655b4f2559212004d26db2e73f Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Fri, 14 Dec 2018 15:06:03 +0100 Subject: [PATCH 22/58] Update some new tests to changed error messages --- .../ui/feature-gates/feature-gate-re-rebalance-coherence.stderr | 2 +- src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr | 2 +- .../ui/re_rebalance_coherence/coherence-bigint-param.stderr | 2 +- .../coherence-cross-crate-conflict.stderr | 2 +- .../re_rebalance_coherence/coherence-lone-type-parameter.stderr | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr index 7a79d0b1f2a63..5972e610e47d6 100644 --- a/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr +++ b/src/test/ui/feature-gates/feature-gate-re-rebalance-coherence.stderr @@ -1,4 +1,4 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) --> $DIR/feature-gate-re-rebalance-coherence.rs:10:1 | LL | impl<'a, T:'a, Tab> QueryFragment for BatchInsert<'a, T, Tab> {} diff --git a/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr b/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr index a6d5105cdc0ea..509cee34b233f 100644 --- a/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr +++ b/src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr @@ -1,4 +1,4 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) --> $DIR/coherence-all-remote.rs:18:1 | LL | impl Remote1 for isize { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr index ed1540a303e68..c2f6a15e8e3f7 100644 --- a/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr +++ b/src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr @@ -1,4 +1,4 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) --> $DIR/coherence-bigint-param.rs:20:1 | LL | impl Remote1 for T { } diff --git a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr index e4f8ba9868e4e..cc10ac8f02544 100644 --- a/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr +++ b/src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr @@ -7,7 +7,7 @@ LL | impl Foo for A { = note: conflicting implementation in crate `trait_impl_conflict`: - impl trait_impl_conflict::Foo for isize; -error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g. `MyStruct`) +error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct`) --> $DIR/coherence-cross-crate-conflict.rs:20:1 | LL | impl Foo for A { diff --git a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr index 60ec7fb67defe..403ced3f287c2 100644 --- a/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr +++ b/src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr @@ -1,4 +1,4 @@ -error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g. `MyStruct`) +error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) --> $DIR/coherence-lone-type-parameter.rs:18:1 | LL | impl Remote for T { } From 8a5d45dc528d75211dd61b457d3f1df58bdcc619 Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Sat, 29 Dec 2018 00:11:13 +0100 Subject: [PATCH 23/58] Unify tests Implement compile tests as variants of existing tests --- src/test/ui/coherence/coherence-all-remote.rs | 6 +- .../ui/coherence/coherence-bigint-param.rs | 6 +- ...nket-conflicts-with-blanket-implemented.rs | 9 +- ...et-conflicts-with-blanket-unimplemented.rs | 8 +- ...ket-conflicts-with-specific-cross-crate.rs | 7 +- ...t-conflicts-with-specific-multidispatch.rs | 8 +- ...e-blanket-conflicts-with-specific-trait.rs | 8 +- ...herence-blanket-conflicts-with-specific.rs | 8 +- ...herence-conflicting-negative-trait-impl.rs | 9 +- src/test/ui/coherence/coherence-cow.a.stderr | 4 +- src/test/ui/coherence/coherence-cow.b.stderr | 4 +- src/test/ui/coherence/coherence-cow.c.stderr | 2 +- src/test/ui/coherence/coherence-cow.rs | 19 ++-- .../coherence-cross-crate-conflict.rs | 10 ++- .../coherence/coherence-default-trait-impl.rs | 9 +- .../coherence/coherence-error-suppression.rs | 8 +- ...erence-impl-trait-for-trait-object-safe.rs | 8 +- .../coherence-impl-trait-for-trait.rs | 16 +++- src/test/ui/coherence/coherence-impls-copy.rs | 38 ++++---- src/test/ui/coherence/coherence-impls-send.rs | 15 +++- .../ui/coherence/coherence-impls-sized.rs | 58 ++++++++----- .../coherence-inherited-assoc-ty-cycle-err.rs | 6 +- .../coherence-lone-type-parameter.rs | 7 +- .../coherence-negative-impls-safe.rs | 6 +- .../coherence-no-direct-lifetime-dispatch.rs | 8 +- src/test/ui/coherence/coherence-orphan.rs | 8 +- .../coherence-overlap-all-t-and-tuple.rs | 8 +- .../coherence-overlap-downstream-inherent.rs | 10 ++- .../coherence/coherence-overlap-downstream.rs | 10 ++- .../coherence-overlap-issue-23516-inherent.rs | 7 +- .../coherence-overlap-issue-23516.rs | 7 +- .../coherence/coherence-overlap-messages.rs | 25 ++++-- .../coherence-overlap-upstream-inherent.rs | 7 +- .../coherence/coherence-overlap-upstream.rs | 7 +- .../coherence/coherence-overlapping-pairs.rs | 6 +- .../coherence-pair-covered-uncovered-1.rs | 7 +- .../coherence-pair-covered-uncovered.rs | 6 +- .../coherence-projection-conflict-orphan.rs | 7 +- .../coherence-projection-conflict-ty-param.rs | 8 +- .../coherence-projection-conflict.rs | 8 +- .../coherence-projection-ok-orphan.rs | 3 + .../ui/coherence/coherence-projection-ok.rs | 3 + .../ui/coherence/coherence-tuple-conflict.rs | 8 +- .../ui/coherence/coherence-vec-local-2.rs | 7 +- src/test/ui/coherence/coherence-vec-local.rs | 7 +- ...erence_copy_like_err_fundamental_struct.rs | 3 + ...ce_copy_like_err_fundamental_struct_ref.rs | 3 + ..._copy_like_err_fundamental_struct_tuple.rs | 6 +- .../coherence_copy_like_err_struct.rs | 7 +- .../coherence_copy_like_err_tuple.rs | 7 +- src/test/ui/coherence/coherence_inherent.rs | 8 +- .../ui/coherence/coherence_inherent_cc.rs | 7 +- src/test/ui/coherence/coherence_local.rs | 3 + .../coherence/coherence_local_err_struct.rs | 7 +- .../ui/coherence/coherence_local_err_tuple.rs | 7 +- src/test/ui/coherence/coherence_local_ref.rs | 3 + .../auxiliary/coherence_copy_like_lib.rs | 20 ----- .../auxiliary/coherence_inherent_cc_lib.rs | 21 ----- .../auxiliary/coherence_lib.rs | 25 ------ .../auxiliary/coherence_orphan_lib.rs | 13 --- .../auxiliary/go_trait.rs | 53 ----------- .../auxiliary/trait_impl_conflict.rs | 16 ---- .../coherence-all-remote.rs | 21 ----- .../coherence-all-remote.stderr | 11 --- .../coherence-bigint-param.rs | 23 ----- .../coherence-bigint-param.stderr | 11 --- ...nket-conflicts-with-blanket-implemented.rs | 40 --------- ...-conflicts-with-blanket-implemented.stderr | 12 --- ...et-conflicts-with-blanket-unimplemented.rs | 36 -------- ...onflicts-with-blanket-unimplemented.stderr | 12 --- ...ket-conflicts-with-specific-cross-crate.rs | 31 ------- ...conflicts-with-specific-cross-crate.stderr | 13 --- ...t-conflicts-with-specific-multidispatch.rs | 38 -------- ...nflicts-with-specific-multidispatch.stderr | 12 --- ...e-blanket-conflicts-with-specific-trait.rs | 40 --------- ...anket-conflicts-with-specific-trait.stderr | 12 --- ...herence-blanket-conflicts-with-specific.rs | 35 -------- ...nce-blanket-conflicts-with-specific.stderr | 12 --- ...herence-conflicting-negative-trait-impl.rs | 29 ------- ...nce-conflicting-negative-trait-impl.stderr | 21 ----- .../coherence-cow.a.stderr | 12 --- .../coherence-cow.b.stderr | 12 --- .../coherence-cow.c.stderr | 12 --- .../re_rebalance_coherence/coherence-cow.rs | 37 -------- .../coherence-cross-crate-conflict.rs | 26 ------ .../coherence-cross-crate-conflict.stderr | 21 ----- .../coherence-default-trait-impl.rs | 26 ------ .../coherence-default-trait-impl.stderr | 16 ---- .../coherence-error-suppression.rs | 27 ------ .../coherence-error-suppression.stderr | 9 -- ...erence-impl-trait-for-trait-object-safe.rs | 21 ----- ...ce-impl-trait-for-trait-object-safe.stderr | 11 --- .../coherence-impl-trait-for-trait.rs | 29 ------- .../coherence-impl-trait-for-trait.stderr | 21 ----- .../coherence-impls-copy.rs | 54 ------------ .../coherence-impls-copy.stderr | 87 ------------------- .../coherence-impls-send.rs | 41 --------- .../coherence-impls-send.stderr | 37 -------- .../coherence-impls-sized.rs | 47 ---------- .../coherence-impls-sized.stderr | 67 -------------- .../coherence-inherited-assoc-ty-cycle-err.rs | 35 -------- ...erence-inherited-assoc-ty-cycle-err.stderr | 16 ---- .../coherence-lone-type-parameter.rs | 21 ----- .../coherence-lone-type-parameter.stderr | 11 --- .../coherence-negative-impls-safe.rs | 21 ----- .../coherence-negative-impls-safe.stderr | 9 -- .../coherence-no-direct-lifetime-dispatch.rs | 20 ----- ...herence-no-direct-lifetime-dispatch.stderr | 11 --- .../coherence-orphan.rs | 32 ------- .../coherence-orphan.stderr | 21 ----- .../coherence-overlap-all-t-and-tuple.rs | 31 ------- .../coherence-overlap-all-t-and-tuple.stderr | 12 --- .../coherence-overlap-downstream-inherent.rs | 29 ------- ...herence-overlap-downstream-inherent.stderr | 23 ----- .../coherence-overlap-downstream.rs | 29 ------- .../coherence-overlap-downstream.stderr | 21 ----- .../coherence-overlap-issue-23516-inherent.rs | 25 ------ ...erence-overlap-issue-23516-inherent.stderr | 14 --- .../coherence-overlap-issue-23516.rs | 23 ----- .../coherence-overlap-issue-23516.stderr | 13 --- .../coherence-overlap-messages.rs | 34 -------- .../coherence-overlap-messages.stderr | 44 ---------- .../coherence-overlap-upstream-inherent.rs | 27 ------ ...coherence-overlap-upstream-inherent.stderr | 14 --- .../coherence-overlap-upstream.rs | 27 ------ .../coherence-overlap-upstream.stderr | 13 --- .../coherence-overlapping-pairs.rs | 23 ----- .../coherence-overlapping-pairs.stderr | 12 --- .../coherence-pair-covered-uncovered-1.rs | 26 ------ .../coherence-pair-covered-uncovered-1.stderr | 12 --- .../coherence-pair-covered-uncovered.rs | 23 ----- .../coherence-pair-covered-uncovered.stderr | 12 --- .../coherence-projection-conflict-orphan.rs | 29 ------- ...oherence-projection-conflict-orphan.stderr | 14 --- .../coherence-projection-conflict-ty-param.rs | 24 ----- ...erence-projection-conflict-ty-param.stderr | 12 --- .../coherence-projection-conflict.rs | 29 ------- .../coherence-projection-conflict.stderr | 12 --- .../coherence-projection-ok-orphan.rs | 30 ------- .../coherence-projection-ok.rs | 30 ------- .../coherence-tuple-conflict.rs | 31 ------- .../coherence-tuple-conflict.stderr | 12 --- .../coherence-vec-local-2.rs | 25 ------ .../coherence-vec-local-2.stderr | 12 --- .../coherence-vec-local.rs | 25 ------ .../coherence-vec-local.stderr | 12 --- ...erence_copy_like_err_fundamental_struct.rs | 35 -------- ...ce_copy_like_err_fundamental_struct_ref.rs | 35 -------- ..._copy_like_err_fundamental_struct_tuple.rs | 32 ------- ...y_like_err_fundamental_struct_tuple.stderr | 14 --- .../coherence_copy_like_err_struct.rs | 33 ------- .../coherence_copy_like_err_struct.stderr | 14 --- .../coherence_copy_like_err_tuple.rs | 32 ------- .../coherence_copy_like_err_tuple.stderr | 14 --- .../coherence_inherent.rs | 47 ---------- .../coherence_inherent.stderr | 13 --- .../coherence_inherent_cc.rs | 39 --------- .../coherence_inherent_cc.stderr | 13 --- .../re_rebalance_coherence/coherence_local.rs | 34 -------- .../coherence_local_err_struct.rs | 29 ------- .../coherence_local_err_struct.stderr | 12 --- .../coherence_local_err_tuple.rs | 29 ------- .../coherence_local_err_tuple.stderr | 12 --- .../coherence_local_ref.rs | 28 ------ 164 files changed, 400 insertions(+), 2723 deletions(-) delete mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_copy_like_lib.rs delete mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_inherent_cc_lib.rs delete mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_lib.rs delete mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/coherence_orphan_lib.rs delete mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/go_trait.rs delete mode 100644 src/test/ui/re_rebalance_coherence/auxiliary/trait_impl_conflict.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-all-remote.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-all-remote.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-bigint-param.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-bigint-param.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-implemented.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-blanket-unimplemented.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-cross-crate.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific-trait.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-blanket-conflicts-with-specific.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-conflicting-negative-trait-impl.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.a.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.b.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.c.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-cow.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-cross-crate-conflict.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-default-trait-impl.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-error-suppression.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-error-suppression.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait-object-safe.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impl-trait-for-trait.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-copy.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-copy.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-send.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-send.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-sized.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-impls-sized.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-inherited-assoc-ty-cycle-err.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-lone-type-parameter.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-negative-impls-safe.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-no-direct-lifetime-dispatch.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-orphan.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-orphan.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-all-t-and-tuple.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream-inherent.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-downstream.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516-inherent.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-issue-23516.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-messages.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-messages.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream-inherent.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlap-upstream.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-overlapping-pairs.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered-1.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-pair-covered-uncovered.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-orphan.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict-ty-param.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-conflict.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-ok-orphan.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-projection-ok.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-tuple-conflict.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local-2.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local-2.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence-vec-local.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_ref.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_fundamental_struct_tuple.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_struct.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_copy_like_err_tuple.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent_cc.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_inherent_cc.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_local.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_struct.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_struct.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.rs delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_err_tuple.stderr delete mode 100644 src/test/ui/re_rebalance_coherence/coherence_local_ref.rs diff --git a/src/test/ui/coherence/coherence-all-remote.rs b/src/test/ui/coherence/coherence-all-remote.rs index 5c3bfee822f1c..68c924ee27403 100644 --- a/src/test/ui/coherence/coherence-all-remote.rs +++ b/src/test/ui/coherence/coherence-all-remote.rs @@ -1,9 +1,13 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote1; impl Remote1 for isize { } -//~^ ERROR E0210 +//[old]~^ ERROR E0210 +//[re]~^^ ERROR E0210 fn main() { } diff --git a/src/test/ui/coherence/coherence-bigint-param.rs b/src/test/ui/coherence/coherence-bigint-param.rs index d199c1c216946..24106b4b348d4 100644 --- a/src/test/ui/coherence/coherence-bigint-param.rs +++ b/src/test/ui/coherence/coherence-bigint-param.rs @@ -1,4 +1,7 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote1; @@ -6,6 +9,7 @@ use lib::Remote1; pub struct BigInt; impl Remote1 for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0210 fn main() { } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs index 46d878859e0e6..098a13e54bfb4 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-implemented.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -21,7 +25,10 @@ impl MyTrait for T { fn get(&self) -> usize { 0 } } -impl MyTrait for T { //~ ERROR E0119 +impl MyTrait for T { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 + fn get(&self) -> usize { 0 } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs index 0044760161e5c..5b76fc0174b30 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-blanket-unimplemented.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -17,7 +21,9 @@ impl MyTrait for T { fn get(&self) -> usize { 0 } } -impl MyTrait for T { //~ ERROR E0119 +impl MyTrait for T { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { 0 } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs index 4c62741d2e4b4..b0aaf57e2a942 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-cross-crate.rs @@ -1,4 +1,7 @@ // aux-build:go_trait.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate go_trait; @@ -12,7 +15,9 @@ impl Go for MyThingy { fn go(&self, arg: isize) { } } -impl GoMut for MyThingy { //~ ERROR conflicting implementations +impl GoMut for MyThingy { +//[old]~^ ERROR conflicting implementations +//[re]~^^ ERROR E0119 fn go_mut(&mut self, arg: isize) { } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs index 42ce638f13705..9192d123514ab 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -19,7 +23,9 @@ struct MyType { dummy: usize } -impl MyTrait for MyType { //~ ERROR E0119 +impl MyTrait for MyType { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { (*self).clone() } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs index 78da8330ba3c5..51cb10e618556 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific-trait.rs @@ -1,6 +1,10 @@ // Test that a blank impl for all T:PartialEq conflicts with an impl for some // specific T when T:PartialEq. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait OtherTrait { fn noop(&self); } @@ -17,7 +21,9 @@ struct MyType { dummy: usize } -impl MyTrait for MyType { //~ ERROR E0119 +impl MyTrait for MyType { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { self.dummy } } diff --git a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs index db5f83c865a6f..3ecb613188ae4 100644 --- a/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs +++ b/src/test/ui/coherence/coherence-blanket-conflicts-with-specific.rs @@ -1,3 +1,7 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + use std::fmt::Debug; use std::default::Default; @@ -16,7 +20,9 @@ struct MyType { dummy: usize } -impl MyTrait for MyType { //~ ERROR E0119 +impl MyTrait for MyType { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn get(&self) -> usize { self.dummy } } diff --git a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs index 2165fdee5e08c..e05fecb11ed4b 100644 --- a/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs +++ b/src/test/ui/coherence/coherence-conflicting-negative-trait-impl.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] #![feature(overlapping_marker_traits)] @@ -8,11 +11,13 @@ struct TestType(::std::marker::PhantomData); unsafe impl Send for TestType {} impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` +//[old]~^ ERROR conflicting implementations of trait `std::marker::Send` +//[re]~^^ ERROR E0119 unsafe impl Send for TestType {} impl !Send for TestType {} -//~^ ERROR conflicting implementations of trait `std::marker::Send` +//[old]~^ ERROR conflicting implementations of trait `std::marker::Send` +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-cow.a.stderr b/src/test/ui/coherence/coherence-cow.a.stderr index 6692e1ce17441..2a3e57b1ce25b 100644 --- a/src/test/ui/coherence/coherence-cow.a.stderr +++ b/src/test/ui/coherence/coherence-cow.a.stderr @@ -1,7 +1,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:16:1 + --> $DIR/coherence-cow.rs:28:1 | -LL | impl Remote for Pair> { } //[a]~ ERROR E0210 +LL | impl Remote for Pair> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.b.stderr b/src/test/ui/coherence/coherence-cow.b.stderr index a148b6898fdc4..0512baef13669 100644 --- a/src/test/ui/coherence/coherence-cow.b.stderr +++ b/src/test/ui/coherence/coherence-cow.b.stderr @@ -1,7 +1,7 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:19:1 + --> $DIR/coherence-cow.rs:33:1 | -LL | impl Remote for Pair,T> { } //[b]~ ERROR E0210 +LL | impl Remote for Pair,T> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type | = note: only traits defined in the current crate can be implemented for a type parameter diff --git a/src/test/ui/coherence/coherence-cow.c.stderr b/src/test/ui/coherence/coherence-cow.c.stderr index b575dd64e87a5..1a95d82a03acf 100644 --- a/src/test/ui/coherence/coherence-cow.c.stderr +++ b/src/test/ui/coherence/coherence-cow.c.stderr @@ -1,5 +1,5 @@ error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct`) - --> $DIR/coherence-cow.rs:22:1 + --> $DIR/coherence-cow.rs:38:1 | LL | impl Remote for Pair,U> { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type diff --git a/src/test/ui/coherence/coherence-cow.rs b/src/test/ui/coherence/coherence-cow.rs index d72adf7a5319f..956b073414861 100644 --- a/src/test/ui/coherence/coherence-cow.rs +++ b/src/test/ui/coherence/coherence-cow.rs @@ -1,4 +1,6 @@ -// revisions: a b c +// revisions: a b c re_a re_b re_c + +#![cfg_attr(any(re_a, re_b, re_c), feature(re_rebalance_coherence))] // aux-build:coherence_lib.rs @@ -12,14 +14,19 @@ use lib::{Remote,Pair}; pub struct Cover(T); -#[cfg(a)] -impl Remote for Pair> { } //[a]~ ERROR E0210 +#[cfg(any(a, re_a))] +impl Remote for Pair> { } +//[a]~^ ERROR E0210 +//[re_a]~^^ ERROR E0117 -#[cfg(b)] -impl Remote for Pair,T> { } //[b]~ ERROR E0210 +#[cfg(any(b, re_b))] +impl Remote for Pair,T> { } +//[b]~^ ERROR E0210 +//[re_b]~^^ ERROR E0117 -#[cfg(c)] +#[cfg(any(c, re_c))] impl Remote for Pair,U> { } //[c]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re_c]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-cross-crate-conflict.rs b/src/test/ui/coherence/coherence-cross-crate-conflict.rs index 07dd585e8c48b..9643ab643dfe5 100644 --- a/src/test/ui/coherence/coherence-cross-crate-conflict.rs +++ b/src/test/ui/coherence/coherence-cross-crate-conflict.rs @@ -2,12 +2,18 @@ // generalizes the one upstream // aux-build:trait_impl_conflict.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate trait_impl_conflict; use trait_impl_conflict::Foo; impl Foo for A { - //~^ ERROR type parameter `A` must be used as the type parameter for some local type - //~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` + //[old]~^ ERROR type parameter `A` must be used as the type parameter for some local type + //[old]~| ERROR conflicting implementations of trait `trait_impl_conflict::Foo` for type `isize` + //[re]~^^^ ERROR E0119 + //[re]~| ERROR E0210 } fn main() { diff --git a/src/test/ui/coherence/coherence-default-trait-impl.rs b/src/test/ui/coherence/coherence-default-trait-impl.rs index df267ca7bd93d..606b4947b5f09 100644 --- a/src/test/ui/coherence/coherence-default-trait-impl.rs +++ b/src/test/ui/coherence/coherence-default-trait-impl.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] auto trait MySafeTrait {} @@ -5,11 +8,13 @@ auto trait MySafeTrait {} struct Foo; unsafe impl MySafeTrait for Foo {} -//~^ ERROR implementing the trait `MySafeTrait` is not unsafe +//[old]~^ ERROR implementing the trait `MySafeTrait` is not unsafe +//[re]~^^ ERROR E0199 unsafe auto trait MyUnsafeTrait {} impl MyUnsafeTrait for Foo {} -//~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration +//[old]~^ ERROR the trait `MyUnsafeTrait` requires an `unsafe impl` declaration +//[re]~^^ ERROR E0200 fn main() {} diff --git a/src/test/ui/coherence/coherence-error-suppression.rs b/src/test/ui/coherence/coherence-error-suppression.rs index f48652e3499a0..60b88fb80e44f 100644 --- a/src/test/ui/coherence/coherence-error-suppression.rs +++ b/src/test/ui/coherence/coherence-error-suppression.rs @@ -1,12 +1,18 @@ // check that error types in coherence do not cause error cascades. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait Foo {} impl Foo for i8 {} impl Foo for i16 {} impl Foo for i32 {} impl Foo for i64 {} -impl Foo for DoesNotExist {} //~ ERROR cannot find type `DoesNotExist` in this scope +impl Foo for DoesNotExist {} +//[old]~^ ERROR cannot find type `DoesNotExist` in this scope +//[re]~^^ ERROR E0412 impl Foo for u8 {} impl Foo for u16 {} impl Foo for u32 {} diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs index e5a7250872f4b..803e8fc6bca64 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait-object-safe.rs @@ -1,9 +1,15 @@ // Test that we give suitable error messages when the user attempts to // impl a trait `Trait` for its own object type. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + // If the trait is not object-safe, we give a more tailored message // because we're such schnuckels: trait NotObjectSafe { fn eq(&self, other: Self); } -impl NotObjectSafe for NotObjectSafe { } //~ ERROR E0038 +impl NotObjectSafe for NotObjectSafe { } +//[old]~^ ERROR E0038 +//[re]~^^ ERROR E0038 fn main() { } diff --git a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs index e4d59eedcabd0..dcaf564fdecfe 100644 --- a/src/test/ui/coherence/coherence-impl-trait-for-trait.rs +++ b/src/test/ui/coherence/coherence-impl-trait-for-trait.rs @@ -1,14 +1,24 @@ // Test that we give suitable error messages when the user attempts to // impl a trait `Trait` for its own object type. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait Foo { fn dummy(&self) { } } trait Bar: Foo { } trait Baz: Bar { } // Supertraits of Baz are not legal: -impl Foo for Baz { } //~ ERROR E0371 -impl Bar for Baz { } //~ ERROR E0371 -impl Baz for Baz { } //~ ERROR E0371 +impl Foo for Baz { } +//[old]~^ ERROR E0371 +//[re]~^^ ERROR E0371 +impl Bar for Baz { } +//[old]~^ ERROR E0371 +//[re]~^^ ERROR E0371 +impl Baz for Baz { } +//[old]~^ ERROR E0371 +//[re]~^^ ERROR E0371 // But other random traits are: trait Other { } diff --git a/src/test/ui/coherence/coherence-impls-copy.rs b/src/test/ui/coherence/coherence-impls-copy.rs index 5bfdfc8f40aec..97133bc33ce0d 100644 --- a/src/test/ui/coherence/coherence-impls-copy.rs +++ b/src/test/ui/coherence/coherence-impls-copy.rs @@ -1,11 +1,15 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] use std::marker::Copy; impl Copy for i32 {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`: -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `i32`: +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0119 +//[re]~| ERROR E0117 enum TestE { A } @@ -21,23 +25,27 @@ impl Clone for TestE { fn clone(&self) -> Self { *self } } impl Copy for MyType {} impl Copy for &'static mut MyType {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//[old]~^ ERROR the trait `Copy` may not be implemented for this type +//[re]~^^ ERROR E0206 impl Clone for MyType { fn clone(&self) -> Self { *self } } impl Copy for (MyType, MyType) {} -//~^ ERROR the trait `Copy` may not be implemented for this type -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR the trait `Copy` may not be implemented for this type +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0206 +//[re]~| ERROR E0117 impl Copy for &'static NotSync {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: - +//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&NotSync`: +//[re]~^^ ERROR E0119 impl Copy for [MyType] {} -//~^ ERROR the trait `Copy` may not be implemented for this type -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR the trait `Copy` may not be implemented for this type +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0206 +//[re]~| ERROR E0117 impl Copy for &'static [NotSync] {} -//~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: -//~| ERROR only traits defined in the current crate can be implemented for arbitrary types - +//[old]~^ ERROR conflicting implementations of trait `std::marker::Copy` for type `&[NotSync]`: +//[old]~| ERROR only traits defined in the current crate can be implemented for arbitrary types +//[re]~^^^ ERROR E0119 +//[re]~| ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-impls-send.rs b/src/test/ui/coherence/coherence-impls-send.rs index b2a9c5be65843..ef13e9caa6678 100644 --- a/src/test/ui/coherence/coherence-impls-send.rs +++ b/src/test/ui/coherence/coherence-impls-send.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] #![feature(overlapping_marker_traits)] @@ -15,16 +18,20 @@ impl !Sync for NotSync {} unsafe impl Send for TestE {} unsafe impl Send for MyType {} unsafe impl Send for (MyType, MyType) {} -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 unsafe impl Send for &'static NotSync {} -//~^ ERROR E0321 +//[old]~^ ERROR E0321 +//[re]~^^ ERROR E0321 unsafe impl Send for [MyType] {} -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 unsafe impl Send for &'static [NotSync] {} -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-impls-sized.rs b/src/test/ui/coherence/coherence-impls-sized.rs index 7af1344f95d9e..84ae2dd291b60 100644 --- a/src/test/ui/coherence/coherence-impls-sized.rs +++ b/src/test/ui/coherence/coherence-impls-sized.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] use std::marker::Copy; @@ -11,26 +14,41 @@ struct MyType; struct NotSync; impl !Sync for NotSync {} -impl Sized for TestE {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for MyType {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for (MyType, MyType) {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static NotSync {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed - -impl Sized for [MyType] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 - -impl Sized for &'static [NotSync] {} //~ ERROR E0322 -//~^ impl of 'Sized' not allowed -//~| ERROR E0117 +impl Sized for TestE {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[re]~^^^ ERROR E0322 + +impl Sized for MyType {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[re]~^^^ ERROR E0322 + +impl Sized for (MyType, MyType) {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[old]~| ERROR E0117 +//[re]~^^^^ ERROR E0322 +//[re]~| ERROR E0117 + +impl Sized for &'static NotSync {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[re]~^^^ ERROR E0322 + +impl Sized for [MyType] {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[old]~| ERROR E0117 +//[re]~^^^^ ERROR E0322 +//[re]~| ERROR E0117 + +impl Sized for &'static [NotSync] {} +//[old]~^ ERROR E0322 +//[old]~| impl of 'Sized' not allowed +//[old]~| ERROR E0117 +//[re]~^^^^ ERROR E0322 +//[re]~| ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs index 92bfeb1bf8afb..5a6b8fb7316d8 100644 --- a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs +++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.rs @@ -4,10 +4,14 @@ // // No we expect to run into a more user-friendly cycle error instead. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(specialization)] trait Trait { type Assoc; } -//~^ cycle detected +//[old]~^ cycle detected +//[re]~^^ ERROR E0391 impl Trait for Vec { type Assoc = (); diff --git a/src/test/ui/coherence/coherence-lone-type-parameter.rs b/src/test/ui/coherence/coherence-lone-type-parameter.rs index 7d52945b9dd64..63b38bf1cc138 100644 --- a/src/test/ui/coherence/coherence-lone-type-parameter.rs +++ b/src/test/ui/coherence/coherence-lone-type-parameter.rs @@ -1,9 +1,14 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; impl Remote for T { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0210 + fn main() { } diff --git a/src/test/ui/coherence/coherence-negative-impls-safe.rs b/src/test/ui/coherence/coherence-negative-impls-safe.rs index 050e47fd6a892..b6658d5bfa414 100644 --- a/src/test/ui/coherence/coherence-negative-impls-safe.rs +++ b/src/test/ui/coherence/coherence-negative-impls-safe.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] use std::marker::Send; @@ -5,6 +8,7 @@ use std::marker::Send; struct TestType; unsafe impl !Send for TestType {} -//~^ ERROR negative impls cannot be unsafe +//[old]~^ ERROR negative impls cannot be unsafe +//[re]~^^ ERROR E0198 fn main() {} diff --git a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs index 0a648c28ec658..9717f1ed0510e 100644 --- a/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs +++ b/src/test/ui/coherence/coherence-no-direct-lifetime-dispatch.rs @@ -1,8 +1,14 @@ // Test that you cannot *directly* dispatch on lifetime requirements +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait MyTrait { fn foo() {} } impl MyTrait for T {} -impl MyTrait for T {} //~ ERROR E0119 +impl MyTrait for T {} +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-orphan.rs b/src/test/ui/coherence/coherence-orphan.rs index ace3ebcc9e8b0..18f50e46021f9 100644 --- a/src/test/ui/coherence/coherence-orphan.rs +++ b/src/test/ui/coherence/coherence-orphan.rs @@ -1,5 +1,7 @@ // aux-build:coherence_orphan_lib.rs +// revisions: old re +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(optin_builtin_traits)] extern crate coherence_orphan_lib as lib; @@ -9,13 +11,15 @@ use lib::TheTrait; struct TheType; impl TheTrait for isize { } -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 impl TheTrait for isize { } impl TheTrait for TheType { } impl !Send for Vec { } -//~^ ERROR E0117 +//[old]~^ ERROR E0117 +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs index 19aad6927ba56..bf3ce89f70bba 100644 --- a/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs +++ b/src/test/ui/coherence/coherence-overlap-all-t-and-tuple.rs @@ -6,6 +6,10 @@ // // Seems pretty basic, but then there was issue #24241. :) +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait From { fn foo() {} } @@ -13,7 +17,9 @@ trait From { impl From for T { } -impl From<(U11,)> for (T11,) { //~ ERROR E0119 +impl From<(U11,)> for (T11,) { +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 } fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs b/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs index 5dea33e330b62..ad54d247f918d 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs +++ b/src/test/ui/coherence/coherence-overlap-downstream-inherent.rs @@ -1,17 +1,23 @@ // Tests that we consider `T: Sugar + Fruit` to be ambiguous, even // though no impls are found. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + struct Sweet(X); pub trait Sugar {} pub trait Fruit {} impl Sweet { fn dummy(&self) { } } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl Sweet { fn dummy(&self) { } } trait Bar {} struct A(T, X); impl A where T: Bar { fn f(&self) {} } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl A { fn f(&self) {} } fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-downstream.rs b/src/test/ui/coherence/coherence-overlap-downstream.rs index 738ec0e3d4550..c6ced7b80fd9d 100644 --- a/src/test/ui/coherence/coherence-overlap-downstream.rs +++ b/src/test/ui/coherence/coherence-overlap-downstream.rs @@ -1,17 +1,23 @@ // Tests that we consider `T: Sugar + Fruit` to be ambiguous, even // though no impls are found. +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + pub trait Sugar {} pub trait Fruit {} pub trait Sweet {} impl Sweet for T { } impl Sweet for T { } -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 pub trait Foo {} pub trait Bar {} impl Foo for T where T: Bar {} impl Foo for i32 {} -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs index a272e620fcab3..969366e29cc35 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs +++ b/src/test/ui/coherence/coherence-overlap-issue-23516-inherent.rs @@ -2,12 +2,17 @@ // though we see no impl of `Sugar` for `Box`. Therefore, an overlap // error is reported for the following pair of impls (#23516). +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + pub trait Sugar {} struct Cake(X); impl Cake { fn dummy(&self) { } } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl Cake> { fn dummy(&self) { } } fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-issue-23516.rs b/src/test/ui/coherence/coherence-overlap-issue-23516.rs index 63e42e8f412dd..e3c15e149f8b5 100644 --- a/src/test/ui/coherence/coherence-overlap-issue-23516.rs +++ b/src/test/ui/coherence/coherence-overlap-issue-23516.rs @@ -2,10 +2,15 @@ // though we see no impl of `Sugar` for `Box`. Therefore, an overlap // error is reported for the following pair of impls (#23516). +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + pub trait Sugar { fn dummy(&self) { } } pub trait Sweet { fn dummy(&self) { } } impl Sweet for T { } impl Sweet for Box { } -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() { } diff --git a/src/test/ui/coherence/coherence-overlap-messages.rs b/src/test/ui/coherence/coherence-overlap-messages.rs index e7ce40dc43aec..e0e2e672e98dd 100644 --- a/src/test/ui/coherence/coherence-overlap-messages.rs +++ b/src/test/ui/coherence/coherence-overlap-messages.rs @@ -1,22 +1,37 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + trait Foo { fn foo() {} } impl Foo for T {} -impl Foo for U {} //~ ERROR conflicting implementations of trait `Foo`: +impl Foo for U {} +//[old]~^ ERROR conflicting implementations of trait `Foo`: +//[re]~^^ ERROR E0119 + trait Bar { fn bar() {} } impl Bar for (T, u8) {} -impl Bar for (u8, T) {} //~ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: +impl Bar for (u8, T) {} +//[old]~^ ERROR conflicting implementations of trait `Bar` for type `(u8, u8)`: +//[re]~^^ ERROR E0119 trait Baz { fn baz() {} } impl Baz for T {} -impl Baz for u8 {} //~ ERROR conflicting implementations of trait `Baz` for type `u8`: +impl Baz for u8 {} +//[old]~^ ERROR conflicting implementations of trait `Baz` for type `u8`: +//[re]~^^ ERROR E0119 trait Quux { fn quux() {} } impl Quux for T {} -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: -impl Quux for T {} //~ ERROR conflicting implementations of trait `Quux<_, _>`: +impl Quux for T {} +//[old]~^ ERROR conflicting implementations of trait `Quux<_, _>`: +//[re]~^^ ERROR E0119 +impl Quux for T {} +//[old]~^ ERROR conflicting implementations of trait `Quux<_, _>`: +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs b/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs index c5d59c6655abe..92b619af076b9 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs +++ b/src/test/ui/coherence/coherence-overlap-upstream-inherent.rs @@ -2,6 +2,10 @@ // though the upstream crate doesn't implement it for now. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate coherence_lib; @@ -9,7 +13,8 @@ use coherence_lib::Remote; struct A(X); impl A where T: Remote { fn dummy(&self) { } } -//~^ ERROR E0592 +//[old]~^ ERROR E0592 +//[re]~^^ ERROR E0592 impl A { fn dummy(&self) { } } fn main() {} diff --git a/src/test/ui/coherence/coherence-overlap-upstream.rs b/src/test/ui/coherence/coherence-overlap-upstream.rs index 47dd7a78fe88f..62f675003f9c4 100644 --- a/src/test/ui/coherence/coherence-overlap-upstream.rs +++ b/src/test/ui/coherence/coherence-overlap-upstream.rs @@ -2,6 +2,10 @@ // though the upstream crate doesn't implement it for now. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate coherence_lib; @@ -10,6 +14,7 @@ use coherence_lib::Remote; trait Foo {} impl Foo for T where T: Remote {} impl Foo for i16 {} -//~^ ERROR E0119 +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-overlapping-pairs.rs b/src/test/ui/coherence/coherence-overlapping-pairs.rs index 11b74ebacc5bc..de31a0839405d 100644 --- a/src/test/ui/coherence/coherence-overlapping-pairs.rs +++ b/src/test/ui/coherence/coherence-overlapping-pairs.rs @@ -1,4 +1,7 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::Remote; @@ -6,6 +9,7 @@ use lib::Remote; struct Foo; impl Remote for lib::Pair { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs index f41e93aa994db..91794b7999b1c 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered-1.rs @@ -2,6 +2,10 @@ // list of type parameters, not the self type. // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] + extern crate coherence_lib as lib; use lib::{Remote1, Pair}; @@ -9,6 +13,7 @@ use lib::{Remote1, Pair}; pub struct Local(T); impl Remote1>> for i32 { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-pair-covered-uncovered.rs b/src/test/ui/coherence/coherence-pair-covered-uncovered.rs index 2400e9ec67904..49a91412bec71 100644 --- a/src/test/ui/coherence/coherence-pair-covered-uncovered.rs +++ b/src/test/ui/coherence/coherence-pair-covered-uncovered.rs @@ -1,4 +1,7 @@ // aux-build:coherence_lib.rs +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] extern crate coherence_lib as lib; use lib::{Remote, Pair}; @@ -6,6 +9,7 @@ use lib::{Remote, Pair}; struct Local(T); impl Remote for Pair> { } -//~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[old]~^ ERROR type parameter `T` must be used as the type parameter for some local type +//[re]~^^ ERROR E0117 fn main() { } diff --git a/src/test/ui/coherence/coherence-projection-conflict-orphan.rs b/src/test/ui/coherence/coherence-projection-conflict-orphan.rs index 31325bea7c91b..4f7fc71536ba8 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-orphan.rs +++ b/src/test/ui/coherence/coherence-projection-conflict-orphan.rs @@ -1,3 +1,6 @@ +// revisions: old re + +#![cfg_attr(re, feature(re_rebalance_coherence))] #![feature(rustc_attrs)] // Here we expect a coherence conflict because, even though `i32` does @@ -13,6 +16,8 @@ pub trait Bar { impl Foo for i32 { } -impl Foo for A { } //~ ERROR E0119 +impl Foo for A { } +//[old]~^ ERROR E0119 +//[re]~^^ ERROR E0119 fn main() {} diff --git a/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs b/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs index 490c7e24f5740..819947fa54756 100644 --- a/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs +++ b/src/test/ui/coherence/coherence-projection-conflict-ty-param.rs @@ -1,12 +1,18 @@ // Coherence error results because we do not know whether `T: Foo