- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Do not suggest "is a function" for free variables #93996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            bors
  merged 1 commit into
  rust-lang:master
from
notriddle:notriddle/magically-becomes-a-function
  
      
      
   
  Feb 17, 2022 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            22 changes: 22 additions & 0 deletions
          
          22 
        
  src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| struct Struct<T>(T); | ||
| impl Struct<T> | ||
| //~^ ERROR cannot find type `T` in this scope | ||
| //~| NOTE not found in this scope | ||
| //~| HELP you might be missing a type parameter | ||
| where | ||
| T: Copy, | ||
| //~^ ERROR cannot find type `T` in this scope | ||
| //~| NOTE not found in this scope | ||
| { | ||
| // The part where it claims that there is no method named `len` is a bug. Feel free to fix it. | ||
| // This test is intended to ensure that a different bug, where it claimed | ||
| // that `v` was a function, does not regress. | ||
| fn method(v: Vec<u8>) { v.len(); } | ||
| //~^ ERROR type annotations needed | ||
| //~| NOTE cannot infer type | ||
| //~| NOTE type must be known at this point | ||
| //~| ERROR no method named `len` | ||
| //~| NOTE private field, not a method | ||
| } | ||
| 
     | 
||
| fn main() {} | 
        
          
          
            32 changes: 32 additions & 0 deletions
          
          32 
        
  src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| error[E0412]: cannot find type `T` in this scope | ||
| --> $DIR/fn-help-with-err-generic-is-not-function.rs:2:13 | ||
| | | ||
| LL | impl Struct<T> | ||
| | - ^ not found in this scope | ||
| | | | ||
| | help: you might be missing a type parameter: `<T>` | ||
| 
     | 
||
| error[E0412]: cannot find type `T` in this scope | ||
| --> $DIR/fn-help-with-err-generic-is-not-function.rs:7:5 | ||
| | | ||
| LL | T: Copy, | ||
| | ^ not found in this scope | ||
| 
     | 
||
| error[E0282]: type annotations needed | ||
| --> $DIR/fn-help-with-err-generic-is-not-function.rs:14:31 | ||
| | | ||
| LL | fn method(v: Vec<u8>) { v.len(); } | ||
| | ^^^ cannot infer type | ||
| | | ||
| = note: type must be known at this point | ||
| 
     | 
||
| error[E0599]: no method named `len` found for struct `Vec<u8>` in the current scope | ||
| --> $DIR/fn-help-with-err-generic-is-not-function.rs:14:31 | ||
| | | ||
| LL | fn method(v: Vec<u8>) { v.len(); } | ||
| | ^^^ private field, not a method | ||
| 
     | 
||
| error: aborting due to 4 previous errors | ||
| 
     | 
||
| Some errors have detailed explanations: E0282, E0412, E0599. | ||
| For more information about an error, try `rustc --explain E0282`. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // This test case checks the behavior of typeck::check::method::suggest::is_fn on Ty::Error. | ||
| fn main() { | ||
| let arc = std::sync::Arc::new(oops); | ||
| //~^ ERROR cannot find value `oops` in this scope | ||
| //~| NOTE not found | ||
| // The error "note: `arc` is a function, perhaps you wish to call it" MUST NOT appear. | ||
| arc.blablabla(); | ||
| //~^ ERROR no method named `blablabla` | ||
| //~| NOTE method not found | ||
| let arc2 = std::sync::Arc::new(|| 1); | ||
| // The error "note: `arc2` is a function, perhaps you wish to call it" SHOULD appear | ||
| arc2.blablabla(); | ||
| //~^ ERROR no method named `blablabla` | ||
| //~| NOTE method not found | ||
| //~| NOTE `arc2` is a function, perhaps you wish to call it | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| error[E0425]: cannot find value `oops` in this scope | ||
| --> $DIR/fn-help-with-err.rs:3:35 | ||
| | | ||
| LL | let arc = std::sync::Arc::new(oops); | ||
| | ^^^^ not found in this scope | ||
| 
     | 
||
| error[E0599]: no method named `blablabla` found for struct `Arc<_>` in the current scope | ||
| --> $DIR/fn-help-with-err.rs:7:9 | ||
| | | ||
| LL | arc.blablabla(); | ||
| | ^^^^^^^^^ method not found in `Arc<_>` | ||
| 
     | 
||
| error[E0599]: no method named `blablabla` found for struct `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:40]>` in the current scope | ||
| --> $DIR/fn-help-with-err.rs:12:10 | ||
| | | ||
| LL | arc2.blablabla(); | ||
| | ^^^^^^^^^ method not found in `Arc<[closure@$DIR/fn-help-with-err.rs:10:36: 10:40]>` | ||
| | | ||
| = note: `arc2` is a function, perhaps you wish to call it | ||
| 
     | 
||
| error: aborting due to 3 previous errors | ||
| 
     | 
||
| Some errors have detailed explanations: E0425, E0599. | ||
| For more information about an error, try `rustc --explain E0425`. | 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.