Skip to content

Conversation

@ArifRoktim
Copy link
Contributor

@ArifRoktim ArifRoktim commented Oct 24, 2020

This closes #6343 and closes #6345.

The old algorithm which used a DetectedCase enum, didn't match how rustc thinks of cases. Some inputs can be interpreted as more than 1 case depending on the situation. For example, to rustc:

  • ABCD: Can be both camel case and upper snake case
  • X86_64: Can be both camel case and upper snake case

I could've made detect_case return a collection of DetectedCase and then modified the other code as such, but I think using the same code rustc uses is simpler and a surefire way to achieve the same diagnostics as rustc.

@popzxc
Copy link
Contributor

popzxc commented Oct 25, 2020

LGTM, thanks! I think I should have looked at the rustc implementation in the first place.

@ArifRoktim
Copy link
Contributor Author

ArifRoktim commented Oct 25, 2020

I'm a little worried about copyright. I've left comments stating what code has been copied from rustc, but I didn't include the contents of either rust/LICENSE-MIT or rust/LICENSE-APACHE. It most likely wouldn't come back to bite us.
Maybe I should create /AUTHORS with the following contents? (I'm no lawyer though.) Inspiration from here

The following third party packages are included, and carry
their own copyright notices and license terms:

* rust-lang/rust

    Permission is hereby granted, free of charge, to any
    person obtaining a copy of this software and associated
    documentation files (the "Software"), to deal in the
    Software without restriction, including without
    limitation the rights to use, copy, modify, merge,
    publish, distribute, sublicense, and/or sell copies of
    the Software, and to permit persons to whom the Software
    is furnished to do so, subject to the following
    conditions:

    The above copyright notice and this permission notice
    shall be included in all copies or substantial portions
    of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
    ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
    TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
    PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
    SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
    IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.

I've also heard we copy rustc for proc-macro support, so if that's applicable, this should make us square on that front too.

@popzxc
Copy link
Contributor

popzxc commented Oct 25, 2020

As long as rust-analyzer is also MIT/Apache, and changing the license of an open-source project is quite hard and unlikely, I believe there is no problem with copying some code when it makes sense.

@ArifRoktim
Copy link
Contributor Author

Alright, cool.

@matklad
Copy link
Contributor

matklad commented Oct 26, 2020

bors r=popzxc

Thanks @ArifRoktim and @popzxc !

@bors
Copy link
Contributor

bors bot commented Oct 26, 2020

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.

False IncorrectCase diagnostic duplicated info

4 participants