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 typo suggestion hueristics #26087

Merged
merged 1 commit into from Jun 8, 2015

Conversation

Projects
None yet
8 participants
@fitzgen
Member

fitzgen commented Jun 8, 2015

This makes the maximum edit distance of typo suggestions a function of the typo'd name's length. FWIW, clang uses this same hueristic, and I've found their suggestions to be better than rustc's. Without something like this, you end up with suggestions that aren't related at all when there are short variable names.

See also #20028 (comment)

@rust-highfive

This comment has been minimized.

Show comment
Hide comment
@rust-highfive

rust-highfive Jun 8, 2015

Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Collaborator

rust-highfive commented Jun 8, 2015

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@Aatch

This comment has been minimized.

Show comment
Hide comment
@Aatch

Aatch Jun 8, 2015

Contributor

@bors r+

Contributor

Aatch commented Jun 8, 2015

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jun 8, 2015

Contributor

📌 Commit 93d01eb has been approved by Aatch

Contributor

bors commented Jun 8, 2015

📌 Commit 93d01eb has been approved by Aatch

bors added a commit that referenced this pull request Jun 8, 2015

Auto merge of #26087 - fitzgen:improve-suggestion-hueristics, r=Aatch
This makes the maximum edit distance of typo suggestions a function of the typo'd name's length. FWIW, clang uses this same hueristic, and I've found their suggestions to be better than rustc's. Without something like this, you end up with suggestions that aren't related at all when there are short variable names.

See also #20028 (comment)
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Jun 8, 2015

Contributor

⌛️ Testing commit 93d01eb with merge dcc59c0...

Contributor

bors commented Jun 8, 2015

⌛️ Testing commit 93d01eb with merge dcc59c0...

@bors bors merged commit 93d01eb into rust-lang:master Jun 8, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@brson brson added the relnotes label Jun 16, 2015

// As a loose rule to avoid obviously incorrect suggestions, clamp the
// maximum edit distance we will accept for a suggestion to one third of
// the typo'd name's length.
let max_distance = std::cmp::max(name.len(), 3) / 3;

This comment has been minimized.

@neil-lobracco

neil-lobracco Jun 17, 2015

Because we're dividing the max(name.len(),3) by 3, isn't the max_distance always 1 now? It seems like we'd want this to be let max_distance = std::cmp::max(name.len() / 3, 3);, instead.

@neil-lobracco

neil-lobracco Jun 17, 2015

Because we're dividing the max(name.len(),3) by 3, isn't the max_distance always 1 now? It seems like we'd want this to be let max_distance = std::cmp::max(name.len() / 3, 3);, instead.

This comment has been minimized.

@niconii

niconii Aug 6, 2015

Member

Nah, if it were min instead of max, it would be, but for example, if name.len() was 9, max(9,3) is 9, so max_distance would be 9 / 3 or 3.

@niconii

niconii Aug 6, 2015

Member

Nah, if it were min instead of max, it would be, but for example, if name.len() was 9, max(9,3) is 9, so max_distance would be 9 / 3 or 3.

@@ -3357,7 +3357,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
NoSuggestion => {
// limit search to 5 to reduce the number

This comment has been minimized.

@neil-lobracco

neil-lobracco Jun 17, 2015

This comment should probably be updated.

@neil-lobracco

neil-lobracco Jun 17, 2015

This comment should probably be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment