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

Improve error message for an escaping closure #24242

Merged
merged 4 commits into from
Apr 11, 2015

Conversation

nikomatsakis
Copy link
Contributor

Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions "in situ" and does some (minor) cleanups to CodeMap.

r? @brson

@brson
Copy link
Contributor

brson commented Apr 9, 2015

Sweet error message. @bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 9, 2015

📌 Commit c4f7dcd has been approved by brson

@nikomatsakis nikomatsakis force-pushed the escaping-closure-error-message branch from c4f7dcd to af593f9 Compare April 9, 2015 19:51
@nikomatsakis
Copy link
Contributor Author

@bors r=brson rollup af59ef9

@bors
Copy link
Contributor

bors commented Apr 9, 2015

📌 Commit af593f9 has been approved by brson

@nikomatsakis
Copy link
Contributor Author

@bors r-

I forgot the test!

"highlight end" and instead add a variant to `RenderSpan`
columns within a line, not just the line numbers. Also try to clarify
and use the term `line_index` when 0-based.
of text (perhaps obtained by span_snippet) and then splice that edited
form back into the original file in the form of a suggestion.
from the current fn. Employ the new `span_suggestion` to show how you
can use `move`.
@nikomatsakis nikomatsakis force-pushed the escaping-closure-error-message branch 2 times, most recently from 1ac7926 to e313b33 Compare April 10, 2015 10:11
@nikomatsakis
Copy link
Contributor Author

@bors r=brson e313b33

added some tests, fixed an off-by-one bug (and added a unit test for that).

Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 10, 2015
…-message, r=brson

 Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions \"in situ\" and does some (minor) cleanups to `CodeMap`.

r? @brson
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 10, 2015
…-message, r=brson

Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions "in situ" and does some (minor) cleanups to `CodeMap`.

r? @brson
bors added a commit that referenced this pull request Apr 10, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 10, 2015
…-message, r=brson

Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions "in situ" and does some (minor) cleanups to `CodeMap`.

r? @brson
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 10, 2015
…-message, r=brson

Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions "in situ" and does some (minor) cleanups to `CodeMap`.

r? @brson
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 10, 2015
…-message, r=brson

Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions "in situ" and does some (minor) cleanups to `CodeMap`.

r? @brson
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 10, 2015
…-message, r=brson

Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions "in situ" and does some (minor) cleanups to `CodeMap`.

r? @brson
Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 11, 2015
…-message, r=brson

 Example showing sample inputs, old message, new message:

https://gist.github.com/nikomatsakis/11126784ac678b7eb6ba

Also adds infrastructure for reporting suggestions \"in situ\" and does some (minor) cleanups to `CodeMap`.

r? @brson
@bors bors merged commit e313b33 into rust-lang:master Apr 11, 2015
ftxqxd added a commit to ftxqxd/rust that referenced this pull request Apr 22, 2015
PR rust-lang#24242 added the ability to the compiler to directly give suggestions about
how to modify code to fix an error. The new errors look like this:

    foobar.rs:5:12: 5:25 error: expected a path on the left-hand side of `+`,
                                not `&'static Copy` [E0178]
    foobar.rs:5     let x: &'static Copy + 'static;
                           ^~~~~~~~~~~~~
    foobar.rs:5:12: 5:35 help: try adding parentheses (per RFC 438):
    foobar.rs:      let x: &'static (Copy + 'static);

    foobar.rs:2:13: 2:23 error: cast to unsized type: `&_` as `core::marker::Copy`
    foobar.rs:2     let x = &1 as Copy;
                            ^~~~~~~~~~
    foobar.rs:2:19: 2:23 help: try casting to a reference instead:
    foobar.rs:      let x = &1 as &Copy;

    foobar.rs:7:24: 7:25 error: expected expression, found `;`
    foobar.rs:7     let x = box (1 + 1);
                                       ^
    foobar.rs:7:13: 7:16 help: try using `box()` instead:
    foobar.rs:      let x = box() (1 + 1);

This also modifies compiletest to give the ability to directly test suggestions
given by error messages.
bors added a commit that referenced this pull request Apr 23, 2015
This PR uses the inline error suggestions introduced in #24242 to modify a few existing `help` messages. The new errors look like this:

    foobar.rs:5:12: 5:25 error: expected a path on the left-hand side of `+`,
                                not `&'static Copy` [E0178]
    foobar.rs:5     let x: &'static Copy + 'static;
                           ^~~~~~~~~~~~~
    foobar.rs:5:12: 5:35 help: try adding parentheses (per RFC 438):
    foobar.rs:      let x: &'static (Copy + 'static);


    foobar.rs:2:13: 2:23 error: cast to unsized type: `&_` as `core::marker::Copy`
    foobar.rs:2     let x = &1 as Copy;
                            ^~~~~~~~~~
    foobar.rs:2:19: 2:23 help: try casting to a reference instead:
    foobar.rs:      let x = &1 as &Copy;


    foobar.rs:7:24: 7:25 error: expected expression, found `;`
    foobar.rs:7     let x = box (1 + 1);
                                       ^
    foobar.rs:7:13: 7:16 help: try using `box()` instead:
    foobar.rs:      let x = box() (1 + 1);

This also modifies compiletest to give the ability to directly test suggestions given by error messages.
@nikomatsakis nikomatsakis deleted the escaping-closure-error-message branch March 30, 2016 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants