Auto merge of #106801 - JohnTitor:rollup-xqkraw0, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #106608 (Render missing generics suggestion verbosely)
 - #106716 ([RFC 2397] Deny incorrect locations)
 - #106754 (Rename `Ty::is_ty_infer` -> `Ty::is_ty_or_numeric_infer`)
 - #106782 (Ignore tests move in git blame)
 - #106785 (Make blame spans better for impl wfcheck)
 - #106791 (Fix ICE formatting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2023-01-13 10:56:53 +00:00
commit 5ca6f7d2c3
52 changed files with 338 additions and 153 deletions

View File

@ -8,3 +8,5 @@ a06baa56b95674fc626b3c3fd680d6a65357fe60
283abbf0e7d20176f76006825b5c52e9a4234e4c
# format libstd/sys
c34fbfaad38cf5829ef5cfe780dc9d58480adeaa
# move tests
cf2dff2b1e3fa55fa5415d524200070d0d7aacfe

View File

@ -79,7 +79,7 @@ impl<'tcx> RegionErrors<'tcx> {
#[track_caller]
pub fn push(&mut self, val: impl Into<RegionErrorKind<'tcx>>) {
let val = val.into();
self.1.sess.delay_span_bug(DUMMY_SP, "{val:?}");
self.1.sess.delay_span_bug(DUMMY_SP, format!("{val:?}"));
self.0.push(val);
}
pub fn is_empty(&self) -> bool {

View File

@ -4,6 +4,9 @@
-passes_see_issue =
see issue #{$issue} <https://github.com/rust-lang/rust/issues/{$issue}> for more information
passes_incorrect_do_not_recommend_location =
`#[do_not_recommend]` can only be placed on trait implementations
passes_outer_crate_level_attr =
crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`

View File

@ -1254,7 +1254,11 @@ fn check_impl<'tcx>(
// therefore don't need to be WF (the trait's `Self: Trait` predicate
// won't hold).
let trait_ref = tcx.impl_trait_ref(item.owner_id).unwrap();
let trait_ref = wfcx.normalize(ast_trait_ref.path.span, None, trait_ref);
let trait_ref = wfcx.normalize(
ast_trait_ref.path.span,
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
trait_ref,
);
let trait_pred = ty::TraitPredicate {
trait_ref,
constness: match constness {
@ -1263,7 +1267,7 @@ fn check_impl<'tcx>(
},
polarity: ty::ImplPolarity::Positive,
};
let obligations = traits::wf::trait_obligations(
let mut obligations = traits::wf::trait_obligations(
wfcx.infcx,
wfcx.param_env,
wfcx.body_id,
@ -1271,6 +1275,13 @@ fn check_impl<'tcx>(
ast_trait_ref.path.span,
item,
);
for obligation in &mut obligations {
if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
&& pred.self_ty().skip_binder() == trait_ref.self_ty()
{
obligation.cause.span = ast_self_ty.span;
}
}
debug!(?obligations);
wfcx.register_obligations(obligations);
}

View File

@ -114,34 +114,46 @@ fn diagnostic_hir_wf_check<'tcx>(
// Get the starting `hir::Ty` using our `WellFormedLoc`.
// We will walk 'into' this type to try to find
// a more precise span for our predicate.
let ty = match loc {
let tys = match loc {
WellFormedLoc::Ty(_) => match hir.get(hir_id) {
hir::Node::ImplItem(item) => match item.kind {
hir::ImplItemKind::Type(ty) => Some(ty),
hir::ImplItemKind::Const(ty, _) => Some(ty),
hir::ImplItemKind::Type(ty) => vec![ty],
hir::ImplItemKind::Const(ty, _) => vec![ty],
ref item => bug!("Unexpected ImplItem {:?}", item),
},
hir::Node::TraitItem(item) => match item.kind {
hir::TraitItemKind::Type(_, ty) => ty,
hir::TraitItemKind::Const(ty, _) => Some(ty),
hir::TraitItemKind::Type(_, ty) => ty.into_iter().collect(),
hir::TraitItemKind::Const(ty, _) => vec![ty],
ref item => bug!("Unexpected TraitItem {:?}", item),
},
hir::Node::Item(item) => match item.kind {
hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _) => Some(ty),
hir::ItemKind::Impl(ref impl_) => {
assert!(impl_.of_trait.is_none(), "Unexpected trait impl: {:?}", impl_);
Some(impl_.self_ty)
}
hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _) => vec![ty],
hir::ItemKind::Impl(ref impl_) => match &impl_.of_trait {
Some(t) => t
.path
.segments
.last()
.iter()
.flat_map(|seg| seg.args().args)
.filter_map(|arg| {
if let hir::GenericArg::Type(ty) = arg { Some(*ty) } else { None }
})
.chain([impl_.self_ty])
.collect(),
None => {
vec![impl_.self_ty]
}
},
ref item => bug!("Unexpected item {:?}", item),
},
hir::Node::Field(field) => Some(field.ty),
hir::Node::Field(field) => vec![field.ty],
hir::Node::ForeignItem(ForeignItem {
kind: ForeignItemKind::Static(ty, _), ..
}) => Some(*ty),
}) => vec![*ty],
hir::Node::GenericParam(hir::GenericParam {
kind: hir::GenericParamKind::Type { default: Some(ty), .. },
..
}) => Some(*ty),
}) => vec![*ty],
ref node => bug!("Unexpected node {:?}", node),
},
WellFormedLoc::Param { function: _, param_idx } => {
@ -149,16 +161,16 @@ fn diagnostic_hir_wf_check<'tcx>(
// Get return type
if param_idx as usize == fn_decl.inputs.len() {
match fn_decl.output {
hir::FnRetTy::Return(ty) => Some(ty),
hir::FnRetTy::Return(ty) => vec![ty],
// The unit type `()` is always well-formed
hir::FnRetTy::DefaultReturn(_span) => None,
hir::FnRetTy::DefaultReturn(_span) => vec![],
}
} else {
Some(&fn_decl.inputs[param_idx as usize])
vec![&fn_decl.inputs[param_idx as usize]]
}
}
};
if let Some(ty) = ty {
for ty in tys {
visitor.visit_ty(ty);
}
visitor.cause

View File

@ -1782,9 +1782,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
// like when you have two references but one is `usize` and the other
// is `f32`. In those cases we still want to show the `note`. If the
// value from `ef` is `Infer(_)`, then we ignore it.
if !ef.expected.is_ty_infer() {
if !ef.expected.is_ty_or_numeric_infer() {
ef.expected != values.expected
} else if !ef.found.is_ty_infer() {
} else if !ef.found.is_ty_or_numeric_infer() {
ef.found != values.found
} else {
false

View File

@ -78,7 +78,7 @@ impl InferenceDiagnosticsData {
}
fn where_x_is_kind(&self, in_type: Ty<'_>) -> &'static str {
if in_type.is_ty_infer() {
if in_type.is_ty_or_numeric_infer() {
""
} else if self.name == "_" {
// FIXME: Consider specializing this message if there is a single `_`
@ -195,12 +195,12 @@ fn ty_to_string<'tcx>(
// invalid pseudo-syntax, we want the `fn`-pointer output instead.
(ty::FnDef(..), _) => ty.fn_sig(infcx.tcx).print(printer).unwrap().into_buffer(),
(_, Some(def_id))
if ty.is_ty_infer()
if ty.is_ty_or_numeric_infer()
&& infcx.tcx.get_diagnostic_item(sym::iterator_collect_fn) == Some(def_id) =>
{
"Vec<_>".to_string()
}
_ if ty.is_ty_infer() => "/* Type */".to_string(),
_ if ty.is_ty_or_numeric_infer() => "/* Type */".to_string(),
// FIXME: The same thing for closures, but this only works when the closure
// does not capture anything.
//
@ -680,7 +680,7 @@ impl<'tcx> InferSourceKind<'tcx> {
| InferSourceKind::ClosureReturn { ty, .. } => {
if ty.is_closure() {
("closure", closure_as_fn_str(infcx, ty))
} else if !ty.is_ty_infer() {
} else if !ty.is_ty_or_numeric_infer() {
("normal", ty_to_string(infcx, ty, None))
} else {
("other", String::new())
@ -813,7 +813,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
self.attempt += 1;
if let Some(InferSource { kind: InferSourceKind::GenericArg { def_id: did, ..}, .. }) = self.infer_source
&& let InferSourceKind::LetBinding { ref ty, ref mut def_id, ..} = new_source.kind
&& ty.is_ty_infer()
&& ty.is_ty_or_numeric_infer()
{
// Customize the output so we talk about `let x: Vec<_> = iter.collect();` instead of
// `let x: _ = iter.collect();`, as this is a very common case.

View File

@ -1686,7 +1686,7 @@ impl<'tcx> Ty<'tcx> {
}
#[inline]
pub fn is_ty_infer(self) -> bool {
pub fn is_ty_or_numeric_infer(self) -> bool {
matches!(self.kind(), Infer(_))
}

View File

@ -202,7 +202,7 @@ impl<'tcx> GenericArg<'tcx> {
pub fn is_non_region_infer(self) -> bool {
match self.unpack() {
GenericArgKind::Lifetime(_) => false,
GenericArgKind::Type(ty) => ty.is_ty_infer(),
GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(),
GenericArgKind::Const(ct) => ct.is_ct_infer(),
}
}

View File

@ -82,6 +82,7 @@ impl CheckAttrVisitor<'_> {
let attrs = self.tcx.hir().attrs(hir_id);
for attr in attrs {
let attr_is_valid = match attr.name_or_empty() {
sym::do_not_recommend => self.check_do_not_recommend(attr.span, target),
sym::inline => self.check_inline(hir_id, attr, span, target),
sym::no_coverage => self.check_no_coverage(hir_id, attr, span, target),
sym::non_exhaustive => self.check_non_exhaustive(hir_id, attr, span, target),
@ -241,6 +242,16 @@ impl CheckAttrVisitor<'_> {
);
}
/// Checks if `#[do_not_recommend]` is applied on a trait impl.
fn check_do_not_recommend(&self, attr_span: Span, target: Target) -> bool {
if let Target::Impl = target {
true
} else {
self.tcx.sess.emit_err(errors::IncorrectDoNotRecommendLocation { span: attr_span });
false
}
}
/// Checks if an `#[inline]` is applied to a function or a closure. Returns `true` if valid.
fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool {
match target {

View File

@ -14,6 +14,13 @@ use rustc_span::{Span, Symbol, DUMMY_SP};
use crate::lang_items::Duplicate;
#[derive(Diagnostic)]
#[diag(passes_incorrect_do_not_recommend_location)]
pub struct IncorrectDoNotRecommendLocation {
#[primary_span]
pub span: Span,
}
#[derive(LintDiagnostic)]
#[diag(passes_outer_crate_level_attr)]
pub struct OuterCrateLevelAttr;

View File

@ -167,7 +167,7 @@ impl<'a> Resolver<'a> {
);
err.emit();
} else if let Some((span, msg, sugg, appl)) = suggestion {
err.span_suggestion(span, msg, sugg, appl);
err.span_suggestion_verbose(span, msg, sugg, appl);
err.emit();
} else if let [segment] = path.as_slice() && is_call {
err.stash(segment.ident.span, rustc_errors::StashKey::CallIntoMethod);

View File

@ -2065,7 +2065,11 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
path: &[Segment],
) -> Option<(Span, &'static str, String, Applicability)> {
let (ident, span) = match path {
[segment] if !segment.has_generic_args && segment.ident.name != kw::SelfUpper => {
[segment]
if !segment.has_generic_args
&& segment.ident.name != kw::SelfUpper
&& segment.ident.name != kw::Dyn =>
{
(segment.ident.to_string(), segment.ident.span)
}
_ => return None,

View File

@ -2252,8 +2252,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
Ok(None) => {
let ambiguities =
ambiguity::recompute_applicable_impls(self.infcx, &obligation);
let has_non_region_infer =
trait_ref.skip_binder().substs.types().any(|t| !t.is_ty_infer());
let has_non_region_infer = trait_ref
.skip_binder()
.substs
.types()
.any(|t| !t.is_ty_or_numeric_infer());
// It doesn't make sense to talk about applicable impls if there are more
// than a handful of them.
if ambiguities.len() > 1 && ambiguities.len() < 10 && has_non_region_infer {

View File

@ -17,9 +17,12 @@ error[E0412]: cannot find type `VAL` in this scope
--> $DIR/ice-6252.rs:10:63
|
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| - ^^^ not found in this scope
| |
| help: you might be missing a type parameter: `, VAL`
| ^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| +++++
error[E0046]: not all trait items implemented, missing: `VAL`
--> $DIR/ice-6252.rs:10:1

View File

@ -1,8 +1,8 @@
error[E0277]: `T` cannot be sent between threads safely
--> $DIR/builtin-superkinds-double-superkind.rs:6:24
--> $DIR/builtin-superkinds-double-superkind.rs:6:32
|
LL | impl <T: Sync+'static> Foo for (T,) { }
| ^^^ `T` cannot be sent between threads safely
| ^^^^ `T` cannot be sent between threads safely
|
= note: required because it appears within the type `(T,)`
note: required by a bound in `Foo`
@ -16,10 +16,10 @@ LL | impl <T: Sync+'static + std::marker::Send> Foo for (T,) { }
| +++++++++++++++++++
error[E0277]: `T` cannot be shared between threads safely
--> $DIR/builtin-superkinds-double-superkind.rs:9:16
--> $DIR/builtin-superkinds-double-superkind.rs:9:24
|
LL | impl <T: Send> Foo for (T,T) { }
| ^^^ `T` cannot be shared between threads safely
| ^^^^^ `T` cannot be shared between threads safely
|
= note: required because it appears within the type `(T, T)`
note: required by a bound in `Foo`

View File

@ -1,8 +1,8 @@
error[E0277]: `T` cannot be sent between threads safely
--> $DIR/builtin-superkinds-in-metadata.rs:13:23
--> $DIR/builtin-superkinds-in-metadata.rs:13:56
|
LL | impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `T` cannot be sent between threads safely
| ^^^^ `T` cannot be sent between threads safely
|
note: required because it appears within the type `X<T>`
--> $DIR/builtin-superkinds-in-metadata.rs:9:8

View File

@ -1,8 +1,8 @@
error[E0277]: `Rc<i8>` cannot be sent between threads safely
--> $DIR/builtin-superkinds-simple.rs:6:6
--> $DIR/builtin-superkinds-simple.rs:6:14
|
LL | impl Foo for std::rc::Rc<i8> { }
| ^^^ `Rc<i8>` cannot be sent between threads safely
| ^^^^^^^^^^^^^^^ `Rc<i8>` cannot be sent between threads safely
|
= help: the trait `Send` is not implemented for `Rc<i8>`
note: required by a bound in `Foo`

View File

@ -1,8 +1,8 @@
error[E0277]: `T` cannot be sent between threads safely
--> $DIR/builtin-superkinds-typaram-not-send.rs:5:24
--> $DIR/builtin-superkinds-typaram-not-send.rs:5:32
|
LL | impl <T: Sync+'static> Foo for T { }
| ^^^ `T` cannot be sent between threads safely
| ^ `T` cannot be sent between threads safely
|
note: required by a bound in `Foo`
--> $DIR/builtin-superkinds-typaram-not-send.rs:3:13

View File

@ -1,8 +1,8 @@
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/impl_wf.rs:11:6
--> $DIR/impl_wf.rs:11:14
|
LL | impl Foo for str { }
| ^^^ doesn't have a size known at compile-time
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
note: required by a bound in `Foo`
@ -12,10 +12,10 @@ LL | trait Foo: Sized { }
| ^^^^^ required by this bound in `Foo`
error[E0277]: the trait bound `f32: Foo` is not satisfied
--> $DIR/impl_wf.rs:22:6
--> $DIR/impl_wf.rs:22:19
|
LL | impl Baz<f32> for f32 { }
| ^^^^^^^^ the trait `Foo` is not implemented for `f32`
| ^^^ the trait `Foo` is not implemented for `f32`
|
= help: the trait `Foo` is implemented for `i32`
note: required by a bound in `Baz`

View File

@ -1,8 +1,8 @@
error[E0283]: type annotations needed: cannot satisfy `u32: C`
--> $DIR/coherence-overlap-trait-alias.rs:15:6
--> $DIR/coherence-overlap-trait-alias.rs:15:12
|
LL | impl C for u32 {}
| ^
| ^^^
|
note: multiple `impl`s satisfying `u32: C` found
--> $DIR/coherence-overlap-trait-alias.rs:14:1

View File

@ -16,10 +16,10 @@ LL | trait Foo<T: ?Sized> : Sized { fn take(self, x: &T) { } } // Note: T is siz
| ++++++++
error[E0277]: the size for values of type `[usize]` cannot be known at compilation time
--> $DIR/dst-sized-trait-param.rs:10:6
--> $DIR/dst-sized-trait-param.rs:10:21
|
LL | impl Foo<isize> for [usize] { }
| ^^^^^^^^^^ doesn't have a size known at compile-time
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[usize]`
note: required by a bound in `Foo`

View File

@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/E0308-2.rs:9:6
--> $DIR/E0308-2.rs:9:13
|
LL | impl Eq for &dyn DynEq {}
| ^^ lifetime mismatch
| ^^^^^^^^^^ lifetime mismatch
|
= note: expected trait `<&dyn DynEq as PartialEq>`
found trait `<&(dyn DynEq + 'static) as PartialEq>`

View File

@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
--> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13
|
LL | impl Struct<T>
| - ^ not found in this scope
| |
| help: you might be missing a type parameter: `<T>`
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | impl<T> Struct<T>
| +++
error[E0412]: cannot find type `T` in this scope
--> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5

View File

@ -2,9 +2,12 @@ error[E0412]: cannot find type `DeviceId` in this scope
--> $DIR/issue-58712.rs:6:20
|
LL | impl<H> AddrVec<H, DeviceId> {
| - ^^^^^^^^ not found in this scope
| |
| help: you might be missing a type parameter: `, DeviceId`
| ^^^^^^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | impl<H, DeviceId> AddrVec<H, DeviceId> {
| ++++++++++
error[E0412]: cannot find type `DeviceId` in this scope
--> $DIR/issue-58712.rs:8:29

View File

@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/issue-65230.rs:8:6
--> $DIR/issue-65230.rs:8:13
|
LL | impl T1 for &dyn T2 {}
| ^^ lifetime mismatch
| ^^^^^^^ lifetime mismatch
|
= note: expected trait `<&dyn T2 as T0>`
found trait `<&(dyn T2 + 'static) as T0>`

View File

@ -13,9 +13,12 @@ error[E0412]: cannot find type `VAL` in this scope
--> $DIR/issue-77919.rs:11:63
|
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| - ^^^ not found in this scope
| |
| help: you might be missing a type parameter: `, VAL`
| ^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | impl<N, M, VAL> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
| +++++
error[E0046]: not all trait items implemented, missing: `VAL`
--> $DIR/issue-77919.rs:11:1

View File

@ -9,8 +9,6 @@ LL | trait Foo<T, T = T> {}
error[E0412]: cannot find type `dyn` in this scope
--> $DIR/issue-86756.rs:5:10
|
LL | fn eq<A, B>() {
| - help: you might be missing a type parameter: `, dyn`
LL | eq::<dyn, Foo>
| ^^^ not found in this scope

View File

@ -1,8 +1,8 @@
error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:6
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:17
|
LL | impl Marker for &'_ () {}
| ^^^^^^
| ^^^^^^
|
note: multiple `impl`s satisfying `&(): Marker` found
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1
@ -13,10 +13,10 @@ LL | impl Marker for &'_ () {}
| ^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed: cannot satisfy `&(): Marker`
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:7:6
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:7:17
|
LL | impl Marker for &'_ () {}
| ^^^^^^
| ^^^^^^
|
note: multiple `impl`s satisfying `&(): Marker` found
--> $DIR/overlap-marker-trait-with-underscore-lifetime.rs:6:1

View File

@ -1,8 +1,8 @@
error[E0283]: type annotations needed: cannot satisfy `(&'static (), &'a ()): A`
--> $DIR/region-overlap.rs:5:10
--> $DIR/region-overlap.rs:5:16
|
LL | impl<'a> A for (&'static (), &'a ()) {}
| ^
| ^^^^^^^^^^^^^^^^^^^^^
|
note: multiple `impl`s satisfying `(&'static (), &'a ()): A` found
--> $DIR/region-overlap.rs:5:1
@ -13,10 +13,10 @@ LL | impl<'a> A for (&'a (), &'static ()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0283]: type annotations needed: cannot satisfy `(&'a (), &'static ()): A`
--> $DIR/region-overlap.rs:6:10
--> $DIR/region-overlap.rs:6:16
|
LL | impl<'a> A for (&'a (), &'static ()) {}
| ^
| ^^^^^^^^^^^^^^^^^^^^^
|
note: multiple `impl`s satisfying `(&'a (), &'static ()): A` found
--> $DIR/region-overlap.rs:5:1

View File

@ -26,17 +26,13 @@ error[E0412]: cannot find type `dyn` in this scope
--> $DIR/dyn-trait-compatibility.rs:5:15
|
LL | type A2 = dyn<dyn, dyn>;
| - ^^^ not found in this scope
| |
| help: you might be missing a type parameter: `<dyn>`
| ^^^ not found in this scope
error[E0412]: cannot find type `dyn` in this scope
--> $DIR/dyn-trait-compatibility.rs:5:20
|
LL | type A2 = dyn<dyn, dyn>;
| - ^^^ not found in this scope
| |
| help: you might be missing a type parameter: `<dyn>`
| ^^^ not found in this scope
error[E0412]: cannot find type `dyn` in this scope
--> $DIR/dyn-trait-compatibility.rs:9:11
@ -48,9 +44,7 @@ error[E0412]: cannot find type `dyn` in this scope
--> $DIR/dyn-trait-compatibility.rs:9:16
|
LL | type A3 = dyn<<dyn as dyn>::dyn>;
| - ^^^ not found in this scope
| |
| help: you might be missing a type parameter: `<dyn>`
| ^^^ not found in this scope
error: aborting due to 8 previous errors

View File

@ -0,0 +1,45 @@
#![feature(do_not_recommend)]
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
const CONST: () = ();
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
static Static: () = ();
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
type Type = ();
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
enum Enum {
}
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
extern {
}
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
fn fun() {
}
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
struct Struct {
}
#[do_not_recommend]
//~^ `#[do_not_recommend]` can only be placed
trait Trait {
}
#[do_not_recommend]
impl Trait for i32 {
}
fn main() {
}

View File

@ -0,0 +1,50 @@
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:3:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:7:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:11:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:15:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:20:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:25:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:30:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: `#[do_not_recommend]` can only be placed on trait implementations
--> $DIR/incorrect-locations.rs:35:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors

View File

@ -1,6 +1,9 @@
trait Foo {
}
#[do_not_recommend]
//~^ ERROR the `#[do_not_recommend]` attribute is an experimental feature
trait Foo {
impl Foo for i32 {
}
fn main() {

View File

@ -1,5 +1,5 @@
error[E0658]: the `#[do_not_recommend]` attribute is an experimental feature
--> $DIR/unstable-feature.rs:1:1
--> $DIR/unstable-feature.rs:4:1
|
LL | #[do_not_recommend]
| ^^^^^^^^^^^^^^^^^^^

View File

@ -1,14 +1,14 @@
error[E0277]: the trait bound `S: ~const Foo` is not satisfied
--> $DIR/super-traits-fail.rs:15:12
--> $DIR/super-traits-fail.rs:15:20
|
LL | impl const Bar for S {}
| ^^^ the trait `~const Foo` is not implemented for `S`
| ^ the trait `~const Foo` is not implemented for `S`
|
note: the trait `Foo` is implemented for `S`, but that implementation is not `const`
--> $DIR/super-traits-fail.rs:15:12
--> $DIR/super-traits-fail.rs:15:20
|
LL | impl const Bar for S {}
| ^^^
| ^
note: required by a bound in `Bar`
--> $DIR/super-traits-fail.rs:8:12
|

View File

@ -1,8 +1,8 @@
error[E0277]: `MyError` doesn't implement `std::fmt::Display`
--> $DIR/issue-71363.rs:4:6
--> $DIR/issue-71363.rs:4:28
|
4 | impl std::error::Error for MyError {}
| ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter
| ^^^^^^^ `MyError` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `MyError`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
@ -10,10 +10,10 @@ note: required by a bound in `std::error::Error`
--> $SRC_DIR/core/src/error.rs:LL:COL
error[E0277]: `MyError` doesn't implement `Debug`
--> $DIR/issue-71363.rs:4:6
--> $DIR/issue-71363.rs:4:28
|
4 | impl std::error::Error for MyError {}
| ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted using `{:?}`
| ^^^^^^^ `MyError` cannot be formatted using `{:?}`
|
= help: the trait `Debug` is not implemented for `MyError`
= note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `B: Clone` is not satisfied
--> $DIR/issue-79224.rs:18:17
--> $DIR/issue-79224.rs:18:29
|
LL | impl<B: ?Sized> Display for Cow<'_, B> {
| ^^^^^^^ the trait `Clone` is not implemented for `B`
| ^^^^^^^^^^ the trait `Clone` is not implemented for `B`
|
= note: required for `B` to implement `ToOwned`
help: consider further restricting this bound

View File

@ -7,10 +7,13 @@ LL | m: Vec<Someunknownname<String, ()>>,
error[E0412]: cannot find type `K` in this scope
--> $DIR/type-not-found-in-adt-field.rs:6:8
|
LL | struct OtherStruct {
| - help: you might be missing a type parameter: `<K>`
LL | m: K,
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | struct OtherStruct<K> {
| +++
error: aborting due to 2 previous errors

View File

@ -1,8 +1,8 @@
error[E0277]: the size for values of type `B` cannot be known at compilation time
--> $DIR/unsized-bound.rs:2:12
--> $DIR/unsized-bound.rs:2:30
|
LL | impl<A, B> Trait<(A, B)> for (A, B) where A: ?Sized, B: ?Sized, {}
| - ^^^^^^^^^^^^^ doesn't have a size known at compile-time
| - ^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|
@ -38,10 +38,10 @@ LL + impl<A, B> Trait<(A, B)> for (A, B) where B: ?Sized, {}
|
error[E0277]: the size for values of type `C` cannot be known at compilation time
--> $DIR/unsized-bound.rs:5:31
--> $DIR/unsized-bound.rs:5:52
|
LL | impl<A, B: ?Sized, C: ?Sized> Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {}
| - ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
| - ^^^^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|
@ -92,10 +92,10 @@ LL + impl<A, B, C: ?Sized> Trait<(A, B, C)> for (A, B, C) where A: ?Sized, {}
|
error[E0277]: the size for values of type `B` cannot be known at compilation time
--> $DIR/unsized-bound.rs:10:28
--> $DIR/unsized-bound.rs:10:47
|
LL | impl<A: ?Sized, B: ?Sized> Trait2<(A, B)> for (A, B) {}
| - ^^^^^^^^^^^^^^ doesn't have a size known at compile-time
| - ^^^^^^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|
@ -131,10 +131,10 @@ LL + impl<A, B: ?Sized> Trait2<(A, B)> for (A, B) {}
|
error[E0277]: the size for values of type `A` cannot be known at compilation time
--> $DIR/unsized-bound.rs:14:9
--> $DIR/unsized-bound.rs:14:23
|
LL | impl<A> Trait3<A> for A where A: ?Sized {}
| - ^^^^^^^^^ doesn't have a size known at compile-time
| - ^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|
@ -154,10 +154,10 @@ LL | trait Trait3<A: ?Sized> {}
| ++++++++
error[E0277]: the size for values of type `A` cannot be known at compilation time
--> $DIR/unsized-bound.rs:17:17
--> $DIR/unsized-bound.rs:17:31
|
LL | impl<A: ?Sized> Trait4<A> for A {}
| - ^^^^^^^^^ doesn't have a size known at compile-time
| - ^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|
@ -177,10 +177,10 @@ LL | trait Trait4<A: ?Sized> {}
| ++++++++
error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized-bound.rs:20:12
--> $DIR/unsized-bound.rs:20:29
|
LL | impl<X, Y> Trait5<X, Y> for X where X: ?Sized {}
| - ^^^^^^^^^^^^ doesn't have a size known at compile-time
| - ^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|
@ -200,10 +200,10 @@ LL | trait Trait5<A: ?Sized, B> {}
| ++++++++
error[E0277]: the size for values of type `X` cannot be known at compilation time
--> $DIR/unsized-bound.rs:23:20
--> $DIR/unsized-bound.rs:23:37
|
LL | impl<X: ?Sized, Y> Trait6<X, Y> for X {}
| - ^^^^^^^^^^^^ doesn't have a size known at compile-time
| - ^ doesn't have a size known at compile-time
| |
| this type parameter needs to be `std::marker::Sized`
|

View File

@ -2,9 +2,12 @@ error[E0412]: cannot find type `Type` in this scope
--> $DIR/ignore-err-impls.rs:6:14
|
LL | impl Generic<Type> for S {}
| - ^^^^ not found in this scope
| |
| help: you might be missing a type parameter: `<Type>`
| ^^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | impl<Type> Generic<Type> for S {}
| ++++++
error: aborting due to previous error

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `isize: Clone2` is not satisfied
--> $DIR/impl-bounds-checking.rs:10:6
--> $DIR/impl-bounds-checking.rs:10:24
|
LL | impl Getter<isize> for isize {
| ^^^^^^^^^^^^^ the trait `Clone2` is not implemented for `isize`
| ^^^^^ the trait `Clone2` is not implemented for `isize`
|
note: required by a bound in `Getter`
--> $DIR/impl-bounds-checking.rs:6:17

View File

@ -1,8 +1,8 @@
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
--> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
--> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:28
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
| ^^^^^^^^^^
| ^^^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
--> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:6
@ -15,10 +15,10 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined he
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
| ^^
note: ...so that the types are compatible
--> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:13
--> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:28
|
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
| ^^^^^^^^^^
| ^^^^^^^^^
= note: expected `T1<'a>`
found `T1<'_>`

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `T: Copy` is not satisfied
--> $DIR/issue-43784-supertrait.rs:8:9
--> $DIR/issue-43784-supertrait.rs:8:22
|
LL | impl<T> Complete for T {}
| ^^^^^^^^ the trait `Copy` is not implemented for `T`
| ^ the trait `Copy` is not implemented for `T`
|
note: required by a bound in `Complete`
--> $DIR/issue-43784-supertrait.rs:4:21

View File

@ -2,9 +2,12 @@ error[E0412]: cannot find type `N` in this scope
--> $DIR/issue-50480.rs:3:12
|
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
| -^ not found in this scope
| |
| help: you might be missing a type parameter: `<N>`
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
| +++
error[E0412]: cannot find type `NotDefined` in this scope
--> $DIR/issue-50480.rs:3:15
@ -16,17 +19,23 @@ error[E0412]: cannot find type `N` in this scope
--> $DIR/issue-50480.rs:3:12
|
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
| -^ not found in this scope
| |
| help: you might be missing a type parameter: `<N>`
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | struct Foo<N>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
| +++
error[E0412]: cannot find type `NotDefined` in this scope
--> $DIR/issue-50480.rs:3:15
|
LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
| - ^^^^^^^^^^ not found in this scope
| |
| help: you might be missing a type parameter: `<NotDefined>`
| ^^^^^^^^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | struct Foo<NotDefined>(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
| ++++++++++++
error[E0412]: cannot find type `N` in this scope
--> $DIR/issue-50480.rs:12:18

View File

@ -2,9 +2,12 @@ error[E0412]: cannot find type `T` in this scope
--> $DIR/issue-75627.rs:3:26
|
LL | unsafe impl Send for Foo<T> {}
| - ^ not found in this scope
| |
| help: you might be missing a type parameter: `<T>`
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | unsafe impl<T> Send for Foo<T> {}
| +++
error: aborting due to previous error

View File

@ -30,9 +30,12 @@ error[E0412]: cannot find type `MISC` in this scope
--> $DIR/issue-78372.rs:3:34
|
LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
| - ^^^^ not found in this scope
| |
| help: you might be missing a type parameter: `, MISC`
| ^^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | impl<T, MISC> DispatchFromDyn<Smaht<U, MISC>> for T {}
| ++++++
error[E0658]: use of unstable library feature 'dispatch_from_dyn'
--> $DIR/issue-78372.rs:1:5

View File

@ -1,8 +1,8 @@
error[E0277]: the trait bound `Foo: HasComponent<()>` is not satisfied
--> $DIR/issue-91594.rs:10:6
--> $DIR/issue-91594.rs:10:19
|
LL | impl HasComponent<<Foo as Component<Foo>>::Interface> for Foo {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `HasComponent<()>` is not implemented for `Foo`
|
= help: the trait `HasComponent<<Foo as Component<Foo>>::Interface>` is implemented for `Foo`
note: required for `Foo` to implement `Component<Foo>`

View File

@ -1,11 +1,13 @@
error[E0412]: cannot find type `Dst` in this scope
--> $DIR/unknown_dst.rs:20:36
|
LL | fn should_gracefully_handle_unknown_dst() {
| - help: you might be missing a type parameter: `<Dst>`
...
LL | assert::is_transmutable::<Src, Dst, Context>();
| ^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | fn should_gracefully_handle_unknown_dst<Dst>() {
| +++++
error: aborting due to previous error

View File

@ -1,11 +1,13 @@
error[E0412]: cannot find type `Src` in this scope
--> $DIR/unknown_src.rs:20:31
|
LL | fn should_gracefully_handle_unknown_src() {
| - help: you might be missing a type parameter: `<Src>`
...
LL | assert::is_transmutable::<Src, Dst, Context>();
| ^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | fn should_gracefully_handle_unknown_src<Src>() {
| +++++
error: aborting due to previous error

View File

@ -1,11 +1,13 @@
error[E0412]: cannot find type `T` in this scope
--> $DIR/autoderef-with-param-env-error.rs:3:5
|
LL | fn foo()
| - help: you might be missing a type parameter: `<T>`
LL | where
LL | T: Send,
| ^ not found in this scope
|
help: you might be missing a type parameter
|
LL | fn foo<T>()
| +++
error: aborting due to previous error

View File

@ -1,10 +1,13 @@
error[E0405]: cannot find trait `Oops` in this scope
--> $DIR/issue-104513-ice.rs:3:19
|
LL | fn f() {
| - help: you might be missing a type parameter: `<Oops>`
LL | let _: S<impl Oops> = S;
| ^^^^ not found in this scope
|
help: you might be missing a type parameter
|
LL | fn f<Oops>() {
| ++++++
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable binding
--> $DIR/issue-104513-ice.rs:3:14