-
Notifications
You must be signed in to change notification settings - Fork 13k
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
GenericPath dirname and dirname_str should be removed #10035
Comments
|
There's a general problem of balancing allocation and convenience. AFAIK we're leaning towards "don't allocate if you don't have to". And maybe there's a usecase for that, but I'm not sure that usecase is in path handling. Then again, whoever does care about it is going to be really annoyed that simple path operations are allocating all over the place. |
@cmr has it spot on. I wrote the current incarnation of the Path module, and I'll readily admit that most uses of paths don't really care much about allocation, but the problem is that this is such an important module (being the fundamental representation of paths for all path-related APIs) that if it doesn't allow you to avoid allocation then it will be very problematic for the small number of people that genuinely do care about path allocation. |
This PR implements [path reform](rust-lang/rfcs#474), and motivation and details for the change can be found there. For convenience, the old path API is being kept as `old_path` for the time being. Updating after this PR is just a matter of changing imports to `old_path` (which is likely not needed, since the prelude entries still export the old path API). This initial PR does not include additional normalization or platform-specific path extensions. These will be done in follow up commits or PRs. [breaking-change] Closes rust-lang#20034 Closes rust-lang#12056 Closes rust-lang#11594 Closes rust-lang#14028 Closes rust-lang#14049 Closes rust-lang#10035
When extracting a field expression, if RA was unable to resolve the type of the field, we would previously fall back to using "var_name" as the variable name. Now, when the `Expr` being extracted matches a `FieldExpr`, we can use the `NameRef`'s ident token as a fallback option. fixes rust-lang#10035
…eld-name, r=jonas-schievink fix: Improve suggested names for extracted variables When extracting a field expression, if RA was unable to resolve the type of the field, we would previously fall back to using "var_name" as the variable name. Now, when the `Expr` being extracted matches a `FieldExpr`, we can use the `NameRef`'s ident token as a fallback option. fixes rust-lang#10035
GenericPath defines dirname which returns a byte vector (why?) instead of a path, and a dirname_str which returns a str. Returning a str seems inconsistent with not returning a str very specifically in Path and having to go through Display. Why doesn't dirname just return a Path? That would allow us to remove dir_path.
Alternatively we could keep dir_path and remove dirname and dirname_str.
This module still needs some love.
The text was updated successfully, but these errors were encountered: