Skip to content
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

detect wrong number of args when type-checking a closure #48123

Merged
merged 2 commits into from
Feb 24, 2018

Conversation

nikomatsakis
Copy link
Contributor

Instead of creating inference variables for those argument types, use
the trait error-reporting code to give a nicer error. This also
improves some other spans for existing tests.

Fixes #47244

r? @estebank

@nikomatsakis
Copy link
Contributor Author

I should add: I'm not terribly happy with how the error reporting code is organized. It feels rather haphazard. I think we should think about exacting the code in traits/error_reporting and infer/error_reporting to a common error_reporting module, since it often happens that we detect the same conceptual error in different ways and we need to invoke methods in common.

@bors
Copy link
Contributor

bors commented Feb 10, 2018

☔ The latest upstream changes (presumably #48113) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 10, 2018
@estebank
Copy link
Contributor

r=me after fixing rebasing and making travis happy. Don't think that having no output for issue-47706-trait is valid.

[01:00:25] failures:
[01:00:25] 
[01:00:25] ---- [ui] ui/issue-47706-trait.rs stdout ----
[01:00:25] 	diff of stderr:
[01:00:25] 
[01:00:25] 1	error[E0601]: main function not found
[01:00:25] 2	
[01:00:25] -	error[E0593]: function is expected to take a single 0-tuple as argument, but it takes 2 distinct arguments
[01:00:25] -	  --> $DIR/issue-47706-trait.rs:13:20
[01:00:25] -	   |
[01:00:25] -	12 |     fn f(&self, _: ()) {
[01:00:25] -	   |     ------------------ takes 2 distinct arguments
[01:00:25] -	13 |         None::<()>.map(Self::f);
[01:00:25] -	   |                    ^^^ expected function that takes a single 0-tuple as argument
[01:00:25] -	
[01:00:25] -	error: aborting due to 2 previous errors
[01:00:25] -	
[01:00:25] 13	
[01:00:25] 
[01:00:25] 
[01:00:25] The actual stderr differed from the expected stderr.
[01:00:25] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-47706-trait.stderr
[01:00:25] To update references, run this command from build directory:
[01:00:25] /checkout/src/test/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui' 'issue-47706-trait.rs'
[01:00:25] 
[01:00:25] error: 1 errors occurred comparing output.
[01:00:25] status: exit code: 101
[01:00:25] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issue-47706-trait.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-47706-trait.stage2-x86_64-unknown-linux-gnu" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issue-47706-trait.stage2-x86_64-unknown-linux-gnu.aux" "-A" "unused"
[01:00:25] stdout:
[01:00:25] ------------------------------------------
[01:00:25] 
[01:00:25] ------------------------------------------
[01:00:25] stderr:
[01:00:25] ------------------------------------------
[01:00:25] {"message":"main function not found","code":{"code":"E0601","explanation":"\nNo `main` function was found in a binary crate. To fix this error, add a\n`main` function. For example:\n\n```\nfn main() {\n    // Your program will start here.\n    println!(\"Hello world!\");\n}\n```\n\nIf you don't know the basics of Rust, you can go look to the Rust Book to get\nstarted: https://doc.rust-lang.org/book/\n"},"level":"error","spans":[],"children":[],"rendered":"error[E0601]: main function not found\n\n"}
[01:00:25] thread 'rustc' panicked at 'non-FnLike node found: NodeTraitItem(TraitItem { id: NodeId(6), name: f, hir_id: HirId { owner: DefIndex(0:4), local_id: ItemLocalId(0) }, attrs: [], generics: Generics { params: [], where_clause: WhereClause { id: NodeId(7), predicates: [] }, span: /checkout/src/test/ui/issue-47706-trait.rs:1:1: 1:1 }, node: Method(MethodSig { unsafety: Normal, constness: NotConst, abi: Rust, decl: FnDecl { inputs: [type(&Self), type(())], output: DefaultReturn(/checkout/src/test/ui/issue-47706-trait.rs:12:24: 12:24), variadic: false, has_implicit_self: true } }, Provided(BodyId { node_id: NodeId(22) })), span: /checkout/src/test/ui/issue-47706-trait.rs:12:5: 14:6 })', librustc/traits/error_reporting.rs:870:18
[01:00:25] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:00:25] 
[01:00:25] error: internal compiler error: unexpected panic
[01:00:25] 
[01:00:25] note: the compiler unexpectedly panicked. this is a bug.
[01:00:25] 
[01:00:25] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[01:00:25] 
[01:00:25] note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu
[01:00:25] 
[01:00:25] 
[01:00:25] ------------------------------------------
[01:00:25] 
[01:00:25] thread '[ui] ui/issue-47706-trait.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:2883:9
[01:00:25] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:00:25] 
[01:00:25] 
[01:00:25] failures:
[01:00:25]     [ui] ui/issue-47706-trait.rs
[01:00:25] 
[01:00:25] test result: FAILED. 985 passed; 1 failed; 4 ignored; 0 measured; 0 filtered out

Instead of creating inference variables for those argument types, use
the trait error-reporting code to give a nicer error.
@nikomatsakis
Copy link
Contributor Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Feb 13, 2018

📌 Commit cc05561 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 13, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Feb 16, 2018
…um-args, r=estebank

detect wrong number of args when type-checking a closure

Instead of creating inference variables for those argument types, use
the trait error-reporting code to give a nicer error. This also
improves some other spans for existing tests.

Fixes rust-lang#47244

r? @estebank
Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 19, 2018
…um-args, r=estebank

detect wrong number of args when type-checking a closure

Instead of creating inference variables for those argument types, use
the trait error-reporting code to give a nicer error. This also
improves some other spans for existing tests.

Fixes rust-lang#47244

r? @estebank
Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 20, 2018
bors added a commit that referenced this pull request Feb 20, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 23, 2018
…um-args, r=estebank

detect wrong number of args when type-checking a closure

Instead of creating inference variables for those argument types, use
the trait error-reporting code to give a nicer error. This also
improves some other spans for existing tests.

Fixes rust-lang#47244

r? @estebank
bors added a commit that referenced this pull request Feb 23, 2018
Rollup of 12 pull requests

- Successful merges: #47933, #48072, #48083, #48123, #48157, #48219, #48221, #48245, #48429, #48436, #48438, #48472
- Failed merges:
bors added a commit that referenced this pull request Feb 24, 2018
Rollup of 12 pull requests

- Successful merges: #47933, #48072, #48083, #48123, #48157, #48219, #48221, #48245, #48429, #48436, #48438, #48472
- Failed merges:
@bors bors merged commit cc05561 into rust-lang:master Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants