diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index 816a71f25579..702df250999f 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -1197,6 +1197,19 @@ impl Clone for LinkedList { fn clone(&self) -> Self { self.iter().cloned().collect() } + + fn clone_from(&mut self, other: &Self) { + let mut iter_other = other.iter(); + if self.len() > other.len() { + self.split_off(other.len()); + } + for (elem, elem_other) in self.iter_mut().zip(&mut iter_other) { + elem.clone_from(elem_other); + } + if !iter_other.is_empty() { + self.extend(iter_other.cloned()); + } + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/liballoc/collections/linked_list/tests.rs b/src/liballoc/collections/linked_list/tests.rs index ecb5948f11b3..1001f6bba3b8 100644 --- a/src/liballoc/collections/linked_list/tests.rs +++ b/src/liballoc/collections/linked_list/tests.rs @@ -110,6 +110,49 @@ fn test_append() { check_links(&n); } +#[test] +fn test_clone_from() { + // Short cloned from long + { + let v = vec![1, 2, 3, 4, 5]; + let u = vec![8, 7, 6, 2, 3, 4, 5]; + let mut m = list_from(&v); + let n = list_from(&u); + m.clone_from(&n); + check_links(&m); + assert_eq!(m, n); + for elt in u { + assert_eq!(m.pop_front(), Some(elt)) + } + } + // Long cloned from short + { + let v = vec![1, 2, 3, 4, 5]; + let u = vec![6, 7, 8]; + let mut m = list_from(&v); + let n = list_from(&u); + m.clone_from(&n); + check_links(&m); + assert_eq!(m, n); + for elt in u { + assert_eq!(m.pop_front(), Some(elt)) + } + } + // Two equal length lists + { + let v = vec![1, 2, 3, 4, 5]; + let u = vec![9, 8, 1, 2, 3]; + let mut m = list_from(&v); + let n = list_from(&u); + m.clone_from(&n); + check_links(&m); + assert_eq!(m, n); + for elt in u { + assert_eq!(m.pop_front(), Some(elt)) + } + } +} + #[test] fn test_insert_prev() { let mut m = list_from(&[0, 2, 4, 6, 8]); diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs index db5b197c5d67..d5fcc0ef6ede 100644 --- a/src/librustc/hir/lowering/expr.rs +++ b/src/librustc/hir/lowering/expr.rs @@ -89,9 +89,14 @@ impl LoweringContext<'_> { hir::MatchSource::Normal, ), ExprKind::Async(capture_clause, closure_node_id, ref block) => { - self.make_async_expr(capture_clause, closure_node_id, None, block.span, |this| { - this.with_new_scopes(|this| this.lower_block_expr(block)) - }) + self.make_async_expr( + capture_clause, + closure_node_id, + None, + block.span, + hir::AsyncGeneratorKind::Block, + |this| this.with_new_scopes(|this| this.lower_block_expr(block)), + ) } ExprKind::Await(ref expr) => self.lower_expr_await(e.span, expr), ExprKind::Closure( @@ -457,6 +462,7 @@ impl LoweringContext<'_> { closure_node_id: NodeId, ret_ty: Option>, span: Span, + async_gen_kind: hir::AsyncGeneratorKind, body: impl FnOnce(&mut LoweringContext<'_>) -> hir::Expr, ) -> hir::ExprKind { let capture_clause = self.lower_capture_clause(capture_clause); @@ -470,7 +476,7 @@ impl LoweringContext<'_> { }; let decl = self.lower_fn_decl(&ast_decl, None, /* impl trait allowed */ false, None); let body_id = self.lower_fn_body(&ast_decl, |this| { - this.generator_kind = Some(hir::GeneratorKind::Async); + this.generator_kind = Some(hir::GeneratorKind::Async(async_gen_kind)); body(this) }); @@ -522,7 +528,7 @@ impl LoweringContext<'_> { /// ``` fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind { match self.generator_kind { - Some(hir::GeneratorKind::Async) => {}, + Some(hir::GeneratorKind::Async(_)) => {}, Some(hir::GeneratorKind::Gen) | None => { let mut err = struct_span_err!( @@ -727,7 +733,7 @@ impl LoweringContext<'_> { Movability::Static => hir::GeneratorMovability::Static, }) }, - Some(hir::GeneratorKind::Async) => { + Some(hir::GeneratorKind::Async(_)) => { bug!("non-`async` closure body turned `async` during lowering"); }, None => { @@ -786,10 +792,12 @@ impl LoweringContext<'_> { None }; let async_body = this.make_async_expr( - capture_clause, closure_id, async_ret_ty, body.span, - |this| { - this.with_new_scopes(|this| this.lower_expr(body)) - } + capture_clause, + closure_id, + async_ret_ty, + body.span, + hir::AsyncGeneratorKind::Closure, + |this| this.with_new_scopes(|this| this.lower_expr(body)), ); this.expr(fn_decl_span, async_body, ThinVec::new()) }); @@ -1005,7 +1013,7 @@ impl LoweringContext<'_> { fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind { match self.generator_kind { Some(hir::GeneratorKind::Gen) => {}, - Some(hir::GeneratorKind::Async) => { + Some(hir::GeneratorKind::Async(_)) => { span_err!( self.sess, span, diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index 7159db736a71..548a2fedfff6 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -1222,7 +1222,11 @@ impl LoweringContext<'_> { } let async_expr = this.make_async_expr( - CaptureBy::Value, closure_id, None, body.span, + CaptureBy::Value, + closure_id, + None, + body.span, + hir::AsyncGeneratorKind::Fn, |this| { // Create a block from the user's function body: let user_body = this.lower_block_expr(body); diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 9b4d88a5a096..d5892794d649 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1362,21 +1362,49 @@ impl Body { } /// The type of source expression that caused this generator to be created. -// Not `IsAsync` because we want to eventually add support for `AsyncGen` #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum GeneratorKind { - /// An `async` block or function. - Async, + /// An explicit `async` block or the body of an async function. + Async(AsyncGeneratorKind), + /// A generator literal created via a `yield` inside a closure. Gen, } impl fmt::Display for GeneratorKind { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + GeneratorKind::Async(k) => fmt::Display::fmt(k, f), + GeneratorKind::Gen => f.write_str("generator"), + } + } +} + +/// In the case of a generator created as part of an async construct, +/// which kind of async construct caused it to be created? +/// +/// This helps error messages but is also used to drive coercions in +/// type-checking (see #60424). +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable, + RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +pub enum AsyncGeneratorKind { + /// An explicit `async` block written by the user. + Block, + + /// An explicit `async` block written by the user. + Closure, + + /// The `async` block generated as the body of an async function. + Fn, +} + +impl fmt::Display for AsyncGeneratorKind { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(match self { - GeneratorKind::Async => "`async` object", - GeneratorKind::Gen => "generator", + AsyncGeneratorKind::Block => "`async` block", + AsyncGeneratorKind::Closure => "`async` closure body", + AsyncGeneratorKind::Fn => "`async fn` body", }) } } @@ -1758,6 +1786,7 @@ pub struct Destination { pub enum GeneratorMovability { /// May contain self-references, `!Unpin`. Static, + /// Must not contain self-references, `Unpin`. Movable, } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index b06b63455ba4..a7ad62d5f706 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -1307,6 +1307,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } } + /// Resolve any type variables found in `value` -- but only one + /// level. So, if the variable `?X` is bound to some type + /// `Foo`, then this would return `Foo` (but `?Y` may + /// itself be bound to a type). + /// + /// Useful when you only need to inspect the outermost level of + /// the type and don't care about nested types (or perhaps you + /// will be resolving them as well, e.g. in a loop). pub fn shallow_resolve(&self, value: T) -> T where T: TypeFoldable<'tcx>, @@ -1567,6 +1575,9 @@ impl<'a, 'tcx> ShallowResolver<'a, 'tcx> { ShallowResolver { infcx } } + /// If `typ` is a type variable of some kind, resolve it one level + /// (but do not resolve types found in the result). If `typ` is + /// not a type variable, just return it unmodified. pub fn shallow_resolve(&mut self, typ: Ty<'tcx>) -> Ty<'tcx> { match typ.kind { ty::Infer(ty::TyVar(v)) => { diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 0c7aa3582ac2..9aea46da68b1 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1026,7 +1026,8 @@ impl EmitterWriter { children.iter() .map(|sub| self.get_multispan_max_line_num(&sub.span)) .max() - .unwrap_or(primary) + .unwrap_or(0) + .max(primary) } /// Adds a left margin to every line but the first, given a padding length and the label being diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index bdf8f3b1d4ae..162555cd3ce4 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -337,7 +337,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> ClosureSignatures<'tcx> { debug!("sig_of_closure_no_expectation()"); - let bound_sig = self.supplied_sig_of_closure(expr_def_id, decl); + let bound_sig = self.supplied_sig_of_closure(expr_def_id, decl, body); self.closure_sigs(expr_def_id, body, bound_sig) } @@ -490,7 +490,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // // (See comment on `sig_of_closure_with_expectation` for the // meaning of these letters.) - let supplied_sig = self.supplied_sig_of_closure(expr_def_id, decl); + let supplied_sig = self.supplied_sig_of_closure(expr_def_id, decl, body); debug!( "check_supplied_sig_against_expectation: supplied_sig={:?}", @@ -591,14 +591,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, expr_def_id: DefId, decl: &hir::FnDecl, + body: &hir::Body, ) -> ty::PolyFnSig<'tcx> { let astconv: &dyn AstConv<'_> = self; + debug!( + "supplied_sig_of_closure(decl={:?}, body.generator_kind={:?})", + decl, + body.generator_kind, + ); + // First, convert the types that the user supplied (if any). let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a)); let supplied_return = match decl.output { hir::Return(ref output) => astconv.ast_ty_to_ty(&output), - hir::DefaultReturn(_) => astconv.ty_infer(None, decl.output.span()), + hir::DefaultReturn(_) => match body.generator_kind { + // In the case of the async block that we create for a function body, + // we expect the return type of the block to match that of the enclosing + // function. + Some(hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Fn)) => { + debug!("supplied_sig_of_closure: closure is async fn body"); + self.deduce_future_output_from_obligations(expr_def_id) + } + + _ => astconv.ty_infer(None, decl.output.span()), + } }; let result = ty::Binder::bind(self.tcx.mk_fn_sig( @@ -620,6 +637,117 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { result } + /// Invoked when we are translating the generator that results + /// from desugaring an `async fn`. Returns the "sugared" return + /// type of the `async fn` -- that is, the return type that the + /// user specified. The "desugared" return type is a `impl + /// Future`, so we do this by searching through the + /// obligations to extract the `T`. + fn deduce_future_output_from_obligations( + &self, + expr_def_id: DefId, + ) -> Ty<'tcx> { + debug!("deduce_future_output_from_obligations(expr_def_id={:?})", expr_def_id); + + let ret_coercion = + self.ret_coercion + .as_ref() + .unwrap_or_else(|| span_bug!( + self.tcx.def_span(expr_def_id), + "async fn generator outside of a fn" + )); + + // In practice, the return type of the surrounding function is + // always a (not yet resolved) inference variable, because it + // is the hidden type for an `impl Trait` that we are going to + // be inferring. + let ret_ty = ret_coercion.borrow().expected_ty(); + let ret_ty = self.inh.infcx.shallow_resolve(ret_ty); + let ret_vid = match ret_ty.kind { + ty::Infer(ty::TyVar(ret_vid)) => ret_vid, + _ => { + span_bug!( + self.tcx.def_span(expr_def_id), + "async fn generator return type not an inference variable" + ) + } + }; + + // Search for a pending obligation like + // + // `::Output = T` + // + // where R is the return type we are expecting. This type `T` + // will be our output. + let output_ty = self.obligations_for_self_ty(ret_vid) + .find_map(|(_, obligation)| { + if let ty::Predicate::Projection(ref proj_predicate) = obligation.predicate { + self.deduce_future_output_from_projection( + obligation.cause.span, + proj_predicate + ) + } else { + None + } + }) + .unwrap(); + + debug!("deduce_future_output_from_obligations: output_ty={:?}", output_ty); + output_ty + } + + /// Given a projection like + /// + /// `::Output = T` + /// + /// where `X` is some type that has no late-bound regions, returns + /// `Some(T)`. If the projection is for some other trait, returns + /// `None`. + fn deduce_future_output_from_projection( + &self, + cause_span: Span, + predicate: &ty::PolyProjectionPredicate<'tcx>, + ) -> Option> { + debug!("deduce_future_output_from_projection(predicate={:?})", predicate); + + // We do not expect any bound regions in our predicate, so + // skip past the bound vars. + let predicate = match predicate.no_bound_vars() { + Some(p) => p, + None => { + debug!("deduce_future_output_from_projection: has late-bound regions"); + return None; + } + }; + + // Check that this is a projection from the `Future` trait. + let trait_ref = predicate.projection_ty.trait_ref(self.tcx); + let future_trait = self.tcx.lang_items().future_trait().unwrap(); + if trait_ref.def_id != future_trait { + debug!("deduce_future_output_from_projection: not a future"); + return None; + } + + // The `Future` trait has only one associted item, `Output`, + // so check that this is what we see. + let output_assoc_item = self.tcx.associated_items(future_trait).nth(0).unwrap().def_id; + if output_assoc_item != predicate.projection_ty.item_def_id { + span_bug!( + cause_span, + "projecting associated item `{:?}` from future, which is not Output `{:?}`", + predicate.projection_ty.item_def_id, + output_assoc_item, + ); + } + + // Extract the type from the projection. Note that there can + // be no bound variables in this type because the "self type" + // does not have any regions in it. + let output_ty = self.resolve_vars_if_possible(&predicate.ty); + debug!("deduce_future_output_from_projection: output_ty={:?}", output_ty); + Some(output_ty) + } + /// Converts the types that the user supplied, in case that doing /// so should yield an error, but returns back a signature where /// all parameters are of type `TyErr`. diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 940537a5f48a..619768e018c7 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx> InteriorVisitor<'a, 'tcx> { expr_and_pat_count: 0, source: match self.kind { // Guess based on the kind of the current generator. hir::GeneratorKind::Gen => hir::YieldSource::Yield, - hir::GeneratorKind::Async => hir::YieldSource::Await, + hir::GeneratorKind::Async(_) => hir::YieldSource::Await, }, })); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 3ab474d16b86..880998ab72ec 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -562,7 +562,19 @@ pub struct FnCtxt<'a, 'tcx> { // if type checking is run in parallel. err_count_on_creation: usize, + /// If `Some`, this stores coercion information for returned + /// expressions. If `None`, this is in a context where return is + /// inappropriate, such as a const expression. + /// + /// This is a `RefCell`, which means that we + /// can track all the return expressions and then use them to + /// compute a useful coercion from the set, similar to a match + /// expression or other branching context. You can use methods + /// like `expected_ty` to access the declared return type (if + /// any). ret_coercion: Option>>, + + /// First span of a return site that we find. Used in error messages. ret_coercion_span: RefCell>, yield_ty: Option>, @@ -4534,7 +4546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let item_id = self.tcx().hir().get_parent_node(self.body_id); if let Some(body_id) = self.tcx().hir().maybe_body_owned_by(item_id) { let body = self.tcx().hir().body(body_id); - if let Some(hir::GeneratorKind::Async) = body.generator_kind { + if let Some(hir::GeneratorKind::Async(_)) = body.generator_kind { let sp = expr.span; // Check for `Future` implementations by constructing a predicate to // prove: `::Output == U` diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 20c517d779b4..de1cc12aea37 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -999,11 +999,16 @@ fn report_bivariance(tcx: TyCtxt<'_>, span: Span, param_name: ast::Name) { let suggested_marker_id = tcx.lang_items().phantom_data(); // Help is available only in presence of lang items. - if let Some(def_id) = suggested_marker_id { - err.help(&format!("consider removing `{}` or using a marker such as `{}`", - param_name, - tcx.def_path_str(def_id))); - } + let msg = if let Some(def_id) = suggested_marker_id { + format!( + "consider removing `{}`, refering to it in a field, or using a marker such as `{}`", + param_name, + tcx.def_path_str(def_id), + ) + } else { + format!( "consider removing `{}` or refering to it in a field", param_name) + }; + err.help(&msg); err.emit(); } diff --git a/src/libstd/backtrace.rs b/src/libstd/backtrace.rs index 61c42a56071e..9f400713a86d 100644 --- a/src/libstd/backtrace.rs +++ b/src/libstd/backtrace.rs @@ -113,7 +113,7 @@ pub struct Backtrace { /// The current status of a backtrace, indicating whether it was captured or /// whether it is empty for some other reason. #[non_exhaustive] -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum BacktraceStatus { /// Capturing a backtrace is not supported, likely because it's not /// implemented for the current platform. diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index e8d7b7663ed5..4ad0bd06d99a 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -1220,6 +1220,7 @@ impl<'a> Parser<'a> { err: &mut DiagnosticBuilder<'_>, pat: P, require_name: bool, + is_self_allowed: bool, is_trait_item: bool, ) -> Option { // If we find a pattern followed by an identifier, it could be an (incorrect) @@ -1241,14 +1242,27 @@ impl<'a> Parser<'a> { if require_name && ( is_trait_item || self.token == token::Comma || + self.token == token::Lt || self.token == token::CloseDelim(token::Paren) - ) { // `fn foo(a, b) {}` or `fn foo(usize, usize) {}` - err.span_suggestion( - pat.span, - "if this was a parameter name, give it a type", - format!("{}: TypeName", ident), - Applicability::HasPlaceholders, - ); + ) { // `fn foo(a, b) {}`, `fn foo(a, b) {}` or `fn foo(usize, usize) {}` + if is_self_allowed { + err.span_suggestion( + pat.span, + "if this is a `self` type, give it a parameter name", + format!("self: {}", ident), + Applicability::MaybeIncorrect, + ); + } + // Avoid suggesting that `fn foo(HashMap)` is fixed with a change to + // `fn foo(HashMap: TypeName)`. + if self.token != token::Lt { + err.span_suggestion( + pat.span, + "if this was a parameter name, give it a type", + format!("{}: TypeName", ident), + Applicability::HasPlaceholders, + ); + } err.span_suggestion( pat.span, "if this is a type, explicitly ignore the parameter name", @@ -1256,7 +1270,9 @@ impl<'a> Parser<'a> { Applicability::MachineApplicable, ); err.note("anonymous parameters are removed in the 2018 edition (see RFC 1685)"); - return Some(ident); + + // Don't attempt to recover by using the `X` in `X` as the parameter name. + return if self.token == token::Lt { None } else { Some(ident) }; } } None diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 95f84d5cb331..d4a6e9f6c6bc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1212,6 +1212,7 @@ impl<'a> Parser<'a> { &mut err, pat, is_name_required, + is_self_allowed, is_trait_item, ) { err.emit(); diff --git a/src/test/ui/anon-params-denied-2018.stderr b/src/test/ui/anon-params-denied-2018.stderr index a58998e4891e..3fcf41a9a60a 100644 --- a/src/test/ui/anon-params-denied-2018.stderr +++ b/src/test/ui/anon-params-denied-2018.stderr @@ -5,6 +5,10 @@ LL | fn foo(i32); | ^ expected one of `:`, `@`, or `|` here | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | fn foo(self: i32); + | ^^^^^^^^^ help: if this was a parameter name, give it a type | LL | fn foo(i32: TypeName); @@ -21,6 +25,10 @@ LL | fn bar_with_default_impl(String, String) {} | ^ expected one of `:`, `@`, or `|` here | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | fn bar_with_default_impl(self: String, String) {} + | ^^^^^^^^^^^^ help: if this was a parameter name, give it a type | LL | fn bar_with_default_impl(String: TypeName, String) {} diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs index 753a4e491550..971d44763348 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.rs +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.rs @@ -20,7 +20,7 @@ fn return_targets_async_block_not_fn() -> u8 { } async fn return_targets_async_block_not_async_fn() -> u8 { - //~^ ERROR type mismatch resolving + //~^ ERROR mismatched types let block = async { return 0u8; }; diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr index c36caa5586fb..a9b0e7ae7795 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -39,6 +39,22 @@ LL | let _: &dyn Future = █ found type `()` = note: required for the cast to the object type `dyn std::future::Future` +error[E0308]: mismatched types + --> $DIR/async-block-control-flow-static-semantics.rs:22:58 + | +LL | async fn return_targets_async_block_not_async_fn() -> u8 { + | __________________________________________________________^ +LL | | +LL | | let block = async { +LL | | return 0u8; +... | +LL | | +LL | | } + | |_^ expected u8, found () + | + = note: expected type `u8` + found type `()` + error[E0271]: type mismatch resolving `::Output == ()` --> $DIR/async-block-control-flow-static-semantics.rs:27:39 | @@ -49,16 +65,6 @@ LL | let _: &dyn Future = █ found type `()` = note: required for the cast to the object type `dyn std::future::Future` -error[E0271]: type mismatch resolving `::Output == u8` - --> $DIR/async-block-control-flow-static-semantics.rs:22:55 - | -LL | async fn return_targets_async_block_not_async_fn() -> u8 { - | ^^ expected (), found u8 - | - = note: expected type `()` - found type `u8` - = note: the return type of a function must have a statically known size - error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:48:44 | diff --git a/src/test/ui/async-await/async-error-span.rs b/src/test/ui/async-await/async-error-span.rs index dec3ac0f6855..28132c9789c6 100644 --- a/src/test/ui/async-await/async-error-span.rs +++ b/src/test/ui/async-await/async-error-span.rs @@ -9,7 +9,7 @@ fn get_future() -> impl Future { } async fn foo() { - let a; //~ ERROR type inside `async` object must be known in this context + let a; //~ ERROR type inside `async fn` body must be known in this context get_future().await; } diff --git a/src/test/ui/async-await/async-error-span.stderr b/src/test/ui/async-await/async-error-span.stderr index 47441f5e4efc..b551b99587dd 100644 --- a/src/test/ui/async-await/async-error-span.stderr +++ b/src/test/ui/async-await/async-error-span.stderr @@ -1,10 +1,10 @@ -error[E0698]: type inside `async` object must be known in this context +error[E0698]: type inside `async fn` body must be known in this context --> $DIR/async-error-span.rs:12:9 | LL | let a; | ^ cannot infer type | -note: the type is part of the `async` object because of this `await` +note: the type is part of the `async fn` body because of this `await` --> $DIR/async-error-span.rs:13:5 | LL | get_future().await; diff --git a/src/test/ui/async-await/issues/issue-63388-1.rs b/src/test/ui/async-await/issues/issue-63388-1.rs index 3cde5de21988..baecf49c798e 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.rs +++ b/src/test/ui/async-await/issues/issue-63388-1.rs @@ -9,9 +9,9 @@ trait Foo {} impl Xyz { async fn do_sth<'a>( &'a self, foo: &dyn Foo - ) -> &dyn Foo //~ ERROR lifetime mismatch + ) -> &dyn Foo { - foo + foo //~ ERROR lifetime mismatch } } diff --git a/src/test/ui/async-await/issues/issue-63388-1.stderr b/src/test/ui/async-await/issues/issue-63388-1.stderr index a54cadb0cd25..2917fa9ccb7f 100644 --- a/src/test/ui/async-await/issues/issue-63388-1.stderr +++ b/src/test/ui/async-await/issues/issue-63388-1.stderr @@ -1,12 +1,13 @@ error[E0623]: lifetime mismatch - --> $DIR/issue-63388-1.rs:12:10 + --> $DIR/issue-63388-1.rs:14:9 | LL | &'a self, foo: &dyn Foo | -------- this parameter and the return type are declared with different lifetimes... LL | ) -> &dyn Foo - | ^^^^^^^^ - | | - | ...but data from `foo` is returned here + | -------- +LL | { +LL | foo + | ^^^ ...but data from `foo` is returned here error: aborting due to previous error diff --git a/src/test/ui/async-await/issues/issue-63388-2.stderr b/src/test/ui/async-await/issues/issue-63388-2.stderr index 1edeb3d54938..5099297fbeb1 100644 --- a/src/test/ui/async-await/issues/issue-63388-2.stderr +++ b/src/test/ui/async-await/issues/issue-63388-2.stderr @@ -11,8 +11,9 @@ error: cannot infer an appropriate lifetime | LL | foo: &dyn Foo, bar: &'a dyn Foo | ^^^ ...but this borrow... -LL | ) -> &dyn Foo - | -------- this return type evaluates to the `'static` lifetime... +... +LL | foo + | --- this return type evaluates to the `'static` lifetime... | note: ...can't outlive the lifetime '_ as defined on the method body at 11:14 --> $DIR/issue-63388-2.rs:11:14 @@ -21,8 +22,8 @@ LL | foo: &dyn Foo, bar: &'a dyn Foo | ^ help: you can add a constraint to the return type to make it last less than `'static` and match the lifetime '_ as defined on the method body at 11:14 | -LL | ) -> &dyn Foo + '_ - | ^^^^^^^^^^^^^ +LL | foo + '_ + | error: aborting due to 2 previous errors diff --git a/src/test/ui/async-await/return-ty-raw-ptr-coercion.rs b/src/test/ui/async-await/return-ty-raw-ptr-coercion.rs new file mode 100644 index 000000000000..9fe0869cad6c --- /dev/null +++ b/src/test/ui/async-await/return-ty-raw-ptr-coercion.rs @@ -0,0 +1,25 @@ +// Check that we apply unsizing coercions based on the return type. +// +// Also serves as a regression test for #60424. +// +// edition:2018 +// check-pass + +#![allow(warnings)] + +use std::fmt::Debug; + +const TMP: u32 = 22; + +// Coerce from `&u32` to `*const u32` +fn raw_pointer_coercion() { + fn sync_example() -> *const u32 { + &TMP + } + + async fn async_example() -> *const u32 { + &TMP + } +} + +fn main() {} diff --git a/src/test/ui/async-await/return-ty-unsize-coercion.rs b/src/test/ui/async-await/return-ty-unsize-coercion.rs new file mode 100644 index 000000000000..93832ef7eddb --- /dev/null +++ b/src/test/ui/async-await/return-ty-unsize-coercion.rs @@ -0,0 +1,45 @@ +// Check that we apply unsizing coercions based on the return type. +// +// Also serves as a regression test for #60424. +// +// edition:2018 +// check-pass + +#![allow(warnings)] + +use std::fmt::Debug; + +// Unsizing coercion from `Box<&'static str>` to `Box`. +fn unsize_trait_coercion() { + fn sync_example() -> Box { + Box::new("asdf") + } + + async fn async_example() -> Box { + Box::new("asdf") + } +} + +// Unsizing coercion from `Box<[u32; N]>` to `Box<[32]>`. +fn unsize_slice_coercion() { + fn sync_example() -> Box<[u32]> { + Box::new([0]) + } + + async fn async_example() -> Box<[u32]> { + Box::new([0]) + } +} + +// Unsizing coercion from `&[&str; 1]` to `&[&str]` +fn unsize_slice_str_coercion() { + fn sync_example() -> &'static [&'static str] { + &["hi"] + } + + async fn async_example() -> &'static [&'static str] { + &["hi"] + } +} + +fn main() {} diff --git a/src/test/ui/async-await/unresolved_type_param.rs b/src/test/ui/async-await/unresolved_type_param.rs index d8ea87d2775b..2876f9fea0e0 100644 --- a/src/test/ui/async-await/unresolved_type_param.rs +++ b/src/test/ui/async-await/unresolved_type_param.rs @@ -7,9 +7,9 @@ async fn bar() -> () {} async fn foo() { bar().await; - //~^ ERROR type inside `async` object must be known in this context + //~^ ERROR type inside `async fn` body must be known in this context //~| NOTE cannot infer type for `T` - //~| NOTE the type is part of the `async` object because of this `await` + //~| NOTE the type is part of the `async fn` body because of this `await` //~| NOTE in this expansion of desugaring of `await` } fn main() {} diff --git a/src/test/ui/async-await/unresolved_type_param.stderr b/src/test/ui/async-await/unresolved_type_param.stderr index f3090a2b980e..c7866fc77441 100644 --- a/src/test/ui/async-await/unresolved_type_param.stderr +++ b/src/test/ui/async-await/unresolved_type_param.stderr @@ -1,10 +1,10 @@ -error[E0698]: type inside `async` object must be known in this context +error[E0698]: type inside `async fn` body must be known in this context --> $DIR/unresolved_type_param.rs:9:5 | LL | bar().await; | ^^^ cannot infer type for `T` | -note: the type is part of the `async` object because of this `await` +note: the type is part of the `async fn` body because of this `await` --> $DIR/unresolved_type_param.rs:9:5 | LL | bar().await; diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr b/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr index 142efe45ac2d..b50605ce0fe1 100644 --- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr +++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.stderr @@ -18,7 +18,7 @@ error[E0392]: parameter `T` is never used LL | pub struct Dependent([(); X]); | ^ unused parameter | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0392.stderr b/src/test/ui/error-codes/E0392.stderr index d0b808df184c..25cd9984052f 100644 --- a/src/test/ui/error-codes/E0392.stderr +++ b/src/test/ui/error-codes/E0392.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used LL | enum Foo { Bar } | ^ unused parameter | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to previous error diff --git a/src/test/ui/inner-static-type-parameter.stderr b/src/test/ui/inner-static-type-parameter.stderr index 083b4b67eb45..e8281b916f6f 100644 --- a/src/test/ui/inner-static-type-parameter.stderr +++ b/src/test/ui/inner-static-type-parameter.stderr @@ -14,7 +14,7 @@ error[E0392]: parameter `T` is never used LL | enum Bar { What } | ^ unused parameter | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-17904-2.stderr b/src/test/ui/issues/issue-17904-2.stderr index 930409cc6372..9d1d76915868 100644 --- a/src/test/ui/issues/issue-17904-2.stderr +++ b/src/test/ui/issues/issue-17904-2.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used LL | struct Foo where T: Copy; | ^ unused parameter | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 72a8fe4283b5..675b47a68ad2 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `T` is never used LL | struct NoData; | ^ unused parameter | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error[E0275]: overflow evaluating the requirement `NoData>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: Foo` --> $DIR/issue-20413.rs:8:1 diff --git a/src/test/ui/issues/issue-36299.stderr b/src/test/ui/issues/issue-36299.stderr index edbe790a0c9f..a092bab0e81f 100644 --- a/src/test/ui/issues/issue-36299.stderr +++ b/src/test/ui/issues/issue-36299.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used LL | struct Foo<'a, A> {} | ^^ unused parameter | - = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error[E0392]: parameter `A` is never used --> $DIR/issue-36299.rs:1:16 @@ -12,7 +12,7 @@ error[E0392]: parameter `A` is never used LL | struct Foo<'a, A> {} | ^ unused parameter | - = help: consider removing `A` or using a marker such as `std::marker::PhantomData` + = help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-36638.stderr b/src/test/ui/issues/issue-36638.stderr index f3f94198465d..699dba0e3f83 100644 --- a/src/test/ui/issues/issue-36638.stderr +++ b/src/test/ui/issues/issue-36638.stderr @@ -16,7 +16,7 @@ error[E0392]: parameter `Self` is never used LL | struct Foo(Self); | ^^^^ unused parameter | - = help: consider removing `Self` or using a marker such as `std::marker::PhantomData` + = help: consider removing `Self`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 3 previous errors diff --git a/src/test/ui/issues/issue-37534.stderr b/src/test/ui/issues/issue-37534.stderr index 2ea9dcbe9d0a..b5ef6ec594a9 100644 --- a/src/test/ui/issues/issue-37534.stderr +++ b/src/test/ui/issues/issue-37534.stderr @@ -20,7 +20,7 @@ error[E0392]: parameter `T` is never used LL | struct Foo { } | ^ unused parameter | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/pat-lt-bracket-2.stderr b/src/test/ui/parser/pat-lt-bracket-2.stderr index dbc8d0f5865c..2191e31ad1ff 100644 --- a/src/test/ui/parser/pat-lt-bracket-2.stderr +++ b/src/test/ui/parser/pat-lt-bracket-2.stderr @@ -3,6 +3,12 @@ error: expected one of `:`, `@`, or `|`, found `<` | LL | fn a(B<) {} | ^ expected one of `:`, `@`, or `|` here + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a type, explicitly ignore the parameter name + | +LL | fn a(_: B<) {} + | ^^^^ error: aborting due to previous error diff --git a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr index 003dd0699d38..57a987f70385 100644 --- a/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr +++ b/src/test/ui/regions/region-bounds-on-objects-and-type-parameters.stderr @@ -27,7 +27,7 @@ error[E0392]: parameter `'c` is never used LL | struct Foo<'a,'b,'c> { | ^^ unused parameter | - = help: consider removing `'c` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'c`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 3 previous errors diff --git a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr index 9860e9805b2e..e4248f3b974b 100644 --- a/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr +++ b/src/test/ui/rfc-2565-param-attrs/param-attrs-2018.stderr @@ -5,6 +5,10 @@ LL | trait Trait2015 { fn foo(#[allow(C)] i32); } | ^ expected one of `:`, `@`, or `|` here | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | trait Trait2015 { fn foo(#[allow(C)] self: i32); } + | ^^^^^^^^^ help: if this was a parameter name, give it a type | LL | trait Trait2015 { fn foo(#[allow(C)] i32: TypeName); } diff --git a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr index 57ad026bdcf9..e3c261576e61 100644 --- a/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr +++ b/src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.stderr @@ -1,28 +1,25 @@ error[E0623]: lifetime mismatch - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:45 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:8:52 | LL | async fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f } - | ---- ^^^^ - | | | - | | ...but data from `f` is returned here + | ---- ---- ^ ...but data from `f` is returned here + | | | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:55 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:11:82 | LL | async fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } - | ----- ^^^^^^^^^^^^^^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ----------------- ^ ...but data from `f` is returned here + | | | this parameter and the return type are declared with different lifetimes... error[E0623]: lifetime mismatch - --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:58 + --> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64 | LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } - | ----- ^^^ - | | | - | | ...but data from `arg` is returned here + | ----- --- ^^^ ...but data from `arg` is returned here + | | | this parameter and the return type are declared with different lifetimes... error: aborting due to 3 previous errors diff --git a/src/test/ui/self/elision/lt-ref-self-async.rs b/src/test/ui/self/elision/lt-ref-self-async.rs index e3ca0c2e2dd9..5aba7cfcf296 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.rs +++ b/src/test/ui/self/elision/lt-ref-self-async.rs @@ -11,29 +11,29 @@ impl<'a> Struct<'a> { // Test using `&self` sugar: async fn ref_self(&self, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } // Test using `&Self` explicitly: async fn ref_Self(self: &Self, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/lt-ref-self-async.stderr b/src/test/ui/self/elision/lt-ref-self-async.stderr index 2bc64bdf1f7a..6b668d9f1f65 100644 --- a/src/test/ui/self/elision/lt-ref-self-async.stderr +++ b/src/test/ui/self/elision/lt-ref-self-async.stderr @@ -1,56 +1,62 @@ error[E0623]: lifetime mismatch - --> $DIR/lt-ref-self-async.rs:13:42 + --> $DIR/lt-ref-self-async.rs:14:9 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/lt-ref-self-async.rs:19:48 + --> $DIR/lt-ref-self-async.rs:20:9 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/lt-ref-self-async.rs:23:57 + --> $DIR/lt-ref-self-async.rs:24:9 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/lt-ref-self-async.rs:27:57 + --> $DIR/lt-ref-self-async.rs:28:9 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/lt-ref-self-async.rs:31:66 + --> $DIR/lt-ref-self-async.rs:32:9 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/lt-ref-self-async.rs:35:62 + --> $DIR/lt-ref-self-async.rs:36:9 | LL | async fn box_pin_Self(self: Box>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-self-async.rs b/src/test/ui/self/elision/ref-mut-self-async.rs index 2ca14800a755..b8eb416d9043 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.rs +++ b/src/test/ui/self/elision/ref-mut-self-async.rs @@ -10,30 +10,30 @@ struct Struct { } impl Struct { // Test using `&mut self` sugar: - async fn ref_self(&mut self, f: &u32) -> &u32 { //~ ERROR lifetime mismatch - f + async fn ref_self(&mut self, f: &u32) -> &u32 { + f //~ ERROR lifetime mismatch } // Test using `&mut Self` explicitly: async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-mut-self-async.stderr b/src/test/ui/self/elision/ref-mut-self-async.stderr index 39a1b30ca532..29fbec9fa7ae 100644 --- a/src/test/ui/self/elision/ref-mut-self-async.stderr +++ b/src/test/ui/self/elision/ref-mut-self-async.stderr @@ -1,56 +1,62 @@ error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:13:46 + --> $DIR/ref-mut-self-async.rs:14:9 | LL | async fn ref_self(&mut self, f: &u32) -> &u32 { - | --------- ^^^^ - | | | - | | ...but data from `f` is returned here + | --------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:19:52 + --> $DIR/ref-mut-self-async.rs:20:9 | LL | async fn ref_Self(self: &mut Self, f: &u32) -> &u32 { - | --------- ^^^^ - | | | - | | ...but data from `f` is returned here + | --------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:23:61 + --> $DIR/ref-mut-self-async.rs:24:9 | LL | async fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 { - | --------- ^^^^ - | | | - | | ...but data from `f` is returned here + | --------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:27:61 + --> $DIR/ref-mut-self-async.rs:28:9 | LL | async fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 { - | --------- ^^^^ - | | | - | | ...but data from `f` is returned here + | --------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:31:70 + --> $DIR/ref-mut-self-async.rs:32:9 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | --------- ^^^^ - | | | - | | ...but data from `f` is returned here + | --------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-self-async.rs:35:70 + --> $DIR/ref-mut-self-async.rs:36:9 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | --------- ^^^^ - | | | - | | ...but data from `f` is returned here + | --------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error: aborting due to 6 previous errors diff --git a/src/test/ui/self/elision/ref-mut-struct-async.rs b/src/test/ui/self/elision/ref-mut-struct-async.rs index a671116de254..1822a9a468b0 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.rs +++ b/src/test/ui/self/elision/ref-mut-struct-async.rs @@ -11,23 +11,23 @@ impl Struct { // Test using `&mut Struct` explicitly: async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-mut-struct-async.stderr b/src/test/ui/self/elision/ref-mut-struct-async.stderr index fe4a636ada66..46591bfc9580 100644 --- a/src/test/ui/self/elision/ref-mut-struct-async.stderr +++ b/src/test/ui/self/elision/ref-mut-struct-async.stderr @@ -1,47 +1,52 @@ error[E0623]: lifetime mismatch - --> $DIR/ref-mut-struct-async.rs:13:56 + --> $DIR/ref-mut-struct-async.rs:14:9 | LL | async fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 { - | ----------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-struct-async.rs:17:65 + --> $DIR/ref-mut-struct-async.rs:18:9 | LL | async fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 { - | ----------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-struct-async.rs:21:65 + --> $DIR/ref-mut-struct-async.rs:22:9 | LL | async fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 { - | ----------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-struct-async.rs:25:74 + --> $DIR/ref-mut-struct-async.rs:26:9 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ----------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-mut-struct-async.rs:29:74 + --> $DIR/ref-mut-struct-async.rs:30:9 | LL | async fn box_pin_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ----------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error: aborting due to 5 previous errors diff --git a/src/test/ui/self/elision/ref-self-async.rs b/src/test/ui/self/elision/ref-self-async.rs index 06f3b127b216..9425fbfca8f0 100644 --- a/src/test/ui/self/elision/ref-self-async.rs +++ b/src/test/ui/self/elision/ref-self-async.rs @@ -19,34 +19,34 @@ impl Deref for Wrap { impl Struct { // Test using `&self` sugar: - async fn ref_self(&self, f: &u32) -> &u32 { //~ ERROR lifetime mismatch - f + async fn ref_self(&self, f: &u32) -> &u32 { + f //~ ERROR lifetime mismatch } // Test using `&Self` explicitly: async fn ref_Self(self: &Self, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-self-async.stderr b/src/test/ui/self/elision/ref-self-async.stderr index 2f9e2a01e347..c255d1893637 100644 --- a/src/test/ui/self/elision/ref-self-async.stderr +++ b/src/test/ui/self/elision/ref-self-async.stderr @@ -1,65 +1,72 @@ error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:22:42 + --> $DIR/ref-self-async.rs:23:9 | LL | async fn ref_self(&self, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:28:48 + --> $DIR/ref-self-async.rs:29:9 | LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:32:57 + --> $DIR/ref-self-async.rs:33:9 | LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:36:57 + --> $DIR/ref-self-async.rs:37:9 | LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:40:66 + --> $DIR/ref-self-async.rs:41:9 | LL | async fn box_box_ref_Self(self: Box>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:44:66 + --> $DIR/ref-self-async.rs:45:9 | LL | async fn box_pin_ref_Self(self: Box>, f: &u32) -> &u32 { - | ----- ^^^^ - | | | - | | ...but data from `f` is returned here + | ----- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-self-async.rs:48:69 + --> $DIR/ref-self-async.rs:49:9 | LL | async fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 { - | ----- ^^^ - | | | - | | ...but data from `f` is returned here + | ----- --- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error: aborting due to 7 previous errors diff --git a/src/test/ui/self/elision/ref-struct-async.rs b/src/test/ui/self/elision/ref-struct-async.rs index 94eaeedc734f..64c84c4cd2eb 100644 --- a/src/test/ui/self/elision/ref-struct-async.rs +++ b/src/test/ui/self/elision/ref-struct-async.rs @@ -11,23 +11,23 @@ impl Struct { // Test using `&Struct` explicitly: async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - f //~^ ERROR lifetime mismatch + f //~ ERROR lifetime mismatch } } diff --git a/src/test/ui/self/elision/ref-struct-async.stderr b/src/test/ui/self/elision/ref-struct-async.stderr index 222e27ebf0d9..c70facc931ec 100644 --- a/src/test/ui/self/elision/ref-struct-async.stderr +++ b/src/test/ui/self/elision/ref-struct-async.stderr @@ -1,47 +1,52 @@ error[E0623]: lifetime mismatch - --> $DIR/ref-struct-async.rs:13:52 + --> $DIR/ref-struct-async.rs:14:9 | LL | async fn ref_Struct(self: &Struct, f: &u32) -> &u32 { - | ------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-struct-async.rs:17:61 + --> $DIR/ref-struct-async.rs:18:9 | LL | async fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 { - | ------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-struct-async.rs:21:61 + --> $DIR/ref-struct-async.rs:22:9 | LL | async fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 { - | ------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-struct-async.rs:25:70 + --> $DIR/ref-struct-async.rs:26:9 | LL | async fn box_box_ref_Struct(self: Box>, f: &u32) -> &u32 { - | ------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error[E0623]: lifetime mismatch - --> $DIR/ref-struct-async.rs:29:66 + --> $DIR/ref-struct-async.rs:30:9 | LL | async fn box_pin_Struct(self: Box>, f: &u32) -> &u32 { - | ------- ^^^^ - | | | - | | ...but data from `f` is returned here + | ------- ---- + | | | this parameter and the return type are declared with different lifetimes... +LL | f + | ^ ...but data from `f` is returned here error: aborting due to 5 previous errors diff --git a/src/test/ui/self/self_type_keyword.stderr b/src/test/ui/self/self_type_keyword.stderr index 6534d8c36e34..456077b65b83 100644 --- a/src/test/ui/self/self_type_keyword.stderr +++ b/src/test/ui/self/self_type_keyword.stderr @@ -76,7 +76,7 @@ error[E0392]: parameter `'Self` is never used LL | struct Bar<'Self>; | ^^^^^ unused parameter | - = help: consider removing `'Self` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'Self`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 12 previous errors diff --git a/src/test/ui/span/issue-34264.stderr b/src/test/ui/span/issue-34264.stderr index cc0eccd37a26..8d4a66f142d2 100644 --- a/src/test/ui/span/issue-34264.stderr +++ b/src/test/ui/span/issue-34264.stderr @@ -3,6 +3,12 @@ error: expected one of `:`, `@`, or `|`, found `<` | LL | fn foo(Option, String) {} | ^ expected one of `:`, `@`, or `|` here + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a type, explicitly ignore the parameter name + | +LL | fn foo(_: Option, String) {} + | ^^^^^^^^^ error: expected one of `:`, `@`, or `|`, found `)` --> $DIR/issue-34264.rs:1:27 diff --git a/src/test/ui/suggestions/issue-64252-self-type.rs b/src/test/ui/suggestions/issue-64252-self-type.rs new file mode 100644 index 000000000000..128d5e85c22c --- /dev/null +++ b/src/test/ui/suggestions/issue-64252-self-type.rs @@ -0,0 +1,14 @@ +// This test checks that a suggestion to add a `self: ` parameter name is provided +// to functions where this is applicable. + +pub fn foo(Box) { } +//~^ ERROR expected one of `:`, `@`, or `|`, found `<` + +struct Bar; + +impl Bar { + fn bar(Box) { } + //~^ ERROR expected one of `:`, `@`, or `|`, found `<` +} + +fn main() { } diff --git a/src/test/ui/suggestions/issue-64252-self-type.stderr b/src/test/ui/suggestions/issue-64252-self-type.stderr new file mode 100644 index 000000000000..fa28a0d684e5 --- /dev/null +++ b/src/test/ui/suggestions/issue-64252-self-type.stderr @@ -0,0 +1,30 @@ +error: expected one of `:`, `@`, or `|`, found `<` + --> $DIR/issue-64252-self-type.rs:4:15 + | +LL | pub fn foo(Box) { } + | ^ expected one of `:`, `@`, or `|` here + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a type, explicitly ignore the parameter name + | +LL | pub fn foo(_: Box) { } + | ^^^^^^ + +error: expected one of `:`, `@`, or `|`, found `<` + --> $DIR/issue-64252-self-type.rs:10:15 + | +LL | fn bar(Box) { } + | ^ expected one of `:`, `@`, or `|` here + | + = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) +help: if this is a `self` type, give it a parameter name + | +LL | fn bar(self: Box) { } + | ^^^^^^^^^ +help: if this is a type, explicitly ignore the parameter name + | +LL | fn bar(_: Box) { } + | ^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/variance/variance-regions-unused-direct.stderr b/src/test/ui/variance/variance-regions-unused-direct.stderr index 21ff475663c6..95fa841a7588 100644 --- a/src/test/ui/variance/variance-regions-unused-direct.stderr +++ b/src/test/ui/variance/variance-regions-unused-direct.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used LL | struct Bivariant<'a>; | ^^ unused parameter | - = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error[E0392]: parameter `'d` is never used --> $DIR/variance-regions-unused-direct.rs:7:19 @@ -12,7 +12,7 @@ error[E0392]: parameter `'d` is never used LL | struct Struct<'a, 'd> { | ^^ unused parameter | - = help: consider removing `'d` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'d`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-regions-unused-indirect.stderr b/src/test/ui/variance/variance-regions-unused-indirect.stderr index fd66217f692f..c90bad8edd47 100644 --- a/src/test/ui/variance/variance-regions-unused-indirect.stderr +++ b/src/test/ui/variance/variance-regions-unused-indirect.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used LL | enum Foo<'a> { | ^^ unused parameter | - = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error[E0392]: parameter `'a` is never used --> $DIR/variance-regions-unused-indirect.rs:7:10 @@ -12,7 +12,7 @@ error[E0392]: parameter `'a` is never used LL | enum Bar<'a> { | ^^ unused parameter | - = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-unused-region-param.stderr b/src/test/ui/variance/variance-unused-region-param.stderr index a96b2338bf42..bba301cdbfbc 100644 --- a/src/test/ui/variance/variance-unused-region-param.stderr +++ b/src/test/ui/variance/variance-unused-region-param.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `'a` is never used LL | struct SomeStruct<'a> { x: u32 } | ^^ unused parameter | - = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error[E0392]: parameter `'a` is never used --> $DIR/variance-unused-region-param.rs:4:15 @@ -12,7 +12,7 @@ error[E0392]: parameter `'a` is never used LL | enum SomeEnum<'a> { Nothing } | ^^ unused parameter | - = help: consider removing `'a` or using a marker such as `std::marker::PhantomData` + = help: consider removing `'a`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 2 previous errors diff --git a/src/test/ui/variance/variance-unused-type-param.stderr b/src/test/ui/variance/variance-unused-type-param.stderr index 883db4629862..d2891015eb7f 100644 --- a/src/test/ui/variance/variance-unused-type-param.stderr +++ b/src/test/ui/variance/variance-unused-type-param.stderr @@ -4,7 +4,7 @@ error[E0392]: parameter `A` is never used LL | struct SomeStruct { x: u32 } | ^ unused parameter | - = help: consider removing `A` or using a marker such as `std::marker::PhantomData` + = help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error[E0392]: parameter `A` is never used --> $DIR/variance-unused-type-param.rs:9:15 @@ -12,7 +12,7 @@ error[E0392]: parameter `A` is never used LL | enum SomeEnum { Nothing } | ^ unused parameter | - = help: consider removing `A` or using a marker such as `std::marker::PhantomData` + = help: consider removing `A`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error[E0392]: parameter `T` is never used --> $DIR/variance-unused-type-param.rs:13:15 @@ -20,7 +20,7 @@ error[E0392]: parameter `T` is never used LL | enum ListCell { | ^ unused parameter | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + = help: consider removing `T`, refering to it in a field, or using a marker such as `std::marker::PhantomData` error: aborting due to 3 previous errors diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index e01184e3658b..337f9c4d6dbe 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -53,6 +53,9 @@ fn filter_dirs(path: &Path) -> bool { "src/tools/rls", "src/tools/rust-installer", "src/tools/rustfmt", + + // Filter RLS output directories + "target/rls", ]; skip.iter().any(|p| path.ends_with(p)) }