File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed 
compiler/rustc_passes/src 
tests/ui/unstable-feature-bound Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -2294,7 +2294,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
22942294        match  target { 
22952295            // FIXME(staged_api): There's no reason we can't support more targets here. We're just 
22962296            // being conservative to begin with. 
2297-             Target :: Fn  | Target :: Impl  {  .. }  => { } 
2297+             Target :: Fn  | Target :: Impl  {  .. }  |  Target :: Trait   => { } 
22982298            Target :: ExternCrate 
22992299            | Target :: Use 
23002300            | Target :: Static 
@@ -2309,7 +2309,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
23092309            | Target :: Struct 
23102310            | Target :: Field 
23112311            | Target :: Union 
2312-             | Target :: Trait 
23132312            | Target :: TraitAlias 
23142313            | Target :: Expression 
23152314            | Target :: Statement 
Original file line number Diff line number Diff line change 1+ error: unstable feature `foo` is used without being enabled.
2+   --> $DIR/unstable_feature_bound_on_trait.rs:28:5
3+    |
4+ LL |     Foo::bar();
5+    |     ^^^^^^^^^^
6+    |
7+    = help: The feature can be enabled by marking the current item with `#[unstable_feature_bound(foo)]`
8+ note: required by a bound in `Bar::bar`
9+   --> $DIR/unstable_feature_bound_on_trait.rs:16:1
10+    |
11+ LL | #[unstable_feature_bound(foo)]
12+    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Bar::bar`
13+ ...
14+ LL |     fn bar() {}
15+    |        --- required by a bound in this associated function
16+ 
17+ error: aborting due to 1 previous error
18+ 
Original file line number Diff line number Diff line change 1+ //@ revisions: pass fail 
2+ //@[pass] check-pass 
3+ 
4+ #![ allow( internal_features) ]  
5+ #![ feature( staged_api) ]  
6+ #![ stable( feature = "a" ,  since = "1.1.1"  ) ]  
7+ 
8+ /// Test the behaviour of marking a trait with #[unstable_feature_bound]. 
9+ /// In this testcase, even though the trait method `bar` and the `struct Foo` are 
10+ /// both stable, #[unstable_feature_bound] is still needed at the call site of Foo::bar(). 
11+ 
12+ #[ stable( feature = "a" ,  since = "1.1.1"  ) ]  
13+ struct  Foo ; 
14+ 
15+ #[ unstable( feature = "foo" ,  issue = "none"  ) ]  
16+ #[ unstable_feature_bound( foo) ]  
17+ trait  Bar  { 
18+     #[ stable( feature = "a" ,  since = "1.1.1"  ) ]  
19+     fn  bar ( )  { } 
20+ } 
21+ 
22+ #[ unstable_feature_bound( foo) ]  
23+ impl  Bar  for  Foo  { 
24+ } 
25+ 
26+ #[ cfg_attr( pass,  unstable_feature_bound( foo) ) ]  
27+ fn  moo ( )  { 
28+     Foo :: bar ( ) ; 
29+     //[fail]~^ ERROR: unstable feature `foo` is used without being enabled. 
30+ } 
31+ 
32+ 
33+ fn  main ( )  { } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments