introduce negative_impls feature gate and document

They used to be covered by `optin_builtin_traits` but negative impls
are now applicable to all traits, not just auto traits.

This also adds docs in the unstable book for the current state of auto traits.
This commit is contained in:
Niko Matsakis 2020-01-09 05:56:38 -05:00
parent 65071708f8
commit fda3378e3f
102 changed files with 330 additions and 111 deletions

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// pp-exact

View file

@ -1,6 +1,6 @@
#![crate_name = "foo"]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
pub struct Foo;

View file

@ -1,7 +1,7 @@
// aux-build:rustdoc-impl-parts-crosscrate.rs
// ignore-cross-compile
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
extern crate rustdoc_impl_parts_crosscrate;

View file

@ -1,3 +1,4 @@
#![feature(negative_impls)]
#![feature(optin_builtin_traits)]
pub auto trait AnOibit {}

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// @has issue_55321/struct.A.html
// @has - '//*[@id="implementations-list"]/*[@class="impl"]//code' "impl !Send for A"

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![crate_name = "foo"]
pub struct Foo;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// @matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha"
pub struct Alpha;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// edition:2018
// This tests the the specialized async-await-specific error when futures don't implement an

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// edition:2018
// This tests the the specialized async-await-specific error when futures don't implement an

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// edition:2018
// This tests the the unspecialized async-await-specific error when futures don't implement an

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl std::future::Future`
--> $DIR/issue-64130-3-other.rs:23:5
--> $DIR/issue-64130-3-other.rs:24:5
|
LL | fn is_qux<T: Qux>(t: T) { }
| ------ --- required by this bound in `is_qux`
@ -13,7 +13,7 @@ LL | is_qux(bar());
= help: the following implementations were found:
<Foo as Qux>
note: future does not implement `Qux` as this value is used across an await
--> $DIR/issue-64130-3-other.rs:17:5
--> $DIR/issue-64130-3-other.rs:18:5
|
LL | let x = Foo;
| - has type `Foo`

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
fn main() {
struct Foo;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![feature(marker_trait_attr)]
#[marker]

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait MySafeTrait {}

View file

@ -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:8: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:13:1
|
LL | impl MyUnsafeTrait for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// Test for issue #56934 - that it is impossible to redundantly
// implement an auto-trait for a trait object type that contains it.

View file

@ -1,17 +1,17 @@
error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker1`
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:14:1
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:15:1
|
LL | impl !Marker1 for dyn Object + Marker2 { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker1`
error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker2`
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:16:1
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:17:1
|
LL | impl !Marker2 for dyn Object + Marker2 { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker2`
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:22:1
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:23:1
|
LL | impl !Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^-----------
@ -22,13 +22,13 @@ LL | impl !Send for dyn Marker2 {}
= 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 `(dyn Object + 'static)`
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:26:1
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:27:1
|
LL | impl !Send for dyn Object {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + Marker2 + 'static)`
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:27:1
--> $DIR/coherence-impl-trait-for-marker-trait-negative.rs:28:1
|
LL | impl !Send for dyn Object + Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// Test for issue #56934 - that it is impossible to redundantly
// implement an auto-trait for a trait object type that contains it.

View file

@ -1,17 +1,17 @@
error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker1`
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:14:1
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:15:1
|
LL | impl Marker1 for dyn Object + Marker2 { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker1`
error[E0371]: the object type `(dyn Object + Marker2 + 'static)` automatically implements the trait `Marker2`
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:16:1
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:17:1
|
LL | impl Marker2 for dyn Object + Marker2 { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Object + Marker2 + 'static)` automatically implements trait `Marker2`
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:22:1
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:23:1
|
LL | unsafe impl Send for dyn Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^-----------
@ -22,13 +22,13 @@ LL | unsafe impl Send for dyn Marker2 {}
= 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 `(dyn Object + 'static)`
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:26:1
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:27:1
|
LL | unsafe impl Send for dyn Object {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type
error[E0321]: cross-crate traits with a default impl, like `std::marker::Send`, can only be implemented for a struct/enum type, not `(dyn Object + Marker2 + 'static)`
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:27:1
--> $DIR/coherence-impl-trait-for-marker-trait-positive.rs:28:1
|
LL | unsafe impl Send for dyn Object + Marker2 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Copy;

View file

@ -1,9 +1,9 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Copy;
enum TestE {
A
A,
}
struct MyType;
@ -26,5 +26,4 @@ unsafe impl Send for &'static [NotSync] {}
//~^ ERROR conflicting implementations of trait
//~| ERROR only traits defined in the current crate
fn main() {
}
fn main() {}

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Copy;

View file

@ -2,7 +2,7 @@
#![allow(dead_code)]
// pretty-expanded FIXME #23616
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Send;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Send;

View file

@ -1,5 +1,5 @@
// aux-build:coherence_orphan_lib.rs
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
extern crate coherence_orphan_lib as lib;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
struct Foo;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
struct Foo;

View file

@ -0,0 +1,3 @@
trait MyTrait {}
impl !MyTrait for u32 {} //~ ERROR negative trait bounds are not yet fully implemented
fn main() {}

View file

@ -0,0 +1,12 @@
error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now
--> $DIR/feature-gate-negative_impls.rs:2:6
|
LL | impl !MyTrait for u32 {}
| ^^^^^^^^
|
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
= help: add `#![feature(negative_impls)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -14,7 +14,7 @@ LL | impl !AutoDummyTrait for DummyStruct {}
| ^^^^^^^^^^^^^^^
|
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
= help: add `#![feature(optin_builtin_traits)]` to the crate attributes to enable
= help: add `#![feature(negative_impls)]` to the crate attributes to enable
error: aborting due to 2 previous errors

View file

@ -1,5 +1,5 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/auto-trait-regions.rs:45:24
--> $DIR/auto-trait-regions.rs:46:24
|
LL | let a = A(&mut true, &mut true, No);
| ^^^^ - temporary value is freed at the end of this statement
@ -12,7 +12,7 @@ LL | assert_foo(a);
= note: consider using a `let` binding to create a longer lived value
error[E0716]: temporary value dropped while borrowed
--> $DIR/auto-trait-regions.rs:45:35
--> $DIR/auto-trait-regions.rs:46:35
|
LL | let a = A(&mut true, &mut true, No);
| ^^^^ - temporary value is freed at the end of this statement
@ -25,13 +25,13 @@ LL | assert_foo(a);
= note: consider using a `let` binding to create a longer lived value
error: higher-ranked subtype error
--> $DIR/auto-trait-regions.rs:30:5
--> $DIR/auto-trait-regions.rs:31:5
|
LL | assert_foo(gen);
| ^^^^^^^^^^^^^^^
error: higher-ranked subtype error
--> $DIR/auto-trait-regions.rs:49:5
--> $DIR/auto-trait-regions.rs:50:5
|
LL | assert_foo(gen);
| ^^^^^^^^^^^^^^^

View file

@ -1,5 +1,6 @@
#![feature(generators)]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait Foo {}

View file

@ -1,5 +1,5 @@
error: implementation of `Foo` is not general enough
--> $DIR/auto-trait-regions.rs:30:5
--> $DIR/auto-trait-regions.rs:31:5
|
LL | auto trait Foo {}
| ----------------- trait `Foo` defined here
@ -11,7 +11,7 @@ LL | assert_foo(gen);
= note: ...but `Foo` is actually implemented for the type `&'1 OnlyFooIfStaticRef`, for some specific lifetime `'1`
error: implementation of `Foo` is not general enough
--> $DIR/auto-trait-regions.rs:30:5
--> $DIR/auto-trait-regions.rs:31:5
|
LL | auto trait Foo {}
| ----------------- trait `Foo` defined here
@ -23,7 +23,7 @@ LL | assert_foo(gen);
= note: ...but `Foo` is actually implemented for the type `&'1 OnlyFooIfStaticRef`, for some specific lifetime `'1`
error: implementation of `Foo` is not general enough
--> $DIR/auto-trait-regions.rs:49:5
--> $DIR/auto-trait-regions.rs:50:5
|
LL | auto trait Foo {}
| ----------------- trait `Foo` defined here
@ -35,7 +35,7 @@ LL | assert_foo(gen);
= note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
error: implementation of `Foo` is not general enough
--> $DIR/auto-trait-regions.rs:49:5
--> $DIR/auto-trait-regions.rs:50:5
|
LL | auto trait Foo {}
| ----------------- trait `Foo` defined here

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Sync;

View file

@ -1,6 +1,7 @@
//~ ERROR
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
unsafe auto trait Trait {
type Output; //~ ERROR E0380

View file

@ -1,5 +1,5 @@
error[E0380]: auto traits cannot have methods or associated items
--> $DIR/issue-23080-2.rs:6:10
--> $DIR/issue-23080-2.rs:7:10
|
LL | unsafe auto trait Trait {
| ----- auto trait cannot have items

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
unsafe auto trait Trait {
fn method(&self) { //~ ERROR E0380

View file

@ -1,5 +1,5 @@
error[E0380]: auto traits cannot have methods or associated items
--> $DIR/issue-23080.rs:4:8
--> $DIR/issue-23080.rs:5:8
|
LL | unsafe auto trait Trait {
| ----- auto trait cannot have items

View file

@ -1,5 +1,6 @@
// check-pass
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait NotSame {}

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![allow(order_dependent_trait_objects)]
// Check that the issue #33140 hack does not allow unintended things.

View file

@ -1,7 +1,7 @@
// Tests that an `&` pointer to something inherently mutable is itself
// to be considered mutable.
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Sync;

View file

@ -1,6 +1,7 @@
// check-pass
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![feature(never_type)]
fn main() {

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Send;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Send;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Sync;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Sync;

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![allow(bare_trait_objects)]
auto trait Auto {}

View file

@ -1,23 +1,23 @@
error[E0178]: expected a path on the left-hand side of `+`, not `((Auto))`
--> $DIR/trait-object-bad-parens.rs:7:16
--> $DIR/trait-object-bad-parens.rs:8:16
|
LL | let _: Box<((Auto)) + Auto>;
| ^^^^^^^^^^^^^^^ expected a path
error[E0178]: expected a path on the left-hand side of `+`, not `(Auto + Auto)`
--> $DIR/trait-object-bad-parens.rs:9:16
--> $DIR/trait-object-bad-parens.rs:10:16
|
LL | let _: Box<(Auto + Auto) + Auto>;
| ^^^^^^^^^^^^^^^^^^^^ expected a path
error[E0178]: expected a path on the left-hand side of `+`, not `(Auto)`
--> $DIR/trait-object-bad-parens.rs:11:16
--> $DIR/trait-object-bad-parens.rs:12:16
|
LL | let _: Box<(Auto +) + Auto>;
| ^^^^^^^^^^^^^^^ expected a path
error[E0178]: expected a path on the left-hand side of `+`, not `(dyn Auto)`
--> $DIR/trait-object-bad-parens.rs:13:16
--> $DIR/trait-object-bad-parens.rs:14:16
|
LL | let _: Box<(dyn Auto) + Auto>;
| ^^^^^^^^^^^^^^^^^ expected a path

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
pub trait Tr {
fn f();

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#[allow(private_in_public)]
mod m {

View file

@ -1,5 +1,5 @@
error: trait `m::PrivNonPrincipal` is private
--> $DIR/private-in-public-non-principal-2.rs:11:5
--> $DIR/private-in-public-non-principal-2.rs:12:5
|
LL | m::leak_dyn_nonprincipal();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ private trait

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
pub trait PubPrincipal {}
auto trait PrivNonPrincipal {}

View file

@ -1,5 +1,5 @@
warning: private trait `PrivNonPrincipal` in public interface (error E0445)
--> $DIR/private-in-public-non-principal.rs:6:1
--> $DIR/private-in-public-non-principal.rs:7:1
|
LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loop {} }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -15,7 +15,7 @@ LL | pub fn check_doc_lint() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/private-in-public-non-principal.rs:10:8
--> $DIR/private-in-public-non-principal.rs:11:8
|
LL | #[deny(missing_docs)]
| ^^^^^^^^^^^^

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![feature(specialization)]
struct S;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![feature(specialization)]
trait MyTrait {}

View file

@ -1,6 +1,7 @@
// Make sure specialization cannot change impl polarity
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![feature(specialization)]
auto trait Foo {}

View file

@ -1,5 +1,5 @@
error[E0748]: found both positive and negative implementation of trait `Foo` for type `u8`:
--> $DIR/specialization-polarity.rs:9:1
--> $DIR/specialization-polarity.rs:10:1
|
LL | impl<T> Foo for T {}
| ----------------- positive implementation here
@ -7,7 +7,7 @@ LL | impl !Foo for u8 {}
| ^^^^^^^^^^^^^^^^ negative implementation here
error[E0748]: found both positive and negative implementation of trait `Bar` for type `u8`:
--> $DIR/specialization-polarity.rs:14:1
--> $DIR/specialization-polarity.rs:15:1
|
LL | impl<T> !Bar for T {}
| ------------------ negative implementation here

View file

@ -5,7 +5,7 @@ LL | impl !Send for TestType {}
| ^^^^^
|
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
= help: add `#![feature(optin_builtin_traits)]` to the crate attributes to enable
= help: add `#![feature(negative_impls)]` to the crate attributes to enable
error: aborting due to previous error

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Send;

View file

@ -1,6 +1,7 @@
// run-pass
#![allow(unused_doc_comments)]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait Auto {}
unsafe auto trait AutoUnsafe {}

View file

@ -1,6 +1,6 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
pub trait ForeignTrait { }
pub trait ForeignTrait {}
impl ForeignTrait for u32 { }
impl ForeignTrait for u32 {}
impl !ForeignTrait for String {}

View file

@ -3,7 +3,7 @@
// errors are not reported. This way, we make sure that, for each function, different
// typeck phases are involved and all errors are reported.
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Send;

View file

@ -1,6 +1,6 @@
// run-pass
#![allow(unused_variables)]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::marker::Send;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![feature(specialization)]
trait MyTrait {

View file

@ -1,5 +1,5 @@
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// Negative impl for u32 cannot "specialize" the base impl.
trait MyTrait {

View file

@ -1,5 +1,5 @@
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// Negative impl for u32 cannot "specialize" the base impl.
trait MyTrait {}

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
trait MyTrait {
type Foo;

View file

@ -1,5 +1,5 @@
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
trait MyTrait {}

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// aux-build: foreign_trait.rs

View file

@ -1,6 +1,6 @@
// run-pass
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
#![allow(dead_code)]
struct TestType;

View file

@ -1,5 +1,5 @@
#![allow(dead_code)]
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
// Overlapping negative impls for `MyStruct` are not permitted:
struct MyStruct;
@ -7,5 +7,4 @@ impl !Send for MyStruct {}
impl !Send for MyStruct {}
//~^ ERROR conflicting implementations of trait
fn main() {
}
fn main() {}

View file

@ -0,0 +1,28 @@
// run-pass
// Tests for RFC 1268: we allow overlapping impls of marker traits,
// that is, traits without items. In this case, a type `T` is
// `MyMarker` if it is either `Debug` or `Display`.
#![feature(marker_trait_attr)]
#![feature(negative_impls)]
use std::fmt::{Debug, Display};
#[marker]
trait MyMarker {}
impl<T: Debug> MyMarker for T {}
impl<T: Display> MyMarker for T {}
fn foo<T: MyMarker>(t: T) -> T {
t
}
fn main() {
// Debug && Display:
assert_eq!(1, foo(1));
assert_eq!(2.0, foo(2.0));
// Debug && !Display:
assert_eq!(vec![1], foo(vec![1]));
}

View file

@ -2,7 +2,7 @@
#![allow(dead_code)]
// pretty-expanded FIXME #23616
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
struct TestType;

View file

@ -3,6 +3,7 @@
// to be synthesized.
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait Magic: Copy {} //~ ERROR E0568

View file

@ -1,5 +1,5 @@
error[E0568]: auto traits cannot have super traits
--> $DIR/traits-inductive-overflow-supertrait-oibit.rs:7:19
--> $DIR/traits-inductive-overflow-supertrait-oibit.rs:8:19
|
LL | auto trait Magic: Copy {}
| ----- ^^^^ help: remove the super traits
@ -7,7 +7,7 @@ LL | auto trait Magic: Copy {}
| auto trait cannot have super traits
error[E0277]: the trait bound `NoClone: std::marker::Copy` is not satisfied
--> $DIR/traits-inductive-overflow-supertrait-oibit.rs:15:23
--> $DIR/traits-inductive-overflow-supertrait-oibit.rs:16:23
|
LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) }
| ---- ----- required by this bound in `copy`

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait Magic : Sized where Option<Self> : Magic {} //~ ERROR E0568
impl<T:Magic> Magic for T {}

View file

@ -1,5 +1,5 @@
error[E0568]: auto traits cannot have super traits
--> $DIR/typeck-auto-trait-no-supertraits-2.rs:3:20
--> $DIR/typeck-auto-trait-no-supertraits-2.rs:4:20
|
LL | auto trait Magic : Sized where Option<Self> : Magic {}
| ----- ^^^^^ help: remove the super traits

View file

@ -23,6 +23,7 @@
// }
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait Magic: Copy {} //~ ERROR E0568
impl<T:Magic> Magic for T {}

View file

@ -1,5 +1,5 @@
error[E0568]: auto traits cannot have super traits
--> $DIR/typeck-auto-trait-no-supertraits.rs:27:19
--> $DIR/typeck-auto-trait-no-supertraits.rs:28:19
|
LL | auto trait Magic: Copy {}
| ----- ^^^^ help: remove the super traits

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait MyTrait {}

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied in `(MyS2, MyS)`
--> $DIR/typeck-default-trait-impl-constituent-types-2.rs:16:5
--> $DIR/typeck-default-trait-impl-constituent-types-2.rs:17:5
|
LL | fn is_mytrait<T: MyTrait>() {}
| ---------- ------- required by this bound in `is_mytrait`

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait MyTrait {}

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied
--> $DIR/typeck-default-trait-impl-constituent-types.rs:20:18
--> $DIR/typeck-default-trait-impl-constituent-types.rs:21:18
|
LL | fn is_mytrait<T: MyTrait>() {}
| ---------- ------- required by this bound in `is_mytrait`

View file

@ -3,7 +3,7 @@
// Test that we do not consider associated types to be sendable without
// some applicable trait bound (and we don't ICE).
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
extern crate tdticc_coherence_lib as lib;

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
struct MySendable {
t: *mut u8

View file

@ -1,4 +1,4 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
struct Managed;
impl !Send for Managed {}

View file

@ -1,4 +1,5 @@
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait MyTrait {}

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `ThisImplsUnsafeTrait: MyTrait` is not satisfied
--> $DIR/typeck-default-trait-impl-negation.rs:21:19
--> $DIR/typeck-default-trait-impl-negation.rs:22:19
|
LL | fn is_my_trait<T: MyTrait>() {}
| ----------- ------- required by this bound in `is_my_trait`
@ -11,7 +11,7 @@ LL | is_my_trait::<ThisImplsUnsafeTrait>();
<ThisImplsUnsafeTrait as MyTrait>
error[E0277]: the trait bound `ThisImplsTrait: MyUnsafeTrait` is not satisfied
--> $DIR/typeck-default-trait-impl-negation.rs:24:26
--> $DIR/typeck-default-trait-impl-negation.rs:25:26
|
LL | fn is_my_unsafe_trait<T: MyUnsafeTrait>() {}
| ------------------ ------------- required by this bound in `is_my_unsafe_trait`

View file

@ -4,6 +4,7 @@
// impls whose types unify.
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
auto trait Defaulted { }
impl<'a,T:Signed> Defaulted for &'a T { }

View file

@ -1,5 +1,5 @@
error[E0277]: the trait bound `u32: Signed` is not satisfied
--> $DIR/typeck-default-trait-impl-precedence.rs:18:5
--> $DIR/typeck-default-trait-impl-precedence.rs:19:5
|
LL | fn is_defaulted<T:Defaulted>() { }
| ------------ --------- required by this bound in `is_defaulted`

View file

@ -1,6 +1,6 @@
// Verify that UnsafeCell is *always* !Sync regardless if `T` is sync.
#![feature(optin_builtin_traits)]
#![feature(negative_impls)]
use std::cell::UnsafeCell;
use std::marker::Sync;