mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rollup merge of #69722 - estebank:negative-impl-span-ast, r=Centril
Tweak output for invalid negative impl AST errors Use more accurate spans for negative `impl` errors. r? @Centril
This commit is contained in:
commit
4f7fc5ad67
@ -2118,14 +2118,14 @@ pub enum ImplPolarity {
|
|||||||
/// `impl Trait for Type`
|
/// `impl Trait for Type`
|
||||||
Positive,
|
Positive,
|
||||||
/// `impl !Trait for Type`
|
/// `impl !Trait for Type`
|
||||||
Negative,
|
Negative(Span),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for ImplPolarity {
|
impl fmt::Debug for ImplPolarity {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
ImplPolarity::Positive => "positive".fmt(f),
|
ImplPolarity::Positive => "positive".fmt(f),
|
||||||
ImplPolarity::Negative => "negative".fmt(f),
|
ImplPolarity::Negative(_) => "negative".fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
use rustc_ast::ast::*;
|
use rustc_ast::ast::*;
|
||||||
use rustc_ast::attr;
|
use rustc_ast::attr;
|
||||||
use rustc_ast::expand::is_proc_macro_attr;
|
use rustc_ast::expand::is_proc_macro_attr;
|
||||||
|
use rustc_ast::ptr::P;
|
||||||
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
|
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
|
||||||
use rustc_ast::walk_list;
|
use rustc_ast::walk_list;
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
@ -594,6 +595,54 @@ impl<'a> AstValidator<'a> {
|
|||||||
.span_label(ident.span, format!("`_` is not a valid name for this `{}` item", kind))
|
.span_label(ident.span, format!("`_` is not a valid name for this `{}` item", kind))
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn deny_generic_params(&self, generics: &Generics, ident_span: Span) {
|
||||||
|
if !generics.params.is_empty() {
|
||||||
|
struct_span_err!(
|
||||||
|
self.session,
|
||||||
|
generics.span,
|
||||||
|
E0567,
|
||||||
|
"auto traits cannot have generic parameters"
|
||||||
|
)
|
||||||
|
.span_label(ident_span, "auto trait cannot have generic parameters")
|
||||||
|
.span_suggestion(
|
||||||
|
generics.span,
|
||||||
|
"remove the parameters",
|
||||||
|
String::new(),
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) {
|
||||||
|
if let [first @ last] | [first, .., last] = &bounds[..] {
|
||||||
|
let span = first.span().to(last.span());
|
||||||
|
struct_span_err!(self.session, span, E0568, "auto traits cannot have super traits")
|
||||||
|
.span_label(ident_span, "auto trait cannot have super traits")
|
||||||
|
.span_suggestion(
|
||||||
|
span,
|
||||||
|
"remove the super traits",
|
||||||
|
String::new(),
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
)
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn deny_items(&self, trait_items: &[P<AssocItem>], ident_span: Span) {
|
||||||
|
if !trait_items.is_empty() {
|
||||||
|
let spans: Vec<_> = trait_items.iter().map(|i| i.ident.span).collect();
|
||||||
|
struct_span_err!(
|
||||||
|
self.session,
|
||||||
|
spans,
|
||||||
|
E0380,
|
||||||
|
"auto traits cannot have methods or associated items"
|
||||||
|
)
|
||||||
|
.span_label(ident_span, "auto trait cannot have items")
|
||||||
|
.emit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn validate_generic_param_order<'a>(
|
fn validate_generic_param_order<'a>(
|
||||||
@ -779,7 +828,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
defaultness: _,
|
defaultness: _,
|
||||||
constness: _,
|
constness: _,
|
||||||
generics: _,
|
generics: _,
|
||||||
of_trait: Some(_),
|
of_trait: Some(ref t),
|
||||||
ref self_ty,
|
ref self_ty,
|
||||||
items: _,
|
items: _,
|
||||||
} => {
|
} => {
|
||||||
@ -794,13 +843,14 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
.help("use `auto trait Trait {}` instead")
|
.help("use `auto trait Trait {}` instead")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
if let (Unsafe::Yes(span), ImplPolarity::Negative) = (unsafety, polarity) {
|
if let (Unsafe::Yes(span), ImplPolarity::Negative(sp)) = (unsafety, polarity) {
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
this.session,
|
this.session,
|
||||||
item.span,
|
sp.to(t.path.span),
|
||||||
E0198,
|
E0198,
|
||||||
"negative impls cannot be unsafe"
|
"negative impls cannot be unsafe"
|
||||||
)
|
)
|
||||||
|
.span_label(sp, "negative because of this")
|
||||||
.span_label(span, "unsafe because of this")
|
.span_label(span, "unsafe because of this")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
@ -816,38 +866,36 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
constness,
|
constness,
|
||||||
generics: _,
|
generics: _,
|
||||||
of_trait: None,
|
of_trait: None,
|
||||||
self_ty: _,
|
ref self_ty,
|
||||||
items: _,
|
items: _,
|
||||||
} => {
|
} => {
|
||||||
|
let error = |annotation_span, annotation| {
|
||||||
|
let mut err = self.err_handler().struct_span_err(
|
||||||
|
self_ty.span,
|
||||||
|
&format!("inherent impls cannot be {}", annotation),
|
||||||
|
);
|
||||||
|
err.span_label(annotation_span, &format!("{} because of this", annotation));
|
||||||
|
err.span_label(self_ty.span, "inherent impl for this type");
|
||||||
|
err
|
||||||
|
};
|
||||||
|
|
||||||
self.invalid_visibility(
|
self.invalid_visibility(
|
||||||
&item.vis,
|
&item.vis,
|
||||||
Some("place qualifiers on individual impl items instead"),
|
Some("place qualifiers on individual impl items instead"),
|
||||||
);
|
);
|
||||||
if let Unsafe::Yes(span) = unsafety {
|
if let Unsafe::Yes(span) = unsafety {
|
||||||
struct_span_err!(
|
error(span, "unsafe").code(error_code!(E0197)).emit();
|
||||||
self.session,
|
|
||||||
item.span,
|
|
||||||
E0197,
|
|
||||||
"inherent impls cannot be unsafe"
|
|
||||||
)
|
|
||||||
.span_label(span, "unsafe because of this")
|
|
||||||
.emit();
|
|
||||||
}
|
}
|
||||||
if polarity == ImplPolarity::Negative {
|
if let ImplPolarity::Negative(span) = polarity {
|
||||||
self.err_handler().span_err(item.span, "inherent impls cannot be negative");
|
error(span, "negative").emit();
|
||||||
}
|
}
|
||||||
if let Defaultness::Default(def_span) = defaultness {
|
if let Defaultness::Default(def_span) = defaultness {
|
||||||
let span = self.session.source_map().def_span(item.span);
|
error(def_span, "`default`")
|
||||||
self.err_handler()
|
|
||||||
.struct_span_err(span, "inherent impls cannot be `default`")
|
|
||||||
.span_label(def_span, "`default` because of this")
|
|
||||||
.note("only trait implementations may be annotated with `default`")
|
.note("only trait implementations may be annotated with `default`")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
if let Const::Yes(span) = constness {
|
if let Const::Yes(span) = constness {
|
||||||
self.err_handler()
|
error(span, "`const`")
|
||||||
.struct_span_err(item.span, "inherent impls cannot be `const`")
|
|
||||||
.span_label(span, "`const` because of this")
|
|
||||||
.note("only trait implementations may be annotated with `const`")
|
.note("only trait implementations may be annotated with `const`")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
@ -882,33 +930,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
ItemKind::Trait(is_auto, _, ref generics, ref bounds, ref trait_items) => {
|
ItemKind::Trait(is_auto, _, ref generics, ref bounds, ref trait_items) => {
|
||||||
if is_auto == IsAuto::Yes {
|
if is_auto == IsAuto::Yes {
|
||||||
// Auto traits cannot have generics, super traits nor contain items.
|
// Auto traits cannot have generics, super traits nor contain items.
|
||||||
if !generics.params.is_empty() {
|
self.deny_generic_params(generics, item.ident.span);
|
||||||
struct_span_err!(
|
self.deny_super_traits(bounds, item.ident.span);
|
||||||
self.session,
|
self.deny_items(trait_items, item.ident.span);
|
||||||
item.span,
|
|
||||||
E0567,
|
|
||||||
"auto traits cannot have generic parameters"
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
|
||||||
if !bounds.is_empty() {
|
|
||||||
struct_span_err!(
|
|
||||||
self.session,
|
|
||||||
item.span,
|
|
||||||
E0568,
|
|
||||||
"auto traits cannot have super traits"
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
|
||||||
if !trait_items.is_empty() {
|
|
||||||
struct_span_err!(
|
|
||||||
self.session,
|
|
||||||
item.span,
|
|
||||||
E0380,
|
|
||||||
"auto traits cannot have methods or associated items"
|
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.no_questions_in_bounds(bounds, "supertraits", true);
|
self.no_questions_in_bounds(bounds, "supertraits", true);
|
||||||
|
|
||||||
@ -1153,9 +1177,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||||||
}) = fk.header()
|
}) = fk.header()
|
||||||
{
|
{
|
||||||
self.err_handler()
|
self.err_handler()
|
||||||
.struct_span_err(span, "functions cannot be both `const` and `async`")
|
.struct_span_err(
|
||||||
|
vec![*cspan, *aspan],
|
||||||
|
"functions cannot be both `const` and `async`",
|
||||||
|
)
|
||||||
.span_label(*cspan, "`const` because of this")
|
.span_label(*cspan, "`const` because of this")
|
||||||
.span_label(*aspan, "`async` because of this")
|
.span_label(*aspan, "`async` because of this")
|
||||||
|
.span_label(span, "") // Point at the fn header.
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,12 +337,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::ItemKind::Impl { polarity, defaultness, .. } => {
|
ast::ItemKind::Impl { polarity, defaultness, ref of_trait, .. } => {
|
||||||
if polarity == ast::ImplPolarity::Negative {
|
if let ast::ImplPolarity::Negative(span) = polarity {
|
||||||
gate_feature_post!(
|
gate_feature_post!(
|
||||||
&self,
|
&self,
|
||||||
optin_builtin_traits,
|
optin_builtin_traits,
|
||||||
i.span,
|
span.to(of_trait.as_ref().map(|t| t.path.span).unwrap_or(span)),
|
||||||
"negative trait bounds are not yet fully implemented; \
|
"negative trait bounds are not yet fully implemented; \
|
||||||
use marker types for now"
|
use marker types for now"
|
||||||
);
|
);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#![feature(bindings_after_at)]
|
||||||
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
|
//! The `rustc_ast_passes` crate contains passes which validate the AST in `syntax`
|
||||||
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
|
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
|
||||||
//! by `rustc_ast_lowering`.
|
//! by `rustc_ast_lowering`.
|
||||||
|
@ -1160,7 +1160,7 @@ impl<'a> State<'a> {
|
|||||||
self.s.space();
|
self.s.space();
|
||||||
}
|
}
|
||||||
|
|
||||||
if polarity == ast::ImplPolarity::Negative {
|
if let ast::ImplPolarity::Negative(_) = polarity {
|
||||||
self.s.word("!");
|
self.s.word("!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ impl<'a> State<'a> {
|
|||||||
self.word_nbsp("const");
|
self.word_nbsp("const");
|
||||||
}
|
}
|
||||||
|
|
||||||
if let hir::ImplPolarity::Negative = polarity {
|
if let hir::ImplPolarity::Negative(_) = polarity {
|
||||||
self.s.word("!");
|
self.s.word("!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,6 +373,16 @@ impl<'a> Parser<'a> {
|
|||||||
self.token.is_keyword(kw::Async) && self.is_keyword_ahead(1, &[kw::Fn])
|
self.token.is_keyword(kw::Async) && self.is_keyword_ahead(1, &[kw::Fn])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_polarity(&mut self) -> ast::ImplPolarity {
|
||||||
|
// Disambiguate `impl !Trait for Type { ... }` and `impl ! { ... }` for the never type.
|
||||||
|
if self.check(&token::Not) && self.look_ahead(1, |t| t.can_begin_type()) {
|
||||||
|
self.bump(); // `!`
|
||||||
|
ast::ImplPolarity::Negative(self.prev_token.span)
|
||||||
|
} else {
|
||||||
|
ast::ImplPolarity::Positive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Parses an implementation item.
|
/// Parses an implementation item.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
@ -411,13 +421,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.sess.gated_spans.gate(sym::const_trait_impl, span);
|
self.sess.gated_spans.gate(sym::const_trait_impl, span);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disambiguate `impl !Trait for Type { ... }` and `impl ! { ... }` for the never type.
|
let polarity = self.parse_polarity();
|
||||||
let polarity = if self.check(&token::Not) && self.look_ahead(1, |t| t.can_begin_type()) {
|
|
||||||
self.bump(); // `!`
|
|
||||||
ast::ImplPolarity::Negative
|
|
||||||
} else {
|
|
||||||
ast::ImplPolarity::Positive
|
|
||||||
};
|
|
||||||
|
|
||||||
// Parse both types and traits as a type, then reinterpret if necessary.
|
// Parse both types and traits as a type, then reinterpret if necessary.
|
||||||
let err_path = |span| ast::Path::from_ident(Ident::new(kw::Invalid, span));
|
let err_path = |span| ast::Path::from_ident(Ident::new(kw::Invalid, span));
|
||||||
|
@ -519,7 +519,7 @@ impl Sig for ast::Item {
|
|||||||
text.push(' ');
|
text.push(' ');
|
||||||
|
|
||||||
let trait_sig = if let Some(ref t) = *of_trait {
|
let trait_sig = if let Some(ref t) = *of_trait {
|
||||||
if polarity == ast::ImplPolarity::Negative {
|
if let ast::ImplPolarity::Negative(_) = polarity {
|
||||||
text.push('!');
|
text.push('!');
|
||||||
}
|
}
|
||||||
let trait_sig = t.path.make(offset + text.len(), id, scx)?;
|
let trait_sig = t.path.make(offset + text.len(), id, scx)?;
|
||||||
|
@ -69,11 +69,11 @@ impl UnsafetyChecker<'tcx> {
|
|||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative) => {
|
(_, _, Unsafety::Unsafe, hir::ImplPolarity::Negative(_)) => {
|
||||||
// Reported in AST validation
|
// Reported in AST validation
|
||||||
self.tcx.sess.delay_span_bug(item.span, "unsafe negative impl");
|
self.tcx.sess.delay_span_bug(item.span, "unsafe negative impl");
|
||||||
}
|
}
|
||||||
(_, _, Unsafety::Normal, hir::ImplPolarity::Negative)
|
(_, _, Unsafety::Normal, hir::ImplPolarity::Negative(_))
|
||||||
| (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive)
|
| (Unsafety::Unsafe, _, Unsafety::Unsafe, hir::ImplPolarity::Positive)
|
||||||
| (Unsafety::Normal, Some(_), Unsafety::Unsafe, hir::ImplPolarity::Positive)
|
| (Unsafety::Normal, Some(_), Unsafety::Unsafe, hir::ImplPolarity::Positive)
|
||||||
| (Unsafety::Normal, None, Unsafety::Normal, _) => {
|
| (Unsafety::Normal, None, Unsafety::Normal, _) => {
|
||||||
|
@ -1548,7 +1548,7 @@ fn impl_polarity(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ImplPolarity {
|
|||||||
let is_rustc_reservation = tcx.has_attr(def_id, sym::rustc_reservation_impl);
|
let is_rustc_reservation = tcx.has_attr(def_id, sym::rustc_reservation_impl);
|
||||||
let item = tcx.hir().expect_item(hir_id);
|
let item = tcx.hir().expect_item(hir_id);
|
||||||
match &item.kind {
|
match &item.kind {
|
||||||
hir::ItemKind::Impl { polarity: hir::ImplPolarity::Negative, .. } => {
|
hir::ItemKind::Impl { polarity: hir::ImplPolarity::Negative(_), .. } => {
|
||||||
if is_rustc_reservation {
|
if is_rustc_reservation {
|
||||||
tcx.sess.span_err(item.span, "reservation impls can't be negative");
|
tcx.sess.span_err(item.span, "reservation impls can't be negative");
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error: functions cannot be both `const` and `async`
|
error: functions cannot be both `const` and `async`
|
||||||
--> $DIR/no-const-async.rs:4:1
|
--> $DIR/no-const-async.rs:4:5
|
||||||
|
|
|
|
||||||
LL | pub const async fn x() {}
|
LL | pub const async fn x() {}
|
||||||
| ^^^^-----^-----^^^^^^^^^^
|
| ----^^^^^-^^^^^----------
|
||||||
| | |
|
| | |
|
||||||
| | `async` because of this
|
| | `async` because of this
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
|
@ -1,20 +1,26 @@
|
|||||||
error[E0567]: auto traits cannot have generic parameters
|
error[E0567]: auto traits cannot have generic parameters
|
||||||
--> $DIR/auto-trait-validation.rs:3:1
|
--> $DIR/auto-trait-validation.rs:3:19
|
||||||
|
|
|
|
||||||
LL | auto trait Generic<T> {}
|
LL | auto trait Generic<T> {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| -------^^^ help: remove the parameters
|
||||||
|
| |
|
||||||
|
| auto trait cannot have generic parameters
|
||||||
|
|
||||||
error[E0568]: auto traits cannot have super traits
|
error[E0568]: auto traits cannot have super traits
|
||||||
--> $DIR/auto-trait-validation.rs:5:1
|
--> $DIR/auto-trait-validation.rs:5:20
|
||||||
|
|
|
|
||||||
LL | auto trait Bound : Copy {}
|
LL | auto trait Bound : Copy {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ----- ^^^^ help: remove the super traits
|
||||||
|
| |
|
||||||
|
| auto trait cannot have super traits
|
||||||
|
|
||||||
error[E0380]: auto traits cannot have methods or associated items
|
error[E0380]: auto traits cannot have methods or associated items
|
||||||
--> $DIR/auto-trait-validation.rs:7:1
|
--> $DIR/auto-trait-validation.rs:7:25
|
||||||
|
|
|
|
||||||
LL | auto trait MyTrait { fn foo() {} }
|
LL | auto trait MyTrait { fn foo() {} }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ------- ^^^
|
||||||
|
| |
|
||||||
|
| auto trait cannot have items
|
||||||
|
|
||||||
error: aborting due to 3 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
error[E0198]: negative impls cannot be unsafe
|
error[E0198]: negative impls cannot be unsafe
|
||||||
--> $DIR/coherence-negative-impls-safe.rs:7:1
|
--> $DIR/coherence-negative-impls-safe.rs:7:13
|
||||||
|
|
|
|
||||||
LL | unsafe impl !Send for TestType {}
|
LL | unsafe impl !Send for TestType {}
|
||||||
| ------^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ------ -^^^^
|
||||||
| |
|
| | |
|
||||||
|
| | negative because of this
|
||||||
| unsafe because of this
|
| unsafe because of this
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0197]: inherent impls cannot be unsafe
|
error[E0197]: inherent impls cannot be unsafe
|
||||||
--> $DIR/E0197.rs:3:1
|
--> $DIR/E0197.rs:3:13
|
||||||
|
|
|
|
||||||
LL | unsafe impl Foo { }
|
LL | unsafe impl Foo { }
|
||||||
| ------^^^^^^^^^^^^^
|
| ------ ^^^ inherent impl for this type
|
||||||
| |
|
| |
|
||||||
| unsafe because of this
|
| unsafe because of this
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
error[E0198]: negative impls cannot be unsafe
|
error[E0198]: negative impls cannot be unsafe
|
||||||
--> $DIR/E0198.rs:5:1
|
--> $DIR/E0198.rs:5:13
|
||||||
|
|
|
|
||||||
LL | unsafe impl !Send for Foo { }
|
LL | unsafe impl !Send for Foo { }
|
||||||
| ------^^^^^^^^^^^^^^^^^^^^^^^
|
| ------ -^^^^
|
||||||
| |
|
| | |
|
||||||
|
| | negative because of this
|
||||||
| unsafe because of this
|
| unsafe because of this
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
@ -8,10 +8,10 @@ LL | auto trait AutoDummyTrait {}
|
|||||||
= help: add `#![feature(optin_builtin_traits)]` to the crate attributes to enable
|
= 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
|
error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now
|
||||||
--> $DIR/feature-gate-optin-builtin-traits.rs:9:1
|
--> $DIR/feature-gate-optin-builtin-traits.rs:9:6
|
||||||
|
|
|
|
||||||
LL | impl !AutoDummyTrait for DummyStruct {}
|
LL | impl !AutoDummyTrait for DummyStruct {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
|
= 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(optin_builtin_traits)]` to the crate attributes to enable
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
|
||||||
unsafe auto trait Trait {
|
unsafe auto trait Trait {
|
||||||
//~^ ERROR E0380
|
type Output; //~ ERROR E0380
|
||||||
type Output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call_method<T: Trait>(x: T) {}
|
fn call_method<T: Trait>(x: T) {}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
error[E0380]: auto traits cannot have methods or associated items
|
error[E0380]: auto traits cannot have methods or associated items
|
||||||
--> $DIR/issue-23080-2.rs:5:1
|
--> $DIR/issue-23080-2.rs:6:10
|
||||||
|
|
|
|
||||||
LL | / unsafe auto trait Trait {
|
LL | unsafe auto trait Trait {
|
||||||
LL | |
|
| ----- auto trait cannot have items
|
||||||
LL | | type Output;
|
LL | type Output;
|
||||||
LL | | }
|
| ^^^^^^
|
||||||
| |_^
|
|
||||||
|
|
||||||
error[E0275]: overflow evaluating the requirement `<() as Trait>::Output`
|
error[E0275]: overflow evaluating the requirement `<() as Trait>::Output`
|
||||||
|
|
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#![feature(optin_builtin_traits)]
|
#![feature(optin_builtin_traits)]
|
||||||
|
|
||||||
unsafe auto trait Trait {
|
unsafe auto trait Trait {
|
||||||
//~^ ERROR E0380
|
fn method(&self) { //~ ERROR E0380
|
||||||
fn method(&self) {
|
|
||||||
println!("Hello");
|
println!("Hello");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
error[E0380]: auto traits cannot have methods or associated items
|
error[E0380]: auto traits cannot have methods or associated items
|
||||||
--> $DIR/issue-23080.rs:3:1
|
--> $DIR/issue-23080.rs:4:8
|
||||||
|
|
|
|
||||||
LL | / unsafe auto trait Trait {
|
LL | unsafe auto trait Trait {
|
||||||
LL | |
|
| ----- auto trait cannot have items
|
||||||
LL | | fn method(&self) {
|
LL | fn method(&self) {
|
||||||
LL | | println!("Hello");
|
| ^^^^^^
|
||||||
LL | | }
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ error: functions cannot be both `const` and `async`
|
|||||||
--> $DIR/fn-header-semantic-fail.rs:13:5
|
--> $DIR/fn-header-semantic-fail.rs:13:5
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn ff5() {} // OK.
|
LL | const async unsafe extern "C" fn ff5() {} // OK.
|
||||||
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^-^^^^^------------------------------
|
||||||
| | |
|
| | |
|
||||||
| | `async` because of this
|
| | `async` because of this
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
@ -45,7 +45,7 @@ error: functions cannot be both `const` and `async`
|
|||||||
--> $DIR/fn-header-semantic-fail.rs:21:9
|
--> $DIR/fn-header-semantic-fail.rs:21:9
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn ft5();
|
LL | const async unsafe extern "C" fn ft5();
|
||||||
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^-^^^^^----------------------------
|
||||||
| | |
|
| | |
|
||||||
| | `async` because of this
|
| | `async` because of this
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
@ -88,7 +88,7 @@ error: functions cannot be both `const` and `async`
|
|||||||
--> $DIR/fn-header-semantic-fail.rs:34:9
|
--> $DIR/fn-header-semantic-fail.rs:34:9
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn ft5() {}
|
LL | const async unsafe extern "C" fn ft5() {}
|
||||||
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^-^^^^^------------------------------
|
||||||
| | |
|
| | |
|
||||||
| | `async` because of this
|
| | `async` because of this
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
@ -97,7 +97,7 @@ error: functions cannot be both `const` and `async`
|
|||||||
--> $DIR/fn-header-semantic-fail.rs:46:9
|
--> $DIR/fn-header-semantic-fail.rs:46:9
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn fi5() {}
|
LL | const async unsafe extern "C" fn fi5() {}
|
||||||
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^-^^^^^------------------------------
|
||||||
| | |
|
| | |
|
||||||
| | `async` because of this
|
| | `async` because of this
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
@ -160,7 +160,7 @@ error: functions cannot be both `const` and `async`
|
|||||||
--> $DIR/fn-header-semantic-fail.rs:55:9
|
--> $DIR/fn-header-semantic-fail.rs:55:9
|
||||||
|
|
|
|
||||||
LL | const async unsafe extern "C" fn fe5();
|
LL | const async unsafe extern "C" fn fe5();
|
||||||
| -----^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^-^^^^^----------------------------
|
||||||
| | |
|
| | |
|
||||||
| | `async` because of this
|
| | `async` because of this
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
error: inherent impls cannot be `const`
|
error: inherent impls cannot be `const`
|
||||||
--> $DIR/inherent-impl.rs:9:1
|
--> $DIR/inherent-impl.rs:9:12
|
||||||
|
|
|
|
||||||
LL | impl const S {}
|
LL | impl const S {}
|
||||||
| ^^^^^-----^^^^^
|
| ----- ^ inherent impl for this type
|
||||||
| |
|
| |
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
|
|
|
|
||||||
= note: only trait implementations may be annotated with `const`
|
= note: only trait implementations may be annotated with `const`
|
||||||
|
|
||||||
error: inherent impls cannot be `const`
|
error: inherent impls cannot be `const`
|
||||||
--> $DIR/inherent-impl.rs:12:1
|
--> $DIR/inherent-impl.rs:12:12
|
||||||
|
|
|
|
||||||
LL | impl const T {}
|
LL | impl const T {}
|
||||||
| ^^^^^-----^^^^^
|
| ----- ^ inherent impl for this type
|
||||||
| |
|
| |
|
||||||
| `const` because of this
|
| `const` because of this
|
||||||
|
|
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error: inherent impls cannot be `default`
|
error: inherent impls cannot be `default`
|
||||||
--> $DIR/validation.rs:7:1
|
--> $DIR/validation.rs:7:14
|
||||||
|
|
|
|
||||||
LL | default impl S {}
|
LL | default impl S {}
|
||||||
| -------^^^^^^^
|
| ------- ^ inherent impl for this type
|
||||||
| |
|
| |
|
||||||
| `default` because of this
|
| `default` because of this
|
||||||
|
|
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now
|
error[E0658]: negative trait bounds are not yet fully implemented; use marker types for now
|
||||||
--> $DIR/syntax-trait-polarity-feature-gate.rs:7:1
|
--> $DIR/syntax-trait-polarity-feature-gate.rs:7:6
|
||||||
|
|
|
|
||||||
LL | impl !Send for TestType {}
|
LL | impl !Send for TestType {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^
|
||||||
|
|
|
|
||||||
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
|
= 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(optin_builtin_traits)]` to the crate attributes to enable
|
||||||
|
@ -1,29 +1,35 @@
|
|||||||
error: inherent impls cannot be negative
|
error: inherent impls cannot be negative
|
||||||
--> $DIR/syntax-trait-polarity.rs:7:1
|
--> $DIR/syntax-trait-polarity.rs:7:7
|
||||||
|
|
|
|
||||||
LL | impl !TestType {}
|
LL | impl !TestType {}
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| -^^^^^^^^ inherent impl for this type
|
||||||
|
| |
|
||||||
|
| negative because of this
|
||||||
|
|
||||||
error[E0198]: negative impls cannot be unsafe
|
error[E0198]: negative impls cannot be unsafe
|
||||||
--> $DIR/syntax-trait-polarity.rs:12:1
|
--> $DIR/syntax-trait-polarity.rs:12:13
|
||||||
|
|
|
|
||||||
LL | unsafe impl !Send for TestType {}
|
LL | unsafe impl !Send for TestType {}
|
||||||
| ------^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ------ -^^^^
|
||||||
| |
|
| | |
|
||||||
|
| | negative because of this
|
||||||
| unsafe because of this
|
| unsafe because of this
|
||||||
|
|
||||||
error: inherent impls cannot be negative
|
error: inherent impls cannot be negative
|
||||||
--> $DIR/syntax-trait-polarity.rs:19:1
|
--> $DIR/syntax-trait-polarity.rs:19:10
|
||||||
|
|
|
|
||||||
LL | impl<T> !TestType2<T> {}
|
LL | impl<T> !TestType2<T> {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| -^^^^^^^^^^^^ inherent impl for this type
|
||||||
|
| |
|
||||||
|
| negative because of this
|
||||||
|
|
||||||
error[E0198]: negative impls cannot be unsafe
|
error[E0198]: negative impls cannot be unsafe
|
||||||
--> $DIR/syntax-trait-polarity.rs:22:1
|
--> $DIR/syntax-trait-polarity.rs:22:16
|
||||||
|
|
|
|
||||||
LL | unsafe impl<T> !Send for TestType2<T> {}
|
LL | unsafe impl<T> !Send for TestType2<T> {}
|
||||||
| ------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ------ -^^^^
|
||||||
| |
|
| | |
|
||||||
|
| | negative because of this
|
||||||
| unsafe because of this
|
| unsafe because of this
|
||||||
|
|
||||||
error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`)
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
error[E0197]: inherent impls cannot be unsafe
|
error[E0197]: inherent impls cannot be unsafe
|
||||||
--> $DIR/trait-safety-inherent-impl.rs:5:1
|
--> $DIR/trait-safety-inherent-impl.rs:5:13
|
||||||
|
|
|
|
||||||
LL | unsafe impl SomeStruct {
|
LL | unsafe impl SomeStruct {
|
||||||
| ^-----
|
| ------ ^^^^^^^^^^ inherent impl for this type
|
||||||
| |
|
| |
|
||||||
| _unsafe because of this
|
| unsafe because of this
|
||||||
| |
|
|
||||||
LL | | fn foo(self) { }
|
|
||||||
LL | | }
|
|
||||||
| |_^
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
error[E0568]: auto traits cannot have super traits
|
error[E0568]: auto traits cannot have super traits
|
||||||
--> $DIR/traits-inductive-overflow-supertrait-oibit.rs:7:1
|
--> $DIR/traits-inductive-overflow-supertrait-oibit.rs:7:19
|
||||||
|
|
|
|
||||||
LL | auto trait Magic: Copy {}
|
LL | auto trait Magic: Copy {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ----- ^^^^ help: remove the super traits
|
||||||
|
| |
|
||||||
|
| auto trait cannot have super traits
|
||||||
|
|
||||||
error[E0277]: the trait bound `NoClone: std::marker::Copy` is not satisfied
|
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:15:23
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
error[E0568]: auto traits cannot have super traits
|
error[E0568]: auto traits cannot have super traits
|
||||||
--> $DIR/typeck-auto-trait-no-supertraits-2.rs:3:1
|
--> $DIR/typeck-auto-trait-no-supertraits-2.rs:3:20
|
||||||
|
|
|
|
||||||
LL | auto trait Magic : Sized where Option<Self> : Magic {}
|
LL | auto trait Magic : Sized where Option<Self> : Magic {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ----- ^^^^^ help: remove the super traits
|
||||||
|
| |
|
||||||
|
| auto trait cannot have super traits
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
error[E0568]: auto traits cannot have super traits
|
error[E0568]: auto traits cannot have super traits
|
||||||
--> $DIR/typeck-auto-trait-no-supertraits.rs:27:1
|
--> $DIR/typeck-auto-trait-no-supertraits.rs:27:19
|
||||||
|
|
|
|
||||||
LL | auto trait Magic: Copy {}
|
LL | auto trait Magic: Copy {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ----- ^^^^ help: remove the super traits
|
||||||
|
| |
|
||||||
|
| auto trait cannot have super traits
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user