diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index a571b2793df1..f43469363cd8 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -88,15 +88,10 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OrphanChecker<'cx, 'tcx> { Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => { if !ty::has_attr(self.tcx, trait_def_id, "old_orphan_check") { span_err!(self.tcx.sess, item.span, E0210, - "type parameter `{}` is not constrained by any local type; \ - only traits defined in the current crate can be implemented \ - for a type parameter", + "type parameter `{}` must be used as the type parameter for \ + some local type (e.g. `MyStruct`); only traits defined in \ + the current crate can be implemented for a type parameter", param_ty.user_string(self.tcx)); - self.tcx.sess.span_note( - item.span, - &format!("for a limited time, you can add \ - `#![feature(old_orphan_check)]` to your crate \ - to disable this rule")); } } } diff --git a/src/test/auxiliary/orphan_check_diagnostics.rs b/src/test/auxiliary/orphan_check_diagnostics.rs new file mode 100644 index 000000000000..7647f159401a --- /dev/null +++ b/src/test/auxiliary/orphan_check_diagnostics.rs @@ -0,0 +1,11 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait RemoteTrait {} diff --git a/src/test/compile-fail/coherence-bigint-param.rs b/src/test/compile-fail/coherence-bigint-param.rs index b8e48436a414..b7ca499be736 100644 --- a/src/test/compile-fail/coherence-bigint-param.rs +++ b/src/test/compile-fail/coherence-bigint-param.rs @@ -16,6 +16,6 @@ use lib::Remote1; pub struct BigInt; impl Remote1 for T { } -//~^ ERROR type parameter `T` is not constrained +//~^ ERROR type parameter `T` must be used as the type parameter for some local type fn main() { } diff --git a/src/test/compile-fail/coherence-cow-no-cover.rs b/src/test/compile-fail/coherence-cow-no-cover.rs index 8d14eb96c617..1bec97de5338 100644 --- a/src/test/compile-fail/coherence-cow-no-cover.rs +++ b/src/test/compile-fail/coherence-cow-no-cover.rs @@ -18,6 +18,6 @@ use lib::{Remote,Pair}; pub struct Cover(T); impl Remote for Pair,U> { } -//~^ ERROR type parameter `U` is not constrained by any local type +//~^ ERROR type parameter `U` must be used as the type parameter for some local type fn main() { } diff --git a/src/test/compile-fail/coherence-cross-crate-conflict.rs b/src/test/compile-fail/coherence-cross-crate-conflict.rs index 8bdd5c58f319..a020b518d827 100644 --- a/src/test/compile-fail/coherence-cross-crate-conflict.rs +++ b/src/test/compile-fail/coherence-cross-crate-conflict.rs @@ -16,7 +16,7 @@ extern crate trait_impl_conflict; use trait_impl_conflict::Foo; impl Foo for A { - //~^ ERROR type parameter `A` is not constrained + //~^ ERROR type parameter `A` must be used as the type parameter for some local type //~^^ ERROR E0119 } diff --git a/src/test/compile-fail/coherence-lone-type-parameter.rs b/src/test/compile-fail/coherence-lone-type-parameter.rs index 917438722de4..9f7481f12f2f 100644 --- a/src/test/compile-fail/coherence-lone-type-parameter.rs +++ b/src/test/compile-fail/coherence-lone-type-parameter.rs @@ -13,6 +13,7 @@ extern crate "coherence-lib" as lib; use lib::Remote; -impl Remote for T { } //~ ERROR type parameter `T` is not constrained +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/compile-fail/coherence-overlapping-pairs.rs b/src/test/compile-fail/coherence-overlapping-pairs.rs index 9354e66af0d8..9878bdec2c36 100644 --- a/src/test/compile-fail/coherence-overlapping-pairs.rs +++ b/src/test/compile-fail/coherence-overlapping-pairs.rs @@ -16,6 +16,6 @@ use lib::Remote; struct Foo; impl Remote for lib::Pair { } -//~^ ERROR type parameter `T` is not constrained +//~^ ERROR type parameter `T` must be used as the type parameter for some local type fn main() { } diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs b/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs index 3655bca6f1d8..2bdcc346f70d 100644 --- a/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs +++ b/src/test/compile-fail/coherence-pair-covered-uncovered-1.rs @@ -18,7 +18,7 @@ use lib::{Remote1, Pair}; pub struct Local(T); -impl Remote1>> for i32 { } -//~^ ERROR type parameter `T` is not constrained +impl Remote1>> for i32 { } +//~^ ERROR type parameter `T` must be used as the type parameter for some local type fn main() { } diff --git a/src/test/compile-fail/coherence-pair-covered-uncovered.rs b/src/test/compile-fail/coherence-pair-covered-uncovered.rs index 92a07b358529..881494f009f1 100644 --- a/src/test/compile-fail/coherence-pair-covered-uncovered.rs +++ b/src/test/compile-fail/coherence-pair-covered-uncovered.rs @@ -16,6 +16,6 @@ use lib::{Remote, Pair}; struct Local(T); impl Remote for Pair> { } -//~^ ERROR type parameter `T` is not constrained +//~^ ERROR type parameter `T` must be used as the type parameter for some local type fn main() { } diff --git a/src/test/compile-fail/orphan-check-diagnostics.rs b/src/test/compile-fail/orphan-check-diagnostics.rs new file mode 100644 index 000000000000..ff5c101b9178 --- /dev/null +++ b/src/test/compile-fail/orphan-check-diagnostics.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. + +// aux-build:orphan_check_diagnostics.rs +// see #22388 + +extern crate orphan_check_diagnostics; + +use orphan_check_diagnostics::RemoteTrait; + +trait LocalTrait {} + +impl RemoteTrait for T where T: LocalTrait {} +//~^ ERROR type parameter `T` must be used as the type parameter for some local type + +fn main() {}