mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 21:47:04 +00:00
Auto merge of #109130 - matthiaskrgr:rollup-dm3jza6, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #108722 (Support for Fuchsia RISC-V target) - #108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests) - #108909 (Fix object safety checks for new RPITITs) - #108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics) - #108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty) - #109101 (Fall back to old metadata computation when type references errors) - #109105 (Don't ICE for late-bound consts across `AnonConstBoundary`) - #109110 (Don't codegen impossible to satisfy impls) - #109116 (Emit diagnostic when calling methods on the unit type in method chains) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
1716932743
@ -404,8 +404,12 @@ impl DefPathData {
|
||||
match *self {
|
||||
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
|
||||
|
||||
// We use this name when collecting `ModChild`s.
|
||||
// FIXME this could probably be removed with some refactoring to the name resolver.
|
||||
ImplTraitAssocTy => Some(kw::Empty),
|
||||
|
||||
Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst
|
||||
| ImplTrait | ImplTraitAssocTy => None,
|
||||
| ImplTrait => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1440,6 +1440,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
tcx.associated_items(pred.def_id())
|
||||
.in_definition_order()
|
||||
.filter(|item| item.kind == ty::AssocKind::Type)
|
||||
.filter(|item| tcx.opt_rpitit_info(item.def_id).is_none())
|
||||
.map(|item| item.def_id),
|
||||
);
|
||||
}
|
||||
|
@ -1427,25 +1427,25 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
||||
if let ResolvedArg::LateBound(..) = def && crossed_anon_const {
|
||||
let use_span = self.tcx.hir().span(hir_id);
|
||||
let def_span = self.tcx.def_span(param_def_id);
|
||||
match self.tcx.def_kind(param_def_id) {
|
||||
let guar = match self.tcx.def_kind(param_def_id) {
|
||||
DefKind::ConstParam => {
|
||||
self.tcx.sess.emit_err(errors::CannotCaptureLateBoundInAnonConst::Const {
|
||||
use_span,
|
||||
def_span,
|
||||
});
|
||||
})
|
||||
}
|
||||
DefKind::TyParam => {
|
||||
self.tcx.sess.emit_err(errors::CannotCaptureLateBoundInAnonConst::Type {
|
||||
use_span,
|
||||
def_span,
|
||||
});
|
||||
})
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
return;
|
||||
};
|
||||
self.map.defs.insert(hir_id, ResolvedArg::Error(guar));
|
||||
} else {
|
||||
self.map.defs.insert(hir_id, def);
|
||||
}
|
||||
|
||||
self.map.defs.insert(hir_id, def);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
self.annotate_expected_due_to_let_ty(err, expr, error);
|
||||
self.emit_type_mismatch_suggestions(err, expr, expr_ty, expected, expected_ty_expr, error);
|
||||
self.note_type_is_not_clone(err, expected, expr_ty, expr);
|
||||
self.note_internal_mutation_in_method(err, expr, expected, expr_ty);
|
||||
self.note_internal_mutation_in_method(err, expr, Some(expected), expr_ty);
|
||||
self.check_for_range_as_method_call(err, expr, expr_ty, expected);
|
||||
self.check_for_binding_assigned_block_without_tail_expression(err, expr, expr_ty, expected);
|
||||
self.check_wrong_return_type_due_to_generic_arg(err, expr, expr_ty);
|
||||
|
@ -950,44 +950,75 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
expr: &hir::Expr<'_>,
|
||||
expected: Ty<'tcx>,
|
||||
expected: Option<Ty<'tcx>>,
|
||||
found: Ty<'tcx>,
|
||||
) {
|
||||
if found != self.tcx.types.unit {
|
||||
return;
|
||||
}
|
||||
if let ExprKind::MethodCall(path_segment, rcvr, ..) = expr.kind {
|
||||
if self
|
||||
.typeck_results
|
||||
|
||||
let ExprKind::MethodCall(path_segment, rcvr, ..) = expr.kind else {
|
||||
return;
|
||||
};
|
||||
|
||||
let rcvr_has_the_expected_type = self
|
||||
.typeck_results
|
||||
.borrow()
|
||||
.expr_ty_adjusted_opt(rcvr)
|
||||
.and_then(|ty| expected.map(|expected_ty| expected_ty.peel_refs() == ty.peel_refs()))
|
||||
.unwrap_or(false);
|
||||
|
||||
let prev_call_mutates_and_returns_unit = || {
|
||||
self.typeck_results
|
||||
.borrow()
|
||||
.expr_ty_adjusted_opt(rcvr)
|
||||
.map_or(true, |ty| expected.peel_refs() != ty.peel_refs())
|
||||
{
|
||||
return;
|
||||
}
|
||||
let mut sp = MultiSpan::from_span(path_segment.ident.span);
|
||||
sp.push_span_label(
|
||||
path_segment.ident.span,
|
||||
format!(
|
||||
"this call modifies {} in-place",
|
||||
match rcvr.kind {
|
||||
ExprKind::Path(QPath::Resolved(
|
||||
None,
|
||||
hir::Path { segments: [segment], .. },
|
||||
)) => format!("`{}`", segment.ident),
|
||||
_ => "its receiver".to_string(),
|
||||
}
|
||||
),
|
||||
);
|
||||
.type_dependent_def_id(expr.hir_id)
|
||||
.map(|def_id| self.tcx.fn_sig(def_id).skip_binder().skip_binder())
|
||||
.and_then(|sig| sig.inputs_and_output.split_last())
|
||||
.map(|(output, inputs)| {
|
||||
output.is_unit()
|
||||
&& inputs
|
||||
.get(0)
|
||||
.and_then(|self_ty| self_ty.ref_mutability())
|
||||
.map_or(false, rustc_ast::Mutability::is_mut)
|
||||
})
|
||||
.unwrap_or(false)
|
||||
};
|
||||
|
||||
if !(rcvr_has_the_expected_type || prev_call_mutates_and_returns_unit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut sp = MultiSpan::from_span(path_segment.ident.span);
|
||||
sp.push_span_label(
|
||||
path_segment.ident.span,
|
||||
format!(
|
||||
"this call modifies {} in-place",
|
||||
match rcvr.kind {
|
||||
ExprKind::Path(QPath::Resolved(
|
||||
None,
|
||||
hir::Path { segments: [segment], .. },
|
||||
)) => format!("`{}`", segment.ident),
|
||||
_ => "its receiver".to_string(),
|
||||
}
|
||||
),
|
||||
);
|
||||
|
||||
let modifies_rcvr_note =
|
||||
format!("method `{}` modifies its receiver in-place", path_segment.ident);
|
||||
if rcvr_has_the_expected_type {
|
||||
sp.push_span_label(
|
||||
rcvr.span,
|
||||
"you probably want to use this value after calling the method...",
|
||||
);
|
||||
err.span_note(sp, &modifies_rcvr_note);
|
||||
err.note(&format!("...instead of the `()` output of method `{}`", path_segment.ident));
|
||||
} else if let ExprKind::MethodCall(..) = rcvr.kind {
|
||||
err.span_note(
|
||||
sp,
|
||||
&format!("method `{}` modifies its receiver in-place", path_segment.ident),
|
||||
modifies_rcvr_note.clone() + ", it is not meant to be used in method chains.",
|
||||
);
|
||||
err.note(&format!("...instead of the `()` output of method `{}`", path_segment.ident));
|
||||
} else {
|
||||
err.span_note(sp, &modifies_rcvr_note);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,6 +416,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
);
|
||||
probe.is_ok()
|
||||
});
|
||||
|
||||
self.note_internal_mutation_in_method(
|
||||
&mut err,
|
||||
rcvr_expr,
|
||||
expected.to_option(&self),
|
||||
rcvr_ty,
|
||||
);
|
||||
}
|
||||
|
||||
let mut custom_span_label = false;
|
||||
|
@ -1356,13 +1356,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
||||
debug!("EncodeContext::encode_info_for_impl_item({:?})", def_id);
|
||||
let tcx = self.tcx;
|
||||
|
||||
let ast_item = self.tcx.hir().expect_impl_item(def_id.expect_local());
|
||||
self.tables.impl_defaultness.set_some(def_id.index, ast_item.defaultness);
|
||||
let defaultness = self.tcx.impl_defaultness(def_id.expect_local());
|
||||
self.tables.impl_defaultness.set_some(def_id.index, defaultness);
|
||||
let impl_item = self.tcx.associated_item(def_id);
|
||||
self.tables.assoc_container.set_some(def_id.index, impl_item.container);
|
||||
|
||||
match impl_item.kind {
|
||||
ty::AssocKind::Fn => {
|
||||
let ast_item = self.tcx.hir().expect_impl_item(def_id.expect_local());
|
||||
let hir::ImplItemKind::Fn(ref sig, body) = ast_item.kind else { bug!() };
|
||||
self.tables.asyncness.set_some(def_id.index, sig.header.asyncness);
|
||||
record_array!(self.tables.fn_arg_names[def_id] <- self.tcx.hir().body_param_names(body));
|
||||
|
@ -316,7 +316,7 @@ impl<'hir> Map<'hir> {
|
||||
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
|
||||
#[inline]
|
||||
pub fn find_by_def_id(self, id: LocalDefId) -> Option<Node<'hir>> {
|
||||
self.find(self.local_def_id_to_hir_id(id))
|
||||
self.find(self.tcx.opt_local_def_id_to_hir_id(id)?)
|
||||
}
|
||||
|
||||
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
|
||||
@ -333,7 +333,7 @@ impl<'hir> Map<'hir> {
|
||||
}
|
||||
|
||||
pub fn get_if_local(self, id: DefId) -> Option<Node<'hir>> {
|
||||
id.as_local().and_then(|id| self.find(self.local_def_id_to_hir_id(id)))
|
||||
id.as_local().and_then(|id| self.find(self.tcx.opt_local_def_id_to_hir_id(id)?))
|
||||
}
|
||||
|
||||
pub fn get_generics(self, id: LocalDefId) -> Option<&'hir Generics<'hir>> {
|
||||
|
@ -730,7 +730,11 @@ where
|
||||
*/
|
||||
};
|
||||
|
||||
let metadata = if let Some(metadata_def_id) = tcx.lang_items().metadata_type() {
|
||||
let metadata = if let Some(metadata_def_id) = tcx.lang_items().metadata_type()
|
||||
// Projection eagerly bails out when the pointee references errors,
|
||||
// fall back to structurally deducing metadata.
|
||||
&& !pointee.references_error()
|
||||
{
|
||||
let metadata = tcx.normalize_erasing_regions(
|
||||
cx.param_env(),
|
||||
tcx.mk_projection(metadata_def_id, [pointee]),
|
||||
|
@ -1326,6 +1326,21 @@ fn create_mono_items_for_default_impls<'tcx>(
|
||||
return;
|
||||
}
|
||||
|
||||
// Unlike 'lazy' monomorphization that begins by collecting items transitively
|
||||
// called by `main` or other global items, when eagerly monomorphizing impl
|
||||
// items, we never actually check that the predicates of this impl are satisfied
|
||||
// in a empty reveal-all param env (i.e. with no assumptions).
|
||||
//
|
||||
// Even though this impl has no substitutions, because we don't consider higher-
|
||||
// ranked predicates such as `for<'a> &'a mut [u8]: Copy` to be trivially false,
|
||||
// we must now check that the impl has no impossible-to-satisfy predicates.
|
||||
if tcx.subst_and_check_impossible_predicates((
|
||||
item.owner_id.to_def_id(),
|
||||
&InternalSubsts::identity_for_item(tcx, item.owner_id.to_def_id()),
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(trait_ref) = tcx.impl_trait_ref(item.owner_id) else {
|
||||
return;
|
||||
};
|
||||
|
@ -1115,6 +1115,7 @@ supported_targets! {
|
||||
// FIXME(#106649): Remove aarch64-fuchsia in favor of aarch64-unknown-fuchsia
|
||||
("aarch64-fuchsia", aarch64_fuchsia),
|
||||
("aarch64-unknown-fuchsia", aarch64_unknown_fuchsia),
|
||||
("riscv64gc-unknown-fuchsia", riscv64gc_unknown_fuchsia),
|
||||
// FIXME(#106649): Remove x86_64-fuchsia in favor of x86_64-unknown-fuchsia
|
||||
("x86_64-fuchsia", x86_64_fuchsia),
|
||||
("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia),
|
||||
|
19
compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs
Normal file
19
compiler/rustc_target/src/spec/riscv64gc_unknown_fuchsia.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
Target {
|
||||
llvm_target: "riscv64gc-unknown-fuchsia".into(),
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
|
||||
arch: "riscv64".into(),
|
||||
options: TargetOptions {
|
||||
code_model: Some(CodeModel::Medium),
|
||||
cpu: "generic-rv64".into(),
|
||||
features: "+m,+a,+f,+d,+c".into(),
|
||||
llvm_abiname: "lp64d".into(),
|
||||
max_atomic_width: Some(64),
|
||||
supported_sanitizers: SanitizerSet::SHADOWCALLSTACK,
|
||||
..super::fuchsia_base::opts()
|
||||
},
|
||||
}
|
||||
}
|
@ -144,6 +144,10 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
obligation: &PredicateObligation<'tcx>,
|
||||
) -> OnUnimplementedNote {
|
||||
if self.tcx.opt_rpitit_info(obligation.cause.body_id.to_def_id()).is_some() {
|
||||
return OnUnimplementedNote::default();
|
||||
}
|
||||
|
||||
let (def_id, substs) = self
|
||||
.impl_similar_to(trait_ref, obligation)
|
||||
.unwrap_or_else(|| (trait_ref.def_id(), trait_ref.skip_binder().substs));
|
||||
|
@ -13,7 +13,6 @@ use super::{elaborate_predicates, elaborate_trait_ref};
|
||||
use crate::infer::TyCtxtInferExt;
|
||||
use crate::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use crate::traits::{self, Obligation, ObligationCause};
|
||||
use hir::def::DefKind;
|
||||
use rustc_errors::{DelayDm, FatalError, MultiSpan};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -157,6 +156,7 @@ fn object_safety_violations_for_trait(
|
||||
.in_definition_order()
|
||||
.filter(|item| item.kind == ty::AssocKind::Type)
|
||||
.filter(|item| !tcx.generics_of(item.def_id).params.is_empty())
|
||||
.filter(|item| tcx.opt_rpitit_info(item.def_id).is_none())
|
||||
.map(|item| {
|
||||
let ident = item.ident(tcx);
|
||||
ObjectSafetyViolation::GAT(ident.name, ident.span)
|
||||
@ -854,7 +854,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<TyCtxt<'tcx>>>(
|
||||
}
|
||||
}
|
||||
ty::Alias(ty::Projection, ref data)
|
||||
if self.tcx.def_kind(data.def_id) == DefKind::ImplTraitPlaceholder =>
|
||||
if self.tcx.is_impl_trait_in_trait(data.def_id) =>
|
||||
{
|
||||
// We'll deny these later in their own pass
|
||||
ControlFlow::Continue(())
|
||||
@ -921,7 +921,7 @@ pub fn contains_illegal_impl_trait_in_trait<'tcx>(
|
||||
ty.skip_binder().walk().find_map(|arg| {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
&& let ty::Alias(ty::Projection, proj) = ty.kind()
|
||||
&& tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
|
||||
&& tcx.is_impl_trait_in_trait(proj.def_id)
|
||||
{
|
||||
Some(MethodViolationCode::ReferencesImplTraitInTrait(tcx.def_span(proj.def_id)))
|
||||
} else {
|
||||
|
@ -328,6 +328,9 @@ fn impl_associated_item_for_impl_trait_in_trait(
|
||||
// `opt_local_def_id_to_hir_id` with `None`.
|
||||
impl_assoc_ty.opt_local_def_id_to_hir_id(None);
|
||||
|
||||
// Copy span of the opaque.
|
||||
impl_assoc_ty.def_ident_span(Some(span));
|
||||
|
||||
impl_assoc_ty.associated_item(ty::AssocItem {
|
||||
name: kw::Empty,
|
||||
kind: ty::AssocKind::Type,
|
||||
@ -342,6 +345,9 @@ fn impl_associated_item_for_impl_trait_in_trait(
|
||||
// extra predicates to assume.
|
||||
impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id));
|
||||
|
||||
// Copy visility of the containing function.
|
||||
impl_assoc_ty.visibility(tcx.visibility(impl_fn_def_id));
|
||||
|
||||
// Copy impl_defaultness of the containing function.
|
||||
impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id));
|
||||
|
||||
|
@ -156,7 +156,11 @@ fn layout_of_uncached<'tcx>(
|
||||
|
||||
let unsized_part = tcx.struct_tail_erasing_lifetimes(pointee, param_env);
|
||||
|
||||
let metadata = if let Some(metadata_def_id) = tcx.lang_items().metadata_type() {
|
||||
let metadata = if let Some(metadata_def_id) = tcx.lang_items().metadata_type()
|
||||
// Projection eagerly bails out when the pointee references errors,
|
||||
// fall back to structurally deducing metadata.
|
||||
&& !pointee.references_error()
|
||||
{
|
||||
let metadata_ty = tcx.normalize_erasing_regions(
|
||||
param_env,
|
||||
tcx.mk_projection(metadata_def_id, [pointee]),
|
||||
|
@ -295,6 +295,7 @@ target | std | host | notes
|
||||
[`riscv32imac-unknown-xous-elf`](platform-support/riscv32imac-unknown-xous-elf.md) | ? | | RISC-V Xous (RV32IMAC ISA)
|
||||
`riscv32imc-esp-espidf` | ✓ | | RISC-V ESP-IDF
|
||||
`riscv64gc-unknown-freebsd` | | | RISC-V FreeBSD
|
||||
`riscv64gc-unknown-fuchsia` | | | RISC-V Fuchsia
|
||||
`riscv64gc-unknown-linux-musl` | | | RISC-V Linux (kernel 4.20, musl 1.2.0)
|
||||
[`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64
|
||||
`s390x-unknown-linux-musl` | | | S390x Linux (kernel 3.2, MUSL)
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(impl_trait_projections)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0053]: method `foo` has an incompatible type for trait
|
||||
--> $DIR/async-example-desugared-boxed-in-trait.rs:15:28
|
||||
--> $DIR/async-example-desugared-boxed-in-trait.rs:17:28
|
||||
|
|
||||
LL | async fn foo(&self) -> i32 {
|
||||
| ^^^ expected `Pin<Box<dyn Future<Output = i32>>>`, found future
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/async-example-desugared-boxed-in-trait.rs:11:22
|
||||
--> $DIR/async-example-desugared-boxed-in-trait.rs:13:22
|
||||
|
|
||||
LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
@ -0,0 +1,17 @@
|
||||
error[E0053]: method `foo` has an incompatible type for trait
|
||||
--> $DIR/async-example-desugared-boxed-in-trait.rs:17:28
|
||||
|
|
||||
LL | async fn foo(&self) -> i32 {
|
||||
| ^^^ expected `Pin<Box<dyn Future<Output = i32>>>`, found future
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/async-example-desugared-boxed-in-trait.rs:13:22
|
||||
|
|
||||
LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: expected signature `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>`
|
||||
found signature `fn(&i32) -> impl Future<Output = i32>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0053`.
|
@ -1,4 +1,6 @@
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: method `foo` should be async because the method from the trait is async
|
||||
--> $DIR/async-example-desugared-boxed.rs:15:5
|
||||
--> $DIR/async-example-desugared-boxed.rs:17:5
|
||||
|
|
||||
LL | async fn foo(&self) -> i32;
|
||||
| --------------------------- required because the trait method is async
|
@ -0,0 +1,11 @@
|
||||
error: method `foo` should be async because the method from the trait is async
|
||||
--> $DIR/async-example-desugared-boxed.rs:17:5
|
||||
|
|
||||
LL | async fn foo(&self) -> i32;
|
||||
| --------------------------- required because the trait method is async
|
||||
...
|
||||
LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,4 +1,6 @@
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: method `foo` should be async because the method from the trait is async
|
||||
--> $DIR/async-example-desugared-manual.rs:23:5
|
||||
--> $DIR/async-example-desugared-manual.rs:25:5
|
||||
|
|
||||
LL | async fn foo(&self) -> i32;
|
||||
| --------------------------- required because the trait method is async
|
@ -0,0 +1,11 @@
|
||||
error: method `foo` should be async because the method from the trait is async
|
||||
--> $DIR/async-example-desugared-manual.rs:25:5
|
||||
|
|
||||
LL | async fn foo(&self) -> i32;
|
||||
| --------------------------- required because the trait method is async
|
||||
...
|
||||
LL | fn foo(&self) -> MyFuture {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,4 +1,6 @@
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0733]: recursion in an `async fn` requires boxing
|
||||
--> $DIR/async-recursive-generic.rs:11:48
|
||||
--> $DIR/async-recursive-generic.rs:13:48
|
||||
|
|
||||
LL | async fn foo_recursive(&self, n: usize) -> T {
|
||||
| ^ recursive `async fn`
|
@ -0,0 +1,12 @@
|
||||
error[E0733]: recursion in an `async fn` requires boxing
|
||||
--> $DIR/async-recursive-generic.rs:13:48
|
||||
|
|
||||
LL | async fn foo_recursive(&self, n: usize) -> T {
|
||||
| ^ recursive `async fn`
|
||||
|
|
||||
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
|
||||
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0733`.
|
@ -1,4 +1,6 @@
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0733]: recursion in an `async fn` requires boxing
|
||||
--> $DIR/async-recursive.rs:11:48
|
||||
--> $DIR/async-recursive.rs:13:48
|
||||
|
|
||||
LL | async fn foo_recursive(&self, n: usize) -> i32 {
|
||||
| ^^^ recursive `async fn`
|
12
tests/ui/async-await/in-trait/async-recursive.next.stderr
Normal file
12
tests/ui/async-await/in-trait/async-recursive.next.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0733]: recursion in an `async fn` requires boxing
|
||||
--> $DIR/async-recursive.rs:13:48
|
||||
|
|
||||
LL | async fn foo_recursive(&self, n: usize) -> i32 {
|
||||
| ^^^ recursive `async fn`
|
||||
|
|
||||
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
|
||||
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0733`.
|
@ -1,4 +1,6 @@
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,11 +1,11 @@
|
||||
error: expected identifier, found keyword `self`
|
||||
--> $DIR/bad-signatures.rs:7:23
|
||||
--> $DIR/bad-signatures.rs:9:23
|
||||
|
|
||||
LL | async fn bar(&abc self);
|
||||
| ^^^^ expected identifier, found keyword
|
||||
|
||||
error: expected one of `:`, `@`, or `|`, found keyword `self`
|
||||
--> $DIR/bad-signatures.rs:7:23
|
||||
--> $DIR/bad-signatures.rs:9:23
|
||||
|
|
||||
LL | async fn bar(&abc self);
|
||||
| -----^^^^
|
||||
@ -14,7 +14,7 @@ LL | async fn bar(&abc self);
|
||||
| help: declare the type after the parameter binding: `<identifier>: <type>`
|
||||
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/bad-signatures.rs:3:12
|
||||
--> $DIR/bad-signatures.rs:5:12
|
||||
|
|
||||
LL | #![feature(async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
26
tests/ui/async-await/in-trait/bad-signatures.next.stderr
Normal file
26
tests/ui/async-await/in-trait/bad-signatures.next.stderr
Normal file
@ -0,0 +1,26 @@
|
||||
error: expected identifier, found keyword `self`
|
||||
--> $DIR/bad-signatures.rs:9:23
|
||||
|
|
||||
LL | async fn bar(&abc self);
|
||||
| ^^^^ expected identifier, found keyword
|
||||
|
||||
error: expected one of `:`, `@`, or `|`, found keyword `self`
|
||||
--> $DIR/bad-signatures.rs:9:23
|
||||
|
|
||||
LL | async fn bar(&abc self);
|
||||
| -----^^^^
|
||||
| | |
|
||||
| | expected one of `:`, `@`, or `|`
|
||||
| help: declare the type after the parameter binding: `<identifier>: <type>`
|
||||
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/bad-signatures.rs:5:12
|
||||
|
|
||||
LL | #![feature(async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: aborting due to 2 previous errors; 1 warning emitted
|
||||
|
@ -1,4 +1,6 @@
|
||||
// edition:2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
//~^ WARN the feature `async_fn_in_trait` is incomplete
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition:2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition:2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types
|
||||
--> $DIR/fn-not-async-err2.rs:13:22
|
||||
--> $DIR/fn-not-async-err2.rs:15:22
|
||||
|
|
||||
LL | fn foo(&self) -> impl Future<Output = i32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
12
tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr
Normal file
12
tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types
|
||||
--> $DIR/fn-not-async-err2.rs:15:22
|
||||
|
|
||||
LL | fn foo(&self) -> impl Future<Output = i32> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
= help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0562`.
|
@ -1,4 +1,6 @@
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition: 2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// edition:2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,6 +1,8 @@
|
||||
// compile-flags:--crate-type=lib
|
||||
// edition:2021
|
||||
// check-pass
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/object-safety.rs:3:12
|
||||
--> $DIR/object-safety.rs:5:12
|
||||
|
|
||||
LL | #![feature(async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
@ -8,13 +8,13 @@ LL | #![feature(async_fn_in_trait)]
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:11:12
|
||||
--> $DIR/object-safety.rs:13:12
|
||||
|
|
||||
LL | let x: &dyn Foo = todo!();
|
||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:7:14
|
||||
--> $DIR/object-safety.rs:9:14
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
27
tests/ui/async-await/in-trait/object-safety.next.stderr
Normal file
27
tests/ui/async-await/in-trait/object-safety.next.stderr
Normal file
@ -0,0 +1,27 @@
|
||||
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/object-safety.rs:5:12
|
||||
|
|
||||
LL | #![feature(async_fn_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:13:12
|
||||
|
|
||||
LL | let x: &dyn Foo = todo!();
|
||||
| ^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:9:14
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
LL | async fn foo(&self);
|
||||
| ^^^ ...because method `foo` is `async`
|
||||
= help: consider moving `foo` to another trait
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
@ -1,4 +1,6 @@
|
||||
// edition:2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(async_fn_in_trait)]
|
||||
//~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
|
13
tests/ui/codegen/mono-impossible.rs
Normal file
13
tests/ui/codegen/mono-impossible.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// compile-flags: -Clink-dead-code=on --crate-type=lib
|
||||
// build-pass
|
||||
|
||||
// Make sure that we don't monomorphize the impossible method `<() as Visit>::visit`,
|
||||
// which does not hold under a reveal-all param env.
|
||||
|
||||
pub trait Visit {
|
||||
fn visit() {}
|
||||
}
|
||||
|
||||
pub trait Array<'a> {}
|
||||
|
||||
impl Visit for () where (): for<'a> Array<'a> {}
|
@ -1,4 +1,6 @@
|
||||
// check-pass
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
@ -10,7 +12,9 @@ trait Foo {
|
||||
}
|
||||
|
||||
impl Foo for () {
|
||||
fn bar() -> Wrapper<i32> { Wrapper(0) }
|
||||
fn bar() -> Wrapper<i32> {
|
||||
Wrapper(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error[E0053]: method `bar` has an incompatible return type for trait
|
||||
--> $DIR/deep-match.rs:11:17
|
||||
--> $DIR/deep-match.rs:14:17
|
||||
|
|
||||
LL | fn bar() -> i32 { 0 }
|
||||
LL | fn bar() -> i32 {
|
||||
| ^^^
|
||||
| |
|
||||
| expected `Wrapper<_>`, found `i32`
|
15
tests/ui/impl-trait/in-trait/deep-match.next.stderr
Normal file
15
tests/ui/impl-trait/in-trait/deep-match.next.stderr
Normal file
@ -0,0 +1,15 @@
|
||||
error[E0053]: method `bar` has an incompatible return type for trait
|
||||
--> $DIR/deep-match.rs:14:17
|
||||
|
|
||||
LL | fn bar() -> i32 {
|
||||
| ^^^
|
||||
| |
|
||||
| expected `Wrapper<_>`, found `i32`
|
||||
| return type in trait
|
||||
|
|
||||
= note: expected struct `Wrapper<_>`
|
||||
found type `i32`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0053`.
|
@ -1,3 +1,6 @@
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
@ -8,8 +11,10 @@ trait Foo {
|
||||
}
|
||||
|
||||
impl Foo for () {
|
||||
fn bar() -> i32 { 0 }
|
||||
//~^ ERROR method `bar` has an incompatible return type for trait
|
||||
fn bar() -> i32 {
|
||||
//~^ ERROR method `bar` has an incompatible return type for trait
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/default-method-binder-shifting.rs:3:12
|
||||
--> $DIR/default-method-binder-shifting.rs:5:12
|
||||
|
|
||||
LL | #![feature(return_position_impl_trait_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
@ -0,0 +1,11 @@
|
||||
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/default-method-binder-shifting.rs:5:12
|
||||
|
|
||||
LL | #![feature(return_position_impl_trait_in_trait)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
@ -1,4 +1,6 @@
|
||||
// check-pass
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete
|
||||
|
@ -1,5 +1,7 @@
|
||||
// build-pass
|
||||
// compile-flags: --crate-type=lib
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,7 @@
|
||||
// check-pass
|
||||
// aux-build: rpitit.rs
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
extern crate rpitit;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
||||
--> $DIR/issue-102140.rs:23:22
|
||||
--> $DIR/issue-102140.rs:26:22
|
||||
|
|
||||
LL | MyTrait::foo(&self)
|
||||
| ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
||||
@ -13,7 +13,7 @@ LL + MyTrait::foo(self)
|
||||
|
|
||||
|
||||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
||||
--> $DIR/issue-102140.rs:23:9
|
||||
--> $DIR/issue-102140.rs:26:9
|
||||
|
|
||||
LL | MyTrait::foo(&self)
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
||||
@ -21,7 +21,7 @@ LL | MyTrait::foo(&self)
|
||||
= help: the trait `MyTrait` is implemented for `Outer`
|
||||
|
||||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
||||
--> $DIR/issue-102140.rs:23:9
|
||||
--> $DIR/issue-102140.rs:26:9
|
||||
|
|
||||
LL | MyTrait::foo(&self)
|
||||
| ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
33
tests/ui/impl-trait/in-trait/issue-102140.next.stderr
Normal file
33
tests/ui/impl-trait/in-trait/issue-102140.next.stderr
Normal file
@ -0,0 +1,33 @@
|
||||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
||||
--> $DIR/issue-102140.rs:26:22
|
||||
|
|
||||
LL | MyTrait::foo(&self)
|
||||
| ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
||||
| |
|
||||
| required by a bound introduced by this call
|
||||
|
|
||||
help: consider removing the leading `&`-reference
|
||||
|
|
||||
LL - MyTrait::foo(&self)
|
||||
LL + MyTrait::foo(self)
|
||||
|
|
||||
|
||||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
||||
--> $DIR/issue-102140.rs:26:9
|
||||
|
|
||||
LL | MyTrait::foo(&self)
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
||||
|
|
||||
= help: the trait `MyTrait` is implemented for `Outer`
|
||||
|
||||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
||||
--> $DIR/issue-102140.rs:26:9
|
||||
|
|
||||
LL | MyTrait::foo(&self)
|
||||
| ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait`
|
||||
|
|
||||
= help: the trait `MyTrait` is implemented for `Outer`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
@ -1,3 +1,6 @@
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
// check-pass
|
||||
// compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
trait Foo {
|
||||
fn foo() -> impl Sized;
|
||||
}
|
||||
|
||||
impl Foo for String {
|
||||
fn foo() -> i32 {
|
||||
22
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,11 +0,0 @@
|
||||
// check-pass
|
||||
// compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
trait Foo {
|
||||
fn foo() -> impl Sized;
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,11 +1,26 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:17:33
|
||||
--> $DIR/object-safety.rs:20:33
|
||||
|
|
||||
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:7:22
|
||||
--> $DIR/object-safety.rs:10:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
LL | fn baz(&self) -> impl Debug;
|
||||
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:23:13
|
||||
|
|
||||
LL | let s = i.baz();
|
||||
| ^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:10:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
@ -16,26 +31,11 @@ LL | fn baz(&self) -> impl Debug;
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:20:13
|
||||
|
|
||||
LL | let s = i.baz();
|
||||
| ^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:7:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
LL | fn baz(&self) -> impl Debug;
|
||||
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:17:13
|
||||
|
|
||||
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:7:22
|
||||
--> $DIR/object-safety.rs:10:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
50
tests/ui/impl-trait/in-trait/object-safety.next.stderr
Normal file
50
tests/ui/impl-trait/in-trait/object-safety.next.stderr
Normal file
@ -0,0 +1,50 @@
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:20:33
|
||||
|
|
||||
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:10:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
LL | fn baz(&self) -> impl Debug;
|
||||
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:23:13
|
||||
|
|
||||
LL | let s = i.baz();
|
||||
| ^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:10:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
LL | fn baz(&self) -> impl Debug;
|
||||
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
|
||||
error[E0038]: the trait `Foo` cannot be made into an object
|
||||
--> $DIR/object-safety.rs:20:13
|
||||
|
|
||||
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
|
||||
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/object-safety.rs:10:22
|
||||
|
|
||||
LL | trait Foo {
|
||||
| --- this trait cannot be made into an object...
|
||||
LL | fn baz(&self) -> impl Debug;
|
||||
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
|
||||
= help: consider moving `baz` to another trait
|
||||
= note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>`
|
||||
= note: required by cast to type `Box<dyn Foo>`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0038`.
|
@ -1,3 +1,6 @@
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/opaque-in-impl-is-opaque.rs:17:19
|
||||
--> $DIR/opaque-in-impl-is-opaque.rs:20:19
|
||||
|
|
||||
LL | fn bar(&self) -> impl Display {
|
||||
| ------------ the found opaque type
|
@ -0,0 +1,17 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/opaque-in-impl-is-opaque.rs:20:19
|
||||
|
|
||||
LL | fn bar(&self) -> impl Display {
|
||||
| ------------ the found opaque type
|
||||
...
|
||||
LL | let x: &str = ().bar();
|
||||
| ---- ^^^^^^^^ expected `&str`, found opaque type
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected reference `&str`
|
||||
found opaque type `impl std::fmt::Display`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
@ -1,3 +1,6 @@
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
// check-pass
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/signature-mismatch.rs:15:5
|
||||
--> $DIR/signature-mismatch.rs:17:5
|
||||
|
|
||||
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
|
||||
| ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
|
16
tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr
Normal file
16
tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr
Normal file
@ -0,0 +1,16 @@
|
||||
error: `impl` item signature doesn't match `trait` item signature
|
||||
--> $DIR/signature-mismatch.rs:17:5
|
||||
|
|
||||
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
|
||||
| ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
|
||||
...
|
||||
LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
|
||||
|
|
||||
= note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
|
||||
found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
|
||||
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
|
||||
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,4 +1,6 @@
|
||||
// edition:2021
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
@ -1,4 +1,6 @@
|
||||
// check-pass
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(specialization)]
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
|
@ -1,4 +1,6 @@
|
||||
// check-pass
|
||||
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
|
||||
// revisions: current next
|
||||
|
||||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
8
tests/ui/layout/transmute-to-tail-with-err.rs
Normal file
8
tests/ui/layout/transmute-to-tail-with-err.rs
Normal file
@ -0,0 +1,8 @@
|
||||
trait Trait<T> {}
|
||||
|
||||
struct Bar(Box<dyn Trait<T>>);
|
||||
//~^ ERROR cannot find type `T` in this scope
|
||||
|
||||
fn main() {
|
||||
let x: Bar = unsafe { std::mem::transmute(()) };
|
||||
}
|
14
tests/ui/layout/transmute-to-tail-with-err.stderr
Normal file
14
tests/ui/layout/transmute-to-tail-with-err.stderr
Normal file
@ -0,0 +1,14 @@
|
||||
error[E0412]: cannot find type `T` in this scope
|
||||
--> $DIR/transmute-to-tail-with-err.rs:3:26
|
||||
|
|
||||
LL | struct Bar(Box<dyn Trait<T>>);
|
||||
| ^ not found in this scope
|
||||
|
|
||||
help: you might be missing a type parameter
|
||||
|
|
||||
LL | struct Bar<T>(Box<dyn Trait<T>>);
|
||||
| +++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0412`.
|
@ -1,4 +1,8 @@
|
||||
fn main() {}
|
||||
fn main() {
|
||||
let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i); //~ ERROR mismatched types
|
||||
vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); //~ ERROR no method named `sort` found for unit type `()` in the current scope
|
||||
}
|
||||
|
||||
fn foo(mut s: String) -> String {
|
||||
s.push_str("asdf") //~ ERROR mismatched types
|
||||
}
|
||||
|
@ -1,5 +1,33 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:3:5
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:2:23
|
||||
|
|
||||
LL | let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i);
|
||||
| -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Vec<i32>`, found `()`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Vec<i32>`
|
||||
found unit type `()`
|
||||
note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:2:71
|
||||
|
|
||||
LL | let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i);
|
||||
| ^^^^^^^^^^^ this call modifies its receiver in-place
|
||||
|
||||
error[E0599]: no method named `sort` found for unit type `()` in the current scope
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:3:72
|
||||
|
|
||||
LL | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
|
||||
| ^^^^ method not found in `()`
|
||||
|
|
||||
note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains.
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:3:53
|
||||
|
|
||||
LL | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort();
|
||||
| ^^^^^^^^^^^ this call modifies its receiver in-place
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:7:5
|
||||
|
|
||||
LL | fn foo(mut s: String) -> String {
|
||||
| ------ expected `String` because of return type
|
||||
@ -7,7 +35,7 @@ LL | s.push_str("asdf")
|
||||
| ^^^^^^^^^^^^^^^^^^ expected `String`, found `()`
|
||||
|
|
||||
note: method `push_str` modifies its receiver in-place
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:3:7
|
||||
--> $DIR/chain-method-call-mutation-in-place.rs:7:7
|
||||
|
|
||||
LL | s.push_str("asdf")
|
||||
| - ^^^^^^^^ this call modifies `s` in-place
|
||||
@ -15,6 +43,7 @@ LL | s.push_str("asdf")
|
||||
| you probably want to use this value after calling the method...
|
||||
= note: ...instead of the `()` output of method `push_str`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
Some errors have detailed explanations: E0308, E0599.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
||||
|
@ -0,0 +1,11 @@
|
||||
#![feature(non_lifetime_binders)]
|
||||
//~^ WARN the feature `non_lifetime_binders` is incomplete
|
||||
|
||||
fn b()
|
||||
where
|
||||
for<const C: usize> [(); C]: Copy,
|
||||
//~^ ERROR cannot capture late-bound const parameter in a constant
|
||||
{
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,19 @@
|
||||
warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/capture-late-ct-in-anon.rs:1:12
|
||||
|
|
||||
LL | #![feature(non_lifetime_binders)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: cannot capture late-bound const parameter in a constant
|
||||
--> $DIR/capture-late-ct-in-anon.rs:6:30
|
||||
|
|
||||
LL | for<const C: usize> [(); C]: Copy,
|
||||
| -------------- ^
|
||||
| |
|
||||
| parameter defined here
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
Loading…
Reference in New Issue
Block a user