提交 bc48107a 编写于 作者: M Manish Goregaokar

Rollup merge of #22418 - japaric:diagnostics, r=nikomatsakis

 closes #22388

r? @nikomatsakis
cc @insaneinside
......@@ -88,15 +88,10 @@ fn visit_item(&mut self, item: &'v ast::Item) {
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<T>`); 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"));
}
}
}
......
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub trait RemoteTrait {}
......@@ -16,6 +16,6 @@
pub struct BigInt;
impl<T> Remote1<BigInt> 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() { }
......@@ -18,6 +18,6 @@
pub struct Cover<T>(T);
impl<T,U> Remote for Pair<Cover<T>,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() { }
......@@ -16,7 +16,7 @@
use trait_impl_conflict::Foo;
impl<A> 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
}
......
......@@ -13,6 +13,7 @@
extern crate "coherence-lib" as lib;
use lib::Remote;
impl<T> Remote for T { } //~ ERROR type parameter `T` is not constrained
impl<T> Remote for T { }
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() { }
......@@ -16,6 +16,6 @@
struct Foo;
impl<T> Remote for lib::Pair<T,Foo> { }
//~^ ERROR type parameter `T` is not constrained
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() { }
......@@ -18,7 +18,7 @@
pub struct Local<T>(T);
impl<T,U> Remote1<Pair<T,Local<U>>> for i32 { }
//~^ ERROR type parameter `T` is not constrained
impl<T, U> Remote1<Pair<T, Local<U>>> for i32 { }
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() { }
......@@ -16,6 +16,6 @@
struct Local<T>(T);
impl<T,U> Remote for Pair<T,Local<U>> { }
//~^ ERROR type parameter `T` is not constrained
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() { }
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> RemoteTrait for T where T: LocalTrait {}
//~^ ERROR type parameter `T` must be used as the type parameter for some local type
fn main() {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册