-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(add): suggest similarly named features #15438
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
base: master
Are you sure you want to change the base?
Conversation
Would you be willing to restructure this to match the recommendation at https://doc.crates.io/contrib/process/working-on-cargo.html#submitting-a-pull-request to add tests in a commit before your change with them passing and then your commit with your change updates the tests so they still pass so that the diff between the commits highlights the change in behavior? |
.into_iter() | ||
.format("\n ") | ||
)?; | ||
} | ||
if deactivated.len() <= MAX_FEATURE_PRINTS { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we still display all of the features if there is a closest match for every unknown feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say yes, although this might be pretty lengthy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking around at how we do this elsewhere
- Most places do not list all options, even without a suggestion
- One place always lists out how to see all options, independent of whether there was a suggestion
- 2 places will conditionally show all options if a suggestion is not present
So there is only a small precedence but it tends to be towards not listing everything if there is a suggestion.
Thinking particularly for this case, we most likely want to focus the users attention on the suggestion. Also, since there was a concern over the number of suggestions, what there can be a lot more of is number of features. While we use columns, it can be quite large.
I lean towards only showing the suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking around at how we do this elsewhere
* Most places do not list all options, even without a suggestion * One place always lists out how to see all options, independent of whether there was a suggestion * 2 places will conditionally show all options if a suggestion is not present
So there is only a small precedence but it tends to be towards not listing everything if there is a suggestion.
Thinking particularly for this case, we most likely want to focus the users attention on the suggestion. Also, since there was a concern over the number of suggestions, what there can be a lot more of is number of features. While we use columns, it can be quite large.
I lean towards only showing the suggestion.
So, how should the output look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure what you are looking for with this question. As I said, I lean towards only showing the suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure what you are looking for with this question. As I said, I lean towards only showing the suggestion.
Sorry for the confusion, I mean: how should the suggestion look like? Just say that there N
similarly spelled features, or perhaps something else?
Also, closest_msg
appends two line breaks into the middle of the message, so maybe I should use different function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion, I mean: how should the suggestion look like? Just say that there N similarly spelled features, or perhaps something else?
Unless we have a good reason, we should be use closest_msg
. If we do have a good reason, we should mirror it. So that means we don't say there are "N similarly spelled features".
Also, closest_msg appends two line breaks into the middle of the message, so maybe I should use different function?
I commented on that at
#15438 (comment) . Other messages don't show two blank lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To double check, earlier in this thread, I asked about not showing deactivated or activated features. Unless I'm misunderstanding something, it looks like that isn't done yet.
Sure! To make tests pass before I introduce my changes, I have to leave them blank, right? |
In this case, they should still be doing adds; just there will be no suggestions given. If there are questions, the link I gave has links to example PRs. |
32330f6
to
992abc3
Compare
Alright, done |
Ohh, just noticed that |
I think we have to rollback to |
Also, how should I approach fixing other tests? Some of them fail because output of |
https://github.com/rust-lang/cargo/actions/runs/14540352012/job/40796970702#step:13:4593 Set the environment variable |
992abc3
to
1d8f58e
Compare
@rustbot ready |
<tspan x="10px" y="118px"><tspan>help: a feature with a similar name exists: `bar`</tspan> | ||
</tspan> | ||
<tspan x="10px" y="136px"> | ||
</tspan> | ||
<tspan x="10px" y="154px"> | ||
</tspan> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're showing two blank lines.
This may be an artifact of how closest_msg
expects error message newlines to be handled. Could you do a refactor before this commit so that this commit only shows one visible line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure: do you mean removing blank lines or just leaving only one blank line per suggestion?
Sorry if I'm asking too much questions 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be two blank lines between items, only one.
This is likely an outcome of other error messages not being expected to have a trailing newline, so closest_msg
adds it and then adds a blank line. But since we have a trailing newline, it makes two blank lines.
We likely need to just these messages to not have a trailing newline.
1d8f58e
to
bd5f6fe
Compare
@rustbot ready |
I know it can sometimes be a pain to clean up commits but could you
That'll be a big help for reviewing |
Sure, I'll ping you once done |
What does this PR try to resolve?
Fixes #15436
How should we test and review this PR?
There are 3 tests for each test case: