File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -775,6 +775,16 @@ impl<'a> LoweringContext<'a> {
775
775
}
776
776
777
777
fn lower_method_sig ( & mut self , sig : & MethodSig ) -> hir:: MethodSig {
778
+ // Check for `self: _` and `self: &_`
779
+ if let SelfKind :: Explicit ( ref ty, _) = sig. explicit_self . node {
780
+ match sig. decl . inputs . get ( 0 ) . and_then ( Arg :: to_self) . map ( |eself| eself. node ) {
781
+ Some ( SelfKind :: Value ( ..) ) | Some ( SelfKind :: Region ( ..) ) => {
782
+ self . id_assigner . diagnostic ( ) . span_err ( ty. span ,
783
+ "the type placeholder `_` is not allowed within types on item signatures" ) ;
784
+ }
785
+ _ => { }
786
+ }
787
+ }
778
788
hir:: MethodSig {
779
789
generics : self . lower_generics ( & sig. generics ) ,
780
790
abi : sig. abi ,
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ struct S ;
12
+
13
+ impl S {
14
+ fn f ( self : _ ) { } //~ERROR the type placeholder `_` is not allowed within types on item sig
15
+ fn g ( self : & _ ) { } //~ERROR the type placeholder `_` is not allowed within types on item sig
16
+ }
17
+
18
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments