Auto merge of #116443 - workingjubilee:rollup-r9mh13f, r=workingjubilee
Rollup of 5 pull requests Successful merges: - #116223 (Fix misuses of a vs an) - #116296 (More accurately point to where default return type should go) - #116429 (Diagnostics: Be more careful when suggesting struct fields) - #116431 (Tweak wording of E0562) - #116432 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 2)) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
e293927016
132 changed files with 553 additions and 396 deletions
|
@ -446,7 +446,7 @@ impl Token {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the token can appear at the start of an pattern.
|
||||
/// Returns `true` if the token can appear at the start of a pattern.
|
||||
///
|
||||
/// Shamelessly borrowed from `can_begin_expr`, only used for diagnostics right now.
|
||||
pub fn can_begin_pattern(&self) -> bool {
|
||||
|
|
|
@ -99,7 +99,7 @@ ast_lowering_misplaced_double_dot =
|
|||
.note = only allowed in tuple, tuple struct, and slice patterns
|
||||
|
||||
ast_lowering_misplaced_impl_trait =
|
||||
`impl Trait` only allowed in function and inherent method return types, not in {$position}
|
||||
`impl Trait` only allowed in function and inherent method argument and return types, not in {$position}
|
||||
|
||||
ast_lowering_misplaced_relax_trait_bound =
|
||||
`?Trait` bounds are only permitted at the point where a type parameter is declared
|
||||
|
|
|
@ -162,7 +162,7 @@ pub enum StabilityLevel {
|
|||
is_soft: bool,
|
||||
/// If part of a feature is stabilized and a new feature is added for the remaining parts,
|
||||
/// then the `implied_by` attribute is used to indicate which now-stable feature previously
|
||||
/// contained a item.
|
||||
/// contained an item.
|
||||
///
|
||||
/// ```pseudo-Rust
|
||||
/// #[unstable(feature = "foo", issue = "...")]
|
||||
|
|
|
@ -1364,7 +1364,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
err.note(format!(
|
||||
"a for loop advances the iterator for you, the result is stored in `{loop_bind}`."
|
||||
));
|
||||
err.help("if you want to call `next` on a iterator within the loop, consider using `while let`.");
|
||||
err.help("if you want to call `next` on an iterator within the loop, consider using `while let`.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1359,9 +1359,9 @@ fn suggest_ampmut<'tcx>(
|
|||
None => (false, decl_span),
|
||||
};
|
||||
|
||||
// if the binding already exists and is a reference with a explicit
|
||||
// if the binding already exists and is a reference with an explicit
|
||||
// lifetime, then we can suggest adding ` mut`. this is special-cased from
|
||||
// the path without a explicit lifetime.
|
||||
// the path without an explicit lifetime.
|
||||
if let Ok(src) = tcx.sess.source_map().span_to_snippet(span)
|
||||
&& src.starts_with("&'")
|
||||
// note that `& 'a T` is invalid so this is correct.
|
||||
|
|
|
@ -1967,7 +1967,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
Reservation(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind }))
|
||||
| Write(WriteKind::MutableBorrow(BorrowKind::Mut { kind: mut_borrow_kind })) => {
|
||||
let is_local_mutation_allowed = match mut_borrow_kind {
|
||||
// `ClosureCapture` is used for mutable variable with a immutable binding.
|
||||
// `ClosureCapture` is used for mutable variable with an immutable binding.
|
||||
// This is only behaviour difference between `ClosureCapture` and mutable borrows.
|
||||
MutBorrowKind::ClosureCapture => LocalMutationIsAllowed::Yes,
|
||||
MutBorrowKind::Default | MutBorrowKind::TwoPhaseBorrow => {
|
||||
|
|
|
@ -164,7 +164,7 @@ struct UniversalRegionIndices<'tcx> {
|
|||
/// be able to map them to our internal `RegionVid`. This is
|
||||
/// basically equivalent to an `GenericArgs`, except that it also
|
||||
/// contains an entry for `ReStatic` -- it might be nice to just
|
||||
/// use a args, and then handle `ReStatic` another way.
|
||||
/// use an args, and then handle `ReStatic` another way.
|
||||
indices: FxHashMap<ty::Region<'tcx>, RegionVid>,
|
||||
|
||||
/// The vid assigned to `'static`. Used only for diagnostics.
|
||||
|
@ -290,7 +290,7 @@ impl<'tcx> UniversalRegions<'tcx> {
|
|||
(FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize)
|
||||
}
|
||||
|
||||
/// Returns `true` if `r` is classified as an local region.
|
||||
/// Returns `true` if `r` is classified as a local region.
|
||||
pub fn is_local_free_region(&self, r: RegionVid) -> bool {
|
||||
self.region_classification(r) == Some(RegionClassification::Local)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ fn clif_sig_from_fn_abi<'tcx>(
|
|||
let inputs = fn_abi.args.iter().flat_map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter());
|
||||
|
||||
let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx);
|
||||
// Sometimes the first param is an pointer to the place where the return value needs to be stored.
|
||||
// Sometimes the first param is a pointer to the place where the return value needs to be stored.
|
||||
let params: Vec<_> = return_ptr.into_iter().chain(inputs).collect();
|
||||
|
||||
Signature { params, returns, call_conv }
|
||||
|
|
|
@ -112,7 +112,7 @@ impl<'ll> CodegenCx<'ll, '_> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return a LLVM type that has at most the required alignment,
|
||||
/// Return an LLVM type that has at most the required alignment,
|
||||
/// and exactly the required size, as a best-effort padding array.
|
||||
pub(crate) fn type_padding_filler(&self, size: Size, align: Align) -> &'ll Type {
|
||||
let unit = Integer::approximate_align(self, align);
|
||||
|
|
|
@ -30,7 +30,7 @@ pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
|
|||
fn type_ptr_ext(&self, address_space: AddressSpace) -> Self::Type;
|
||||
fn element_type(&self, ty: Self::Type) -> Self::Type;
|
||||
|
||||
/// Returns the number of elements in `self` if it is a LLVM vector type.
|
||||
/// Returns the number of elements in `self` if it is an LLVM vector type.
|
||||
fn vector_length(&self, ty: Self::Type) -> usize;
|
||||
|
||||
fn float_width(&self, ty: Self::Type) -> usize;
|
||||
|
|
|
@ -1189,7 +1189,7 @@ fn report_trait_method_mismatch<'tcx>(
|
|||
let ap = Applicability::MachineApplicable;
|
||||
match sig.decl.output {
|
||||
hir::FnRetTy::DefaultReturn(sp) => {
|
||||
let sugg = format!("-> {} ", trait_sig.output());
|
||||
let sugg = format!(" -> {}", trait_sig.output());
|
||||
diag.span_suggestion_verbose(sp, msg, sugg, ap);
|
||||
}
|
||||
hir::FnRetTy::Return(hir_ty) => {
|
||||
|
|
|
@ -113,7 +113,11 @@ pub(super) fn check_fn<'a, 'tcx>(
|
|||
|
||||
fcx.typeck_results.borrow_mut().liberated_fn_sigs_mut().insert(fn_id, fn_sig);
|
||||
|
||||
fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType);
|
||||
let return_or_body_span = match decl.output {
|
||||
hir::FnRetTy::DefaultReturn(_) => body.value.span,
|
||||
hir::FnRetTy::Return(ty) => ty.span,
|
||||
};
|
||||
fcx.require_type_is_sized(declared_ret_ty, return_or_body_span, traits::SizedReturnType);
|
||||
fcx.check_return_expr(&body.value, false);
|
||||
|
||||
// We insert the deferred_generator_interiors entry after visiting the body.
|
||||
|
|
|
@ -110,7 +110,7 @@ pub struct AddressOfTemporaryTaken {
|
|||
pub enum AddReturnTypeSuggestion {
|
||||
#[suggestion(
|
||||
hir_typeck_add_return_type_add,
|
||||
code = "-> {found} ",
|
||||
code = " -> {found}",
|
||||
applicability = "machine-applicable"
|
||||
)]
|
||||
Add {
|
||||
|
@ -120,7 +120,7 @@ pub enum AddReturnTypeSuggestion {
|
|||
},
|
||||
#[suggestion(
|
||||
hir_typeck_add_return_type_missing_here,
|
||||
code = "-> _ ",
|
||||
code = " -> _",
|
||||
applicability = "has-placeholders"
|
||||
)]
|
||||
MissingHere {
|
||||
|
|
|
@ -41,7 +41,6 @@ use rustc_infer::infer::DefineOpaqueTypes;
|
|||
use rustc_infer::infer::InferOk;
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase};
|
||||
use rustc_middle::ty::error::{
|
||||
ExpectedFound,
|
||||
|
@ -1585,12 +1584,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.check_expr_struct_fields(
|
||||
adt_ty,
|
||||
expected,
|
||||
expr.hir_id,
|
||||
expr,
|
||||
qpath.span(),
|
||||
variant,
|
||||
fields,
|
||||
base_expr,
|
||||
expr.span,
|
||||
);
|
||||
|
||||
self.require_type_is_sized(adt_ty, expr.span, traits::StructInitializerSized);
|
||||
|
@ -1601,12 +1599,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
adt_ty: Ty<'tcx>,
|
||||
expected: Expectation<'tcx>,
|
||||
expr_id: hir::HirId,
|
||||
expr: &hir::Expr<'_>,
|
||||
span: Span,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
ast_fields: &'tcx [hir::ExprField<'tcx>],
|
||||
base_expr: &'tcx Option<&'tcx hir::Expr<'tcx>>,
|
||||
expr_span: Span,
|
||||
) {
|
||||
let tcx = self.tcx;
|
||||
|
||||
|
@ -1646,7 +1643,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// struct-like enums (yet...), but it's definitely not
|
||||
// a bug to have constructed one.
|
||||
if adt_kind != AdtKind::Enum {
|
||||
tcx.check_stability(v_field.did, Some(expr_id), field.span, None);
|
||||
tcx.check_stability(v_field.did, Some(expr.hir_id), field.span, None);
|
||||
}
|
||||
|
||||
self.field_ty(field.span, v_field, args)
|
||||
|
@ -1662,10 +1659,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.report_unknown_field(
|
||||
adt_ty,
|
||||
variant,
|
||||
expr,
|
||||
field,
|
||||
ast_fields,
|
||||
adt.variant_descr(),
|
||||
expr_span,
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -1731,7 +1728,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
.iter()
|
||||
.map(|f| {
|
||||
let fru_ty = self
|
||||
.normalize(expr_span, self.field_ty(base_expr.span, f, fresh_args));
|
||||
.normalize(expr.span, self.field_ty(base_expr.span, f, fresh_args));
|
||||
let ident = self.tcx.adjust_ident(f.ident(self.tcx), variant.def_id);
|
||||
if let Some(_) = remaining_fields.remove(&ident) {
|
||||
let target_ty = self.field_ty(base_expr.span, f, args);
|
||||
|
@ -1814,7 +1811,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
ty::Adt(adt, args) if adt.is_struct() => variant
|
||||
.fields
|
||||
.iter()
|
||||
.map(|f| self.normalize(expr_span, f.ty(self.tcx, args)))
|
||||
.map(|f| self.normalize(expr.span, f.ty(self.tcx, args)))
|
||||
.collect(),
|
||||
_ => {
|
||||
self.tcx
|
||||
|
@ -1824,13 +1821,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
};
|
||||
self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr_id, fru_tys);
|
||||
self.typeck_results.borrow_mut().fru_field_types_mut().insert(expr.hir_id, fru_tys);
|
||||
} else if adt_kind != AdtKind::Union && !remaining_fields.is_empty() {
|
||||
debug!(?remaining_fields);
|
||||
let private_fields: Vec<&ty::FieldDef> = variant
|
||||
.fields
|
||||
.iter()
|
||||
.filter(|field| !field.vis.is_accessible_from(tcx.parent_module(expr_id), tcx))
|
||||
.filter(|field| !field.vis.is_accessible_from(tcx.parent_module(expr.hir_id), tcx))
|
||||
.collect();
|
||||
|
||||
if !private_fields.is_empty() {
|
||||
|
@ -2049,16 +2046,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
&self,
|
||||
ty: Ty<'tcx>,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
expr: &hir::Expr<'_>,
|
||||
field: &hir::ExprField<'_>,
|
||||
skip_fields: &[hir::ExprField<'_>],
|
||||
kind_name: &str,
|
||||
expr_span: Span,
|
||||
) -> ErrorGuaranteed {
|
||||
if variant.is_recovered() {
|
||||
let guar = self
|
||||
.tcx
|
||||
.sess
|
||||
.delay_span_bug(expr_span, "parser recovered but no error was emitted");
|
||||
.delay_span_bug(expr.span, "parser recovered but no error was emitted");
|
||||
self.set_tainted_by_errors(guar);
|
||||
return guar;
|
||||
}
|
||||
|
@ -2102,7 +2099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
err.span_label(field.ident.span, "field does not exist");
|
||||
err.span_suggestion_verbose(
|
||||
expr_span,
|
||||
expr.span,
|
||||
format!(
|
||||
"`{adt}::{variant}` is a tuple {kind_name}, use the appropriate syntax",
|
||||
adt = ty,
|
||||
|
@ -2120,7 +2117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
err.span_label(variant_ident_span, format!("`{ty}` defined here"));
|
||||
err.span_label(field.ident.span, "field does not exist");
|
||||
err.span_suggestion_verbose(
|
||||
expr_span,
|
||||
expr.span,
|
||||
format!("`{ty}` is a tuple {kind_name}, use the appropriate syntax",),
|
||||
format!("{ty}(/* fields */)"),
|
||||
Applicability::HasPlaceholders,
|
||||
|
@ -2129,9 +2126,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
},
|
||||
_ => {
|
||||
// prevent all specified fields from being suggested
|
||||
let skip_fields: Vec<_> = skip_fields.iter().map(|x| x.ident.name).collect();
|
||||
let available_field_names = self.available_field_names(variant, expr, skip_fields);
|
||||
if let Some(field_name) =
|
||||
self.suggest_field_name(variant, field.ident.name, &skip_fields, expr_span)
|
||||
find_best_match_for_name(&available_field_names, field.ident.name, None)
|
||||
{
|
||||
err.span_suggestion(
|
||||
field.ident.span,
|
||||
|
@ -2153,10 +2150,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
format!("`{ty}` does not have this field"),
|
||||
);
|
||||
}
|
||||
let mut available_field_names =
|
||||
self.available_field_names(variant, expr_span);
|
||||
available_field_names
|
||||
.retain(|name| skip_fields.iter().all(|skip| name != skip));
|
||||
if available_field_names.is_empty() {
|
||||
err.note("all struct fields are already assigned");
|
||||
} else {
|
||||
|
@ -2174,63 +2167,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
err.emit()
|
||||
}
|
||||
|
||||
// Return a hint about the closest match in field names
|
||||
fn suggest_field_name(
|
||||
&self,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
field: Symbol,
|
||||
skip: &[Symbol],
|
||||
// The span where stability will be checked
|
||||
span: Span,
|
||||
) -> Option<Symbol> {
|
||||
let names = variant
|
||||
.fields
|
||||
.iter()
|
||||
.filter_map(|field| {
|
||||
// ignore already set fields and private fields from non-local crates
|
||||
// and unstable fields.
|
||||
if skip.iter().any(|&x| x == field.name)
|
||||
|| (!variant.def_id.is_local() && !field.vis.is_public())
|
||||
|| matches!(
|
||||
self.tcx.eval_stability(field.did, None, span, None),
|
||||
stability::EvalResult::Deny { .. }
|
||||
)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(field.name)
|
||||
}
|
||||
})
|
||||
.collect::<Vec<Symbol>>();
|
||||
|
||||
find_best_match_for_name(&names, field, None)
|
||||
}
|
||||
|
||||
fn available_field_names(
|
||||
&self,
|
||||
variant: &'tcx ty::VariantDef,
|
||||
access_span: Span,
|
||||
expr: &hir::Expr<'_>,
|
||||
skip_fields: &[hir::ExprField<'_>],
|
||||
) -> Vec<Symbol> {
|
||||
let body_owner_hir_id = self.tcx.hir().local_def_id_to_hir_id(self.body_id);
|
||||
variant
|
||||
.fields
|
||||
.iter()
|
||||
.filter(|field| {
|
||||
let def_scope = self
|
||||
.tcx
|
||||
.adjust_ident_and_get_scope(
|
||||
field.ident(self.tcx),
|
||||
variant.def_id,
|
||||
body_owner_hir_id,
|
||||
)
|
||||
.1;
|
||||
field.vis.is_accessible_from(def_scope, self.tcx)
|
||||
&& !matches!(
|
||||
self.tcx.eval_stability(field.did, None, access_span, None),
|
||||
stability::EvalResult::Deny { .. }
|
||||
)
|
||||
skip_fields.iter().all(|&skip| skip.ident.name != field.name)
|
||||
&& self.is_field_suggestable(field, expr.hir_id, expr.span)
|
||||
})
|
||||
.filter(|field| !self.tcx.is_doc_hidden(field.did))
|
||||
.map(|field| field.name)
|
||||
.collect()
|
||||
}
|
||||
|
@ -2460,7 +2409,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
self.suggest_first_deref_field(&mut err, expr, base, ident);
|
||||
}
|
||||
ty::Adt(def, _) if !def.is_enum() => {
|
||||
self.suggest_fields_on_recordish(&mut err, def, ident, expr.span);
|
||||
self.suggest_fields_on_recordish(&mut err, expr, def, ident);
|
||||
}
|
||||
ty::Param(param_ty) => {
|
||||
self.point_at_param_definition(&mut err, param_ty);
|
||||
|
@ -2622,12 +2571,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
fn suggest_fields_on_recordish(
|
||||
&self,
|
||||
err: &mut Diagnostic,
|
||||
expr: &hir::Expr<'_>,
|
||||
def: ty::AdtDef<'tcx>,
|
||||
field: Ident,
|
||||
access_span: Span,
|
||||
) {
|
||||
let available_field_names = self.available_field_names(def.non_enum_variant(), expr, &[]);
|
||||
if let Some(suggested_field_name) =
|
||||
self.suggest_field_name(def.non_enum_variant(), field.name, &[], access_span)
|
||||
find_best_match_for_name(&available_field_names, field.name, None)
|
||||
{
|
||||
err.span_suggestion(
|
||||
field.span,
|
||||
|
@ -2637,12 +2587,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
);
|
||||
} else {
|
||||
err.span_label(field.span, "unknown field");
|
||||
let struct_variant_def = def.non_enum_variant();
|
||||
let field_names = self.available_field_names(struct_variant_def, access_span);
|
||||
if !field_names.is_empty() {
|
||||
if !available_field_names.is_empty() {
|
||||
err.note(format!(
|
||||
"available fields are: {}",
|
||||
self.name_series_display(field_names),
|
||||
self.name_series_display(available_field_names),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -782,8 +782,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
hir::FnRetTy::Return(hir_ty) => {
|
||||
let span = hir_ty.span;
|
||||
|
||||
if let hir::TyKind::OpaqueDef(item_id, ..) = hir_ty.kind
|
||||
&& let hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::OpaqueTy(op_ty),
|
||||
|
@ -799,28 +797,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
debug!(?found);
|
||||
if found.is_suggestable(self.tcx, false) {
|
||||
if term.span.is_empty() {
|
||||
err.subdiagnostic(errors::AddReturnTypeSuggestion::Add { span, found: found.to_string() });
|
||||
err.subdiagnostic(errors::AddReturnTypeSuggestion::Add { span: term.span, found: found.to_string() });
|
||||
return true;
|
||||
} else {
|
||||
err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span, expected });
|
||||
err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span: term.span, expected });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only point to return type if the expected type is the return type, as if they
|
||||
// are not, the expectation must have been caused by something else.
|
||||
debug!("return type {:?}", hir_ty);
|
||||
let ty = self.astconv().ast_ty_to_ty(hir_ty);
|
||||
debug!("return type {:?}", ty);
|
||||
debug!("expected type {:?}", expected);
|
||||
let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into());
|
||||
let ty = Binder::bind_with_vars(ty, bound_vars);
|
||||
let ty = self.normalize(span, ty);
|
||||
let ty = self.tcx.erase_late_bound_regions(ty);
|
||||
if self.can_coerce(expected, ty) {
|
||||
err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span, expected });
|
||||
self.try_suggest_return_impl_trait(err, expected, ty, fn_id);
|
||||
return true;
|
||||
} else {
|
||||
// Only point to return type if the expected type is the return type, as if they
|
||||
// are not, the expectation must have been caused by something else.
|
||||
debug!("return type {:?}", hir_ty);
|
||||
let ty = self.astconv().ast_ty_to_ty(hir_ty);
|
||||
debug!("return type {:?}", ty);
|
||||
debug!("expected type {:?}", expected);
|
||||
let bound_vars = self.tcx.late_bound_vars(hir_ty.hir_id.owner.into());
|
||||
let ty = Binder::bind_with_vars(ty, bound_vars);
|
||||
let ty = self.normalize(hir_ty.span, ty);
|
||||
let ty = self.tcx.erase_late_bound_regions(ty);
|
||||
if self.can_coerce(expected, ty) {
|
||||
err.subdiagnostic(errors::ExpectedReturnTypeLabel::Other { span: hir_ty.span, expected });
|
||||
self.try_suggest_return_impl_trait(err, expected, ty, fn_id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
@ -1687,4 +1685,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn is_field_suggestable(
|
||||
&self,
|
||||
field: &ty::FieldDef,
|
||||
hir_id: HirId,
|
||||
span: Span,
|
||||
) -> bool {
|
||||
// The field must be visible in the containing module.
|
||||
field.vis.is_accessible_from(self.tcx.parent_module(hir_id), self.tcx)
|
||||
// The field must not be unstable.
|
||||
&& !matches!(
|
||||
self.tcx.eval_stability(field.did, None, rustc_span::DUMMY_SP, None),
|
||||
rustc_middle::middle::stability::EvalResult::Deny { .. }
|
||||
)
|
||||
// If the field is from an external crate it must not be `doc(hidden)`.
|
||||
&& (field.did.is_local() || !self.tcx.is_doc_hidden(field.did))
|
||||
// If the field is hygienic it must come from the same syntax context.
|
||||
&& self.tcx.def_ident_span(field.did).unwrap().normalize_to_macros_2_0().eq_ctxt(span)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ use rustc_hir::pat_util::EnumerateAndAdjustIterator;
|
|||
use rustc_hir::{HirId, Pat, PatKind};
|
||||
use rustc_infer::infer;
|
||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_middle::middle::stability::EvalResult;
|
||||
use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeVisitableExt};
|
||||
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
|
@ -1408,6 +1407,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
adt.variant_descr(),
|
||||
&inexistent_fields,
|
||||
&mut unmentioned_fields,
|
||||
pat,
|
||||
variant,
|
||||
args,
|
||||
))
|
||||
|
@ -1434,15 +1434,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let accessible_unmentioned_fields: Vec<_> = unmentioned_fields
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|(field, _)| {
|
||||
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id), tcx)
|
||||
&& !matches!(
|
||||
tcx.eval_stability(field.did, None, DUMMY_SP, None),
|
||||
EvalResult::Deny { .. }
|
||||
)
|
||||
// We only want to report the error if it is hidden and not local
|
||||
&& !(tcx.is_doc_hidden(field.did) && !field.did.is_local())
|
||||
})
|
||||
.filter(|(field, _)| self.is_field_suggestable(field, pat.hir_id, pat.span))
|
||||
.collect();
|
||||
|
||||
if !has_rest_pat {
|
||||
|
@ -1578,12 +1570,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
kind_name: &str,
|
||||
inexistent_fields: &[&hir::PatField<'tcx>],
|
||||
unmentioned_fields: &mut Vec<(&'tcx ty::FieldDef, Ident)>,
|
||||
pat: &'tcx Pat<'tcx>,
|
||||
variant: &ty::VariantDef,
|
||||
args: &'tcx ty::List<ty::GenericArg<'tcx>>,
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let tcx = self.tcx;
|
||||
let (field_names, t, plural) = if inexistent_fields.len() == 1 {
|
||||
(format!("a field named `{}`", inexistent_fields[0].ident), "this", "")
|
||||
let (field_names, t, plural) = if let [field] = inexistent_fields {
|
||||
(format!("a field named `{}`", field.ident), "this", "")
|
||||
} else {
|
||||
(
|
||||
format!(
|
||||
|
@ -1620,10 +1613,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
),
|
||||
);
|
||||
|
||||
if unmentioned_fields.len() == 1 {
|
||||
let input =
|
||||
unmentioned_fields.iter().map(|(_, field)| field.name).collect::<Vec<_>>();
|
||||
let suggested_name = find_best_match_for_name(&input, pat_field.ident.name, None);
|
||||
if let [(field_def, field)] = unmentioned_fields.as_slice()
|
||||
&& self.is_field_suggestable(field_def, pat.hir_id, pat.span)
|
||||
{
|
||||
let suggested_name =
|
||||
find_best_match_for_name(&[field.name], pat_field.ident.name, None);
|
||||
if let Some(suggested_name) = suggested_name {
|
||||
err.span_suggestion(
|
||||
pat_field.ident.span,
|
||||
|
@ -1646,22 +1640,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
PatKind::Lit(expr)
|
||||
if !self.can_coerce(
|
||||
self.typeck_results.borrow().expr_ty(expr),
|
||||
self.field_ty(
|
||||
unmentioned_fields[0].1.span,
|
||||
unmentioned_fields[0].0,
|
||||
args,
|
||||
),
|
||||
self.field_ty(field.span, field_def, args),
|
||||
) => {}
|
||||
_ => {
|
||||
let unmentioned_field = unmentioned_fields[0].1.name;
|
||||
err.span_suggestion_short(
|
||||
pat_field.ident.span,
|
||||
format!(
|
||||
"`{}` has a field named `{}`",
|
||||
tcx.def_path_str(variant.def_id),
|
||||
unmentioned_field
|
||||
field.name,
|
||||
),
|
||||
unmentioned_field.to_string(),
|
||||
field.name,
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
|
@ -1871,8 +1860,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
fields: &'tcx [hir::PatField<'tcx>],
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let inaccessible = if have_inaccessible_fields { " and inaccessible fields" } else { "" };
|
||||
let field_names = if unmentioned_fields.len() == 1 {
|
||||
format!("field `{}`{}", unmentioned_fields[0].1, inaccessible)
|
||||
let field_names = if let [(_, field)] = unmentioned_fields {
|
||||
format!("field `{field}`{inaccessible}")
|
||||
} else {
|
||||
let fields = unmentioned_fields
|
||||
.iter()
|
||||
|
|
|
@ -194,13 +194,13 @@ impl<'a> SourceKindMultiSuggestion<'a> {
|
|||
data: &'a FnRetTy<'a>,
|
||||
should_wrap_expr: Option<Span>,
|
||||
) -> Self {
|
||||
let (arrow, post) = match data {
|
||||
FnRetTy::DefaultReturn(_) => ("-> ", " "),
|
||||
_ => ("", ""),
|
||||
let arrow = match data {
|
||||
FnRetTy::DefaultReturn(_) => " -> ",
|
||||
_ => "",
|
||||
};
|
||||
let (start_span, start_span_code, end_span) = match should_wrap_expr {
|
||||
Some(end_span) => (data.span(), format!("{arrow}{ty_info}{post}{{ "), Some(end_span)),
|
||||
None => (data.span(), format!("{arrow}{ty_info}{post}"), None),
|
||||
Some(end_span) => (data.span(), format!("{arrow}{ty_info} {{"), Some(end_span)),
|
||||
None => (data.span(), format!("{arrow}{ty_info}"), None),
|
||||
};
|
||||
Self::ClosureReturn { start_span, start_span_code, end_span }
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
//! the most suitable spot to implement it, and then just let the
|
||||
//! other fns cycle around. The handoff works like this:
|
||||
//!
|
||||
//! - `into(place)` -> fallback is to create a rvalue with `as_rvalue` and assign it to `place`
|
||||
//! - `into(place)` -> fallback is to create an rvalue with `as_rvalue` and assign it to `place`
|
||||
//! - `as_rvalue` -> fallback is to create an Operand with `as_operand` and use `Rvalue::use`
|
||||
//! - `as_operand` -> either invokes `as_constant` or `as_temp`
|
||||
//! - `as_constant` -> (no fallback)
|
||||
|
|
|
@ -247,7 +247,7 @@ impl<'a> Parser<'a> {
|
|||
)?;
|
||||
FnRetTy::Ty(ty)
|
||||
} else {
|
||||
FnRetTy::Default(self.token.span.shrink_to_lo())
|
||||
FnRetTy::Default(self.prev_token.span.shrink_to_hi())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
|
|||
arg.make_indirect();
|
||||
} else {
|
||||
// We want to pass small aggregates as immediates, but using
|
||||
// a LLVM aggregate type for this leads to bad optimizations,
|
||||
// an LLVM aggregate type for this leads to bad optimizations,
|
||||
// so we pick an appropriately sized integer type instead.
|
||||
arg.cast_to(Reg { kind: RegKind::Integer, size });
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use core::iter::Peekable;
|
||||
|
||||
/// A iterator for deduping the key of a sorted iterator.
|
||||
/// An iterator for deduping the key of a sorted iterator.
|
||||
/// When encountering the duplicated key, only the last key-value pair is yielded.
|
||||
///
|
||||
/// Used by [`BTreeMap::bulk_build_from_sorted_iter`][1].
|
||||
|
|
|
@ -67,7 +67,7 @@ The following procedure outlines the build process for the MIPS64 R6 target with
|
|||
|
||||
### Prerequisite: Disable debuginfo
|
||||
|
||||
A LLVM bug makes rustc crash if debug or debug info generation is enabled. You need to edit `config.toml` to disable this:
|
||||
An LLVM bug makes rustc crash if debug or debug info generation is enabled. You need to edit `config.toml` to disable this:
|
||||
|
||||
```toml
|
||||
[rust]
|
||||
|
|
|
@ -102,14 +102,10 @@ pub(super) fn check(
|
|||
]),
|
||||
("None", "unwrap_or_else", _) => match args[0].kind {
|
||||
hir::ExprKind::Closure(hir::Closure {
|
||||
fn_decl:
|
||||
hir::FnDecl {
|
||||
output: hir::FnRetTy::DefaultReturn(span) | hir::FnRetTy::Return(hir::Ty { span, .. }),
|
||||
..
|
||||
},
|
||||
body,
|
||||
..
|
||||
}) => Some(vec![
|
||||
(expr.span.with_hi(span.hi()), String::new()),
|
||||
(expr.span.with_hi(cx.tcx.hir().body(*body).value.span.lo()), String::new()),
|
||||
(expr.span.with_lo(args[0].span.hi()), String::new()),
|
||||
]),
|
||||
_ => None,
|
||||
|
|
|
@ -2,7 +2,7 @@ error: this function has too many arguments (11/10)
|
|||
--> $DIR/too_many_arguments.rs:4:1
|
||||
|
|
||||
LL | fn too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8, p11: u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::too-many-arguments` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`
|
||||
|
|
|
@ -2,7 +2,7 @@ error: this function has too many arguments (8/7)
|
|||
--> $DIR/functions.rs:8:1
|
||||
|
|
||||
LL | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::too-many-arguments` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]`
|
||||
|
@ -17,7 +17,7 @@ LL | | two: u32,
|
|||
... |
|
||||
LL | | eight: ()
|
||||
LL | | ) {
|
||||
| |__^
|
||||
| |_^
|
||||
|
||||
error: this function has too many arguments (8/7)
|
||||
--> $DIR/functions.rs:48:5
|
||||
|
@ -29,7 +29,7 @@ error: this function has too many arguments (8/7)
|
|||
--> $DIR/functions.rs:58:5
|
||||
|
|
||||
LL | fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this public function might dereference a raw pointer but is not marked `unsafe`
|
||||
--> $DIR/functions.rs:68:34
|
||||
|
|
|
@ -4,7 +4,7 @@ error: this unit-returning function has a `#[must_use]` attribute
|
|||
LL | #[must_use]
|
||||
| ----------- help: remove the attribute
|
||||
LL | pub fn must_use_default() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::must-use-unit` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::must_use_unit)]`
|
||||
|
@ -23,7 +23,7 @@ error: this unit-returning function has a `#[must_use]` attribute
|
|||
LL | #[must_use = "With note"]
|
||||
| ------------------------- help: remove the attribute
|
||||
LL | pub fn must_use_with_note() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ fn unwrap_option_none() {
|
|||
let _val: u16 = 234;
|
||||
let _val: u16 = 234;
|
||||
let _val: u16 = { 234 };
|
||||
let _val: u16 = { 234 };
|
||||
let _val: u16 = { 234 };
|
||||
|
||||
panic!();
|
||||
panic!("this always happens");
|
||||
|
@ -31,7 +31,7 @@ fn unwrap_option_none() {
|
|||
234;
|
||||
234;
|
||||
{ 234 };
|
||||
{ 234 };
|
||||
{ 234 };
|
||||
}
|
||||
|
||||
fn unwrap_result_ok() {
|
||||
|
|
|
@ -116,7 +116,7 @@ LL | let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 });
|
|||
help: remove the `None` and `unwrap_or_else()`
|
||||
|
|
||||
LL - let _val: u16 = None.unwrap_or_else(|| -> u16 { 234 });
|
||||
LL + let _val: u16 = { 234 };
|
||||
LL + let _val: u16 = { 234 };
|
||||
|
|
||||
|
||||
error: used `unwrap()` on `None` value
|
||||
|
@ -187,7 +187,7 @@ LL | None::<u16>.unwrap_or_else(|| -> u16 { 234 });
|
|||
help: remove the `None` and `unwrap_or_else()`
|
||||
|
|
||||
LL - None::<u16>.unwrap_or_else(|| -> u16 { 234 });
|
||||
LL + { 234 };
|
||||
LL + { 234 };
|
||||
|
|
||||
|
||||
error: used `unwrap()` on `Ok` value
|
||||
|
|
|
@ -2599,7 +2599,8 @@ fn rewrite_fn_base(
|
|||
if where_clause_str.is_empty() {
|
||||
if let ast::FnRetTy::Default(ret_span) = fd.output {
|
||||
match recover_missing_comment_in_span(
|
||||
mk_sp(params_span.hi(), ret_span.hi()),
|
||||
// from after the closing paren to right before block or semicolon
|
||||
mk_sp(ret_span.lo(), span.hi()),
|
||||
shape,
|
||||
context,
|
||||
last_line_width(&result),
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
// https://github.com/rust-lang/rust/issues/25001
|
||||
#![crate_name="issue_25001"]
|
||||
|
||||
// @has issue_25001/struct.Foo.html
|
||||
pub struct Foo<T>(T);
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
// https://github.com/rust-lang/rust/issues/28478
|
||||
#![crate_name="issue_28478"]
|
||||
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
// @has issue_28478/trait.Bar.html
|
|
@ -1,3 +1,6 @@
|
|||
// https://github.com/rust-lang/rust/issues/21474
|
||||
#![crate_name="issue_21474"]
|
||||
|
||||
pub use inner::*;
|
||||
|
||||
mod inner {
|
|
@ -1,6 +1,9 @@
|
|||
// aux-build:issue-22025.rs
|
||||
// ignore-cross-compile
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/22025
|
||||
#![crate_name="issue_22025"]
|
||||
|
||||
extern crate issue_22025;
|
||||
|
||||
pub use issue_22025::foo::{Foo, Bar};
|
10
tests/rustdoc/doctest-hide-empty-line-23106.rs
Normal file
10
tests/rustdoc/doctest-hide-empty-line-23106.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
// compile-flags:--test
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/23106
|
||||
#![crate_name="issue_23106"]
|
||||
|
||||
/// ```
|
||||
/// #
|
||||
/// ```
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
// compile-flags:--test
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/23744
|
||||
#![crate_name="issue_23744"]
|
||||
|
||||
/// Example of rustdoc incorrectly parsing <code>```rust,should_panic</code>.
|
||||
///
|
||||
/// ```should_panic
|
|
@ -1,5 +1,8 @@
|
|||
// compile-flags:--test
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/25944
|
||||
#![crate_name="issue_25944"]
|
||||
|
||||
/// ```
|
||||
/// let a = r#"
|
||||
/// foo
|
|
@ -1,3 +1,6 @@
|
|||
// https://github.com/rust-lang/rust/issues/22038
|
||||
#![crate_name="issue_22038"]
|
||||
|
||||
extern "C" {
|
||||
// @has issue_22038/fn.foo1.html \
|
||||
// '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()'
|
|
@ -2,5 +2,8 @@
|
|||
// aux-build:issue-28927-1.rs
|
||||
// ignore-cross-compile
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/28927
|
||||
#![crate_name="issue_28927"]
|
||||
|
||||
pub extern crate issue_28927_1 as inner1;
|
||||
pub use inner1 as foo;
|
|
@ -1,6 +1,9 @@
|
|||
// aux-build:issue-21092.rs
|
||||
// ignore-cross-compile
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/21092
|
||||
#![crate_name="issue_21092"]
|
||||
|
||||
extern crate issue_21092;
|
||||
|
||||
// @has issue_21092/struct.Bar.html
|
|
@ -1,6 +1,9 @@
|
|||
// aux-build:issue-27362-aux.rs
|
||||
// ignore-cross-compile
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/27362
|
||||
#![crate_name="issue_27362"]
|
||||
|
||||
extern crate issue_27362_aux;
|
||||
|
||||
pub use issue_27362_aux::*;
|
|
@ -2,6 +2,9 @@
|
|||
// aux-build:issue-23207-2.rs
|
||||
// ignore-cross-compile
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/23207
|
||||
#![crate_name="issue_23207"]
|
||||
|
||||
extern crate issue_23207_2;
|
||||
|
||||
// @has issue_23207/fmt/index.html
|
|
@ -1,6 +1,9 @@
|
|||
// aux-build:issue-21801.rs
|
||||
// ignore-cross-compile
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/21801
|
||||
#![crate_name="issue_21801"]
|
||||
|
||||
extern crate issue_21801;
|
||||
|
||||
// @has issue_21801/struct.Foo.html
|
|
@ -1,7 +0,0 @@
|
|||
// compile-flags:--test
|
||||
|
||||
/// ```
|
||||
/// #
|
||||
/// ```
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,3 +1,6 @@
|
|||
// https://github.com/rust-lang/rust/issues/23812
|
||||
#![crate_name="issue_23812"]
|
||||
|
||||
macro_rules! doc {
|
||||
(#[$outer:meta] mod $i:ident { #![$inner:meta] }) =>
|
||||
(
|
|
@ -1,3 +1,6 @@
|
|||
// https://github.com/rust-lang/rust/issues/27862
|
||||
#![crate_name="issue_27862"]
|
||||
|
||||
/// Tests | Table
|
||||
/// ------|-------------
|
||||
/// t = b | id = \|x\| x
|
|
@ -2,6 +2,9 @@
|
|||
#![feature(rustdoc_internals)]
|
||||
#![no_std]
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/23511
|
||||
#![crate_name="issue_23511"]
|
||||
|
||||
pub mod str {
|
||||
#![rustc_doc_primitive = "str"]
|
||||
|
|
@ -2,10 +2,13 @@
|
|||
// ignore-cross-compile
|
||||
// build-aux-docs
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/26606
|
||||
#![crate_name="issue_26606"]
|
||||
|
||||
// @has issue_26606_macro/macro.make_item.html
|
||||
#[macro_use]
|
||||
extern crate issue_26606_macro;
|
||||
|
||||
// @has issue_26606/constant.FOO.html
|
||||
// @has - '//a[@href="../src/issue_26606/issue-26606.rs.html#11"]' 'source'
|
||||
// @has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#14"]' 'source'
|
||||
make_item!(FOO);
|
|
@ -1,6 +1,9 @@
|
|||
// ignore-windows
|
||||
// compile-flags: --no-defaults
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/26995
|
||||
#![crate_name="issue_26995"]
|
||||
|
||||
// @has src/issue_26995/dev/null.html
|
||||
// @has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html'
|
||||
#[path="/dev/null"]
|
|
@ -1,3 +1,6 @@
|
|||
// https://github.com/rust-lang/rust/issues/27759
|
||||
#![crate_name="issue_27759"]
|
||||
|
||||
#![feature(staged_api)]
|
||||
#![doc(issue_tracker_base_url = "http://issue_url/")]
|
||||
|
|
@ -2,6 +2,9 @@
|
|||
// aux-build:empty.rs
|
||||
// ignore-cross-compile
|
||||
|
||||
// https://github.com/rust-lang/rust/issues/27104
|
||||
#![crate_name="issue_27104"]
|
||||
|
||||
// @has issue_27104/index.html
|
||||
// @!hasraw - 'extern crate std'
|
||||
// @!hasraw - 'use std::prelude::'
|
|
@ -33,7 +33,7 @@ LL | fn main<A: TraitWAssocConst<A=32>>() {
|
|||
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
|
||||
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in impl headers
|
||||
--> $DIR/issue-105330.rs:6:27
|
||||
|
|
||||
LL | impl TraitWAssocConst for impl Demo {
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-71443-1.rs:6:5
|
||||
|
|
||||
LL | fn hello<F: for<'a> Iterator<Item: 'a>>() {
|
||||
| - help: try adding a return type: `-> Incorrect`
|
||||
| - help: try adding a return type: `-> Incorrect`
|
||||
LL | Incorrect
|
||||
| ^^^^^^^^^ expected `()`, found `Incorrect`
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ trait MyTrait {
|
|||
|
||||
impl MyTrait for i32 {
|
||||
fn foo(&self) -> impl Future<Output = i32> {
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types
|
||||
async { *self }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `impl` method return types
|
||||
--> $DIR/fn-not-async-err2.rs:13:22
|
||||
|
|
||||
LL | fn foo(&self) -> impl Future<Output = i32> {
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/block-must-not-have-result-res.rs:5:9
|
||||
|
|
||||
LL | fn drop(&mut self) {
|
||||
| - expected `()` because of default return type
|
||||
| - expected `()` because of default return type
|
||||
LL | true
|
||||
| ^^^^ expected `()`, found `bool`
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-20862.rs:2:5
|
||||
|
|
||||
LL | fn foo(x: i32) {
|
||||
| - help: a return type might be missing here: `-> _`
|
||||
| - help: a return type might be missing here: `-> _`
|
||||
LL | |y| x + y
|
||||
| ^^^^^^^^^ expected `()`, found closure
|
||||
|
|
||||
|
|
|
@ -17,7 +17,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-22645.rs:15:3
|
||||
|
|
||||
LL | fn main() {
|
||||
| - expected `()` because of default return type
|
||||
| - expected `()` because of default return type
|
||||
LL | let b = Bob + 3.5;
|
||||
LL | b + 3
|
||||
| ^^^^^ expected `()`, found `Bob`
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/issue-5500.rs:2:5
|
||||
|
|
||||
LL | fn main() {
|
||||
| - expected `()` because of default return type
|
||||
| - expected `()` because of default return type
|
||||
LL | &panic!()
|
||||
| ^^^^^^^^^ expected `()`, found `&_`
|
||||
|
|
||||
|
|
|
@ -2,7 +2,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/add_semicolon_non_block_closure.rs:8:12
|
||||
|
|
||||
LL | fn main() {
|
||||
| - expected `()` because of default return type
|
||||
| - expected `()` because of default return type
|
||||
LL | foo(|| bar())
|
||||
| ^^^^^ expected `()`, found `i32`
|
||||
|
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
error: implicit types in closure signatures are forbidden when `for<...>` is present
|
||||
--> $DIR/implicit-return.rs:4:34
|
||||
--> $DIR/implicit-return.rs:4:33
|
||||
|
|
||||
LL | let _f = for<'a> |_: &'a ()| {};
|
||||
| ------- ^
|
||||
| ------- ^
|
||||
| |
|
||||
| `for<...>` is here
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ LL | let _ = for<'a> |x: &'a ()| -> &() { x };
|
|||
| ^ explicit lifetime name needed here
|
||||
|
||||
error: implicit types in closure signatures are forbidden when `for<...>` is present
|
||||
--> $DIR/implicit-stuff.rs:5:22
|
||||
--> $DIR/implicit-stuff.rs:5:21
|
||||
|
|
||||
LL | let _ = for<> || {};
|
||||
| ----- ^
|
||||
| ----- ^
|
||||
| |
|
||||
| `for<...>` is here
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// Regression test for issue #79865.
|
||||
// The assertion will fail when compiled with Rust 1.56..=1.59
|
||||
// due to a LLVM miscompilation.
|
||||
// due to an LLVM miscompilation.
|
||||
|
||||
use std::arch::x86_64::*;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ error[E0308]: mismatched types
|
|||
--> $DIR/tab.rs:8:2
|
||||
|
|
||||
LL | fn foo() {
|
||||
| - help: try adding a return type: `-> &'static str`
|
||||
| - help: try adding a return type: `-> &'static str`
|
||||
LL | "bar boo"
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `&str`
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ LL | fn foo(self);
|
|||
found signature `fn(Box<MyFuture>)`
|
||||
|
||||
error[E0053]: method `bar` has an incompatible type for trait
|
||||
--> $DIR/bad-self-type.rs:24:18
|
||||
--> $DIR/bad-self-type.rs:24:17
|
||||
|
|
||||
LL | fn bar(self) {}
|
||||
| ^ expected `Option<()>`, found `()`
|
||||
| ^ expected `Option<()>`, found `()`
|
||||
|
|
||||
note: type in trait
|
||||
--> $DIR/bad-self-type.rs:18:21
|
||||
|
|
|
@ -12,7 +12,7 @@ enum Foo {
|
|||
}
|
||||
|
||||
// NOTE(eddyb) Don't make this a const, needs to be a static
|
||||
// so it is always instantiated as a LLVM constant value.
|
||||
// so it is always instantiated as an LLVM constant value.
|
||||
static FOO: Foo = Foo::C;
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Verify that we do not trigger a LLVM assertion by creating zero-sized DWARF fragments.
|
||||
// Verify that we do not trigger an LLVM assertion by creating zero-sized DWARF fragments.
|
||||
//
|
||||
// build-pass
|
||||
// compile-flags: -g -Zmir-opt-level=0 -Zmir-enable-passes=+ScalarReplacementOfAggregates
|
||||
|
|
6
tests/ui/did_you_mean/auxiliary/doc-hidden-fields.rs
Normal file
6
tests/ui/did_you_mean/auxiliary/doc-hidden-fields.rs
Normal file
|
@ -0,0 +1,6 @@
|
|||
#[derive(Default)]
|
||||
pub struct B {
|
||||
#[doc(hidden)]
|
||||
pub hello: i32,
|
||||
pub bye: i32,
|
||||
}
|
38
tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.rs
Normal file
38
tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Regression test for issue #93210.
|
||||
|
||||
// aux-crate:doc_hidden_fields=doc-hidden-fields.rs
|
||||
// edition: 2021
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct A {
|
||||
#[doc(hidden)]
|
||||
pub hello: i32,
|
||||
pub bye: i32,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct C {
|
||||
pub hello: i32,
|
||||
pub bye: i32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// We want to list the field `hello` despite being marked
|
||||
// `doc(hidden)` because it's defined in this crate.
|
||||
A::default().hey;
|
||||
//~^ ERROR no field `hey` on type `A`
|
||||
//~| NOTE unknown field
|
||||
//~| NOTE available fields are: `hello`, `bye`
|
||||
|
||||
// Here we want to hide the field `hello` since it's marked
|
||||
// `doc(hidden)` and comes from an external crate.
|
||||
doc_hidden_fields::B::default().hey;
|
||||
//~^ ERROR no field `hey` on type `B`
|
||||
//~| NOTE unknown field
|
||||
//~| NOTE available fields are: `bye`
|
||||
|
||||
C::default().hey;
|
||||
//~^ ERROR no field `hey` on type `C`
|
||||
//~| NOTE unknown field
|
||||
//~| NOTE available fields are: `hello`, `bye`
|
||||
}
|
27
tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.stderr
Normal file
27
tests/ui/did_you_mean/dont-suggest-doc-hidden-fields.stderr
Normal file
|
@ -0,0 +1,27 @@
|
|||
error[E0609]: no field `hey` on type `A`
|
||||
--> $DIR/dont-suggest-doc-hidden-fields.rs:22:18
|
||||
|
|
||||
LL | A::default().hey;
|
||||
| ^^^ unknown field
|
||||
|
|
||||
= note: available fields are: `hello`, `bye`
|
||||
|
||||
error[E0609]: no field `hey` on type `B`
|
||||
--> $DIR/dont-suggest-doc-hidden-fields.rs:29:37
|
||||
|
|
||||
LL | doc_hidden_fields::B::default().hey;
|
||||
| ^^^ unknown field
|
||||
|
|
||||
= note: available fields are: `bye`
|
||||
|
||||
error[E0609]: no field `hey` on type `C`
|
||||
--> $DIR/dont-suggest-doc-hidden-fields.rs:34:18
|
||||
|
|
||||
LL | C::default().hey;
|
||||
| ^^^ unknown field
|
||||
|
|
||||
= note: available fields are: `hello`, `bye`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0609`.
|
47
tests/ui/did_you_mean/dont-suggest-hygienic-fields.rs
Normal file
47
tests/ui/did_you_mean/dont-suggest-hygienic-fields.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Regression test for issue #116334.
|
||||
// Don't include hygienic fields from different syntax contexts in
|
||||
// the list of available or similarly named fields.
|
||||
|
||||
#![feature(decl_macro)]
|
||||
|
||||
macro compound($Ty:ident) {
|
||||
#[derive(Default)]
|
||||
struct $Ty {
|
||||
field: u32, // field `field` is hygienic
|
||||
}
|
||||
}
|
||||
|
||||
macro component($Ty:ident) {
|
||||
struct $Ty(u64); // field `0` is hygienic (but still accessible via the constructor)
|
||||
}
|
||||
|
||||
compound! { Compound }
|
||||
component! { Component }
|
||||
|
||||
fn main() {
|
||||
let ty = Compound::default();
|
||||
|
||||
let _ = ty.field; //~ ERROR no field `field` on type `Compound`
|
||||
let _ = ty.fieeld; //~ ERROR no field `fieeld` on type `Compound`
|
||||
|
||||
let Compound { field } = ty;
|
||||
//~^ ERROR struct `Compound` does not have a field named `field`
|
||||
//~| ERROR pattern requires `..` due to inaccessible fields
|
||||
//~| HELP ignore the inaccessible and unused fields
|
||||
|
||||
let ty = Component(90);
|
||||
|
||||
let _ = ty.0; //~ ERROR no field `0` on type `Component`
|
||||
}
|
||||
|
||||
environment!();
|
||||
|
||||
macro environment() {
|
||||
struct Crate { field: () }
|
||||
|
||||
// Here, we do want to suggest `field` even though it's hygienic
|
||||
// precisely because they come from the same syntax context.
|
||||
const CRATE: Crate = Crate { fiel: () };
|
||||
//~^ ERROR struct `Crate` has no field named `fiel`
|
||||
//~| HELP a field with a similar name exists
|
||||
}
|
50
tests/ui/did_you_mean/dont-suggest-hygienic-fields.stderr
Normal file
50
tests/ui/did_you_mean/dont-suggest-hygienic-fields.stderr
Normal file
|
@ -0,0 +1,50 @@
|
|||
error[E0560]: struct `Crate` has no field named `fiel`
|
||||
--> $DIR/dont-suggest-hygienic-fields.rs:44:34
|
||||
|
|
||||
LL | environment!();
|
||||
| -------------- in this macro invocation
|
||||
...
|
||||
LL | const CRATE: Crate = Crate { fiel: () };
|
||||
| ^^^^ help: a field with a similar name exists: `field`
|
||||
|
|
||||
= note: this error originates in the macro `environment` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0609]: no field `field` on type `Compound`
|
||||
--> $DIR/dont-suggest-hygienic-fields.rs:24:16
|
||||
|
|
||||
LL | let _ = ty.field;
|
||||
| ^^^^^ unknown field
|
||||
|
||||
error[E0609]: no field `fieeld` on type `Compound`
|
||||
--> $DIR/dont-suggest-hygienic-fields.rs:25:16
|
||||
|
|
||||
LL | let _ = ty.fieeld;
|
||||
| ^^^^^^ unknown field
|
||||
|
||||
error[E0026]: struct `Compound` does not have a field named `field`
|
||||
--> $DIR/dont-suggest-hygienic-fields.rs:27:20
|
||||
|
|
||||
LL | let Compound { field } = ty;
|
||||
| ^^^^^ struct `Compound` does not have this field
|
||||
|
||||
error: pattern requires `..` due to inaccessible fields
|
||||
--> $DIR/dont-suggest-hygienic-fields.rs:27:9
|
||||
|
|
||||
LL | let Compound { field } = ty;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: ignore the inaccessible and unused fields
|
||||
|
|
||||
LL | let Compound { field, .. } = ty;
|
||||
| ++++
|
||||
|
||||
error[E0609]: no field `0` on type `Component`
|
||||
--> $DIR/dont-suggest-hygienic-fields.rs:34:16
|
||||
|
|
||||
LL | let _ = ty.0;
|
||||
| ^ unknown field
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0026, E0560, E0609.
|
||||
For more information about an error, try `rustc --explain E0026`.
|
|
@ -1,24 +0,0 @@
|
|||
#[derive(Default)]
|
||||
pub struct A {
|
||||
#[doc(hidden)]
|
||||
pub hello: i32,
|
||||
pub bye: i32,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct B {
|
||||
pub hello: i32,
|
||||
pub bye: i32,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
A::default().hey;
|
||||
//~^ ERROR no field `hey` on type `A`
|
||||
//~| NOTE unknown field
|
||||
//~| NOTE available fields are: `bye`
|
||||
|
||||
B::default().hey;
|
||||
//~^ ERROR no field `hey` on type `B`
|
||||
//~| NOTE unknown field
|
||||
//~| NOTE available fields are: `hello`, `bye`
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
error[E0609]: no field `hey` on type `A`
|
||||
--> $DIR/issue-93210-ignore-doc-hidden.rs:15:18
|
||||
|
|
||||
LL | A::default().hey;
|
||||
| ^^^ unknown field
|
||||
|
|
||||
= note: available fields are: `bye`
|
||||
|
||||
error[E0609]: no field `hey` on type `B`
|
||||
--> $DIR/issue-93210-ignore-doc-hidden.rs:20:18
|
||||
|
|
||||
LL | B::default().hey;
|
||||
| ^^^ unknown field
|
||||
|
|
||||
= note: available fields are: `hello`, `bye`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0609`.
|
|
@ -54,20 +54,20 @@ fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) }
|
|||
|
||||
const _cdef: impl Tr1<As1: Copy> = S1;
|
||||
//~^ ERROR associated type bounds are unstable
|
||||
//~| ERROR `impl Trait` only allowed in function and inherent method return types
|
||||
//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types
|
||||
// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
|
||||
// const _cdef_dyn: &dyn Tr1<As1: Copy> = &S1;
|
||||
|
||||
static _sdef: impl Tr1<As1: Copy> = S1;
|
||||
//~^ ERROR associated type bounds are unstable
|
||||
//~| ERROR `impl Trait` only allowed in function and inherent method return types
|
||||
//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types
|
||||
// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
|
||||
// static _sdef_dyn: &dyn Tr1<As1: Copy> = &S1;
|
||||
|
||||
fn main() {
|
||||
let _: impl Tr1<As1: Copy> = S1;
|
||||
//~^ ERROR associated type bounds are unstable
|
||||
//~| ERROR `impl Trait` only allowed in function and inherent method return types
|
||||
//~| ERROR `impl Trait` only allowed in function and inherent method argument and return types
|
||||
// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed.
|
||||
// let _: &dyn Tr1<As1: Copy> = &S1;
|
||||
}
|
||||
|
|
|
@ -115,19 +115,19 @@ LL | let _: impl Tr1<As1: Copy> = S1;
|
|||
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
|
||||
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:55:14
|
||||
|
|
||||
LL | const _cdef: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:61:15
|
||||
|
|
||||
LL | static _sdef: impl Tr1<As1: Copy> = S1;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/feature-gate-associated_type_bounds.rs:68:12
|
||||
|
|
||||
LL | let _: impl Tr1<As1: Copy> = S1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn f() -> impl Fn() -> impl Sized { || () }
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return
|
||||
fn g() -> &'static dyn Fn() -> impl Sized { &|| () }
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types
|
||||
--> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24
|
||||
|
|
||||
LL | fn f() -> impl Fn() -> impl Sized { || () }
|
||||
|
@ -7,7 +7,7 @@ LL | fn f() -> impl Fn() -> impl Sized { || () }
|
|||
= note: see issue #99697 <https://github.com/rust-lang/rust/issues/99697> for more information
|
||||
= help: add `#![feature(impl_trait_in_fn_trait_return)]` to the crate attributes to enable
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in `Fn` trait return types
|
||||
--> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32
|
||||
|
|
||||
LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () }
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
#![feature(async_fn_in_trait)]
|
||||
|
||||
trait Foo {
|
||||
fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return
|
||||
fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return
|
||||
fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return
|
||||
fn baz() -> Box<impl std::fmt::Display>; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return
|
||||
}
|
||||
|
||||
// Both return_position_impl_trait_in_trait and async_fn_in_trait are required for this (see also
|
||||
// feature-gate-async_fn_in_trait.rs)
|
||||
trait AsyncFoo {
|
||||
async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method return types, not in trait method return
|
||||
async fn bar() -> impl Sized; //~ ERROR `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types
|
||||
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:8:17
|
||||
|
|
||||
LL | fn bar() -> impl Sized;
|
||||
|
@ -7,7 +7,7 @@ LL | fn bar() -> impl Sized;
|
|||
= 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[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types
|
||||
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:9:21
|
||||
|
|
||||
LL | fn baz() -> Box<impl std::fmt::Display>;
|
||||
|
@ -16,7 +16,7 @@ LL | fn baz() -> Box<impl std::fmt::Display>;
|
|||
= 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[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in trait method return types
|
||||
--> $DIR/feature-gate-return_position_impl_trait_in_trait.rs:15:23
|
||||
|
|
||||
LL | async fn bar() -> impl Sized;
|
||||
|
|
|
@ -30,8 +30,8 @@ LL | fn bar() {}
|
|||
= note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate
|
||||
help: replace the return type so that it matches the trait
|
||||
|
|
||||
LL | fn bar() -> impl Sized {}
|
||||
| +++++++++++++
|
||||
LL | fn bar()-> impl Sized {}
|
||||
| +++++++++++++
|
||||
|
||||
error: impl trait in impl method signature does not match trait method signature
|
||||
--> $DIR/refine.rs:22:17
|
||||
|
|
|
@ -2,6 +2,6 @@ use std::fmt::Debug;
|
|||
|
||||
fn main() {
|
||||
let x: Option<impl Debug> = Some(44_u32);
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/issue-54600.rs:4:19
|
||||
|
|
||||
LL | let x: Option<impl Debug> = Some(44_u32);
|
||||
|
|
|
@ -3,5 +3,5 @@ use std::ops::Add;
|
|||
fn main() {
|
||||
let i: i32 = 0;
|
||||
let j: &impl Add = &i;
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/issue-54840.rs:5:13
|
||||
|
|
||||
LL | let j: &impl Add = &i;
|
||||
|
|
|
@ -8,5 +8,5 @@ fn mk_gen() -> impl Generator<Return=!, Yield=()> {
|
|||
|
||||
fn main() {
|
||||
let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/issue-58504.rs:10:16
|
||||
|
|
||||
LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
|
||||
|
|
|
@ -5,9 +5,9 @@ impl Lam for B {}
|
|||
pub struct Wrap<T>(T);
|
||||
|
||||
const _A: impl Lam = {
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
let x: Wrap<impl Lam> = Wrap(B);
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
x.0
|
||||
};
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in const types
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in const types
|
||||
--> $DIR/issue-58956.rs:7:11
|
||||
|
|
||||
LL | const _A: impl Lam = {
|
||||
| ^^^^^^^^
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/issue-58956.rs:9:17
|
||||
|
|
||||
LL | let x: Wrap<impl Lam> = Wrap(B);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
let x : (impl Copy,) = (true,);
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/issue-70971.rs:2:14
|
||||
|
|
||||
LL | let x : (impl Copy,) = (true,);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
struct Bug {
|
||||
V1: [(); {
|
||||
let f: impl core::future::Future<Output = u8> = async { 1 };
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
//~| expected identifier
|
||||
1
|
||||
}],
|
||||
|
|
|
@ -9,7 +9,7 @@ LL | let f: impl core::future::Future<Output = u8> = async { 1 };
|
|||
= help: pass `--edition 2021` to `rustc`
|
||||
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/issue-79099.rs:3:16
|
||||
|
|
||||
LL | let f: impl core::future::Future<Output = u8> = async { 1 };
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
struct Foo<T = impl Copy>(T);
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
|
||||
|
||||
type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ ERROR `impl Trait` only allowed in function and inherent method argument and return types
|
||||
|
||||
// should not cause ICE
|
||||
fn x() -> Foo {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
|
||||
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:1:16
|
||||
|
|
||||
LL | struct Foo<T = impl Copy>(T);
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in generic parameter defaults
|
||||
--> $DIR/issue-83929-impl-trait-in-generic-default.rs:4:20
|
||||
|
|
||||
LL | type Result<T, E = impl std::error::Error> = std::result::Result<T, E>;
|
||||
|
|
|
@ -3,7 +3,7 @@ impl Trait for () {}
|
|||
|
||||
fn foo<'a: 'a>() {
|
||||
let _x: impl Trait = ();
|
||||
//~^ `impl Trait` only allowed in function and inherent method return types
|
||||
//~^ `impl Trait` only allowed in function and inherent method argument and return types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings
|
||||
error[E0562]: `impl Trait` only allowed in function and inherent method argument and return types, not in variable bindings
|
||||
--> $DIR/issue-84919.rs:5:13
|
||||
|
|
||||
LL | let _x: impl Trait = ();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue