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
INSP: Add error for repr
without parentheses
#6352
Conversation
Draft because I'm not sure whether or not to add a |
@zeroeightysix I think |
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.
In general looks ok except some comments.
Since this diagnostic can be quite easily applied for different attributes, I've added some optional comments about generalization. If you desired to improve it, you may fix these comments in separate PR with supporting more attributes
src/test/kotlin/org/rust/ide/annotator/fixes/AddReprParenthesesFixTest.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/AddReprParenthesesFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/AddReprParenthesesFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/AddReprParenthesesFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/AddReprParenthesesFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/AddReprParenthesesFix.kt
Outdated
Show resolved
Hide resolved
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.
LGTM except comments
Could you also squash all "fixing" commits into main ones, please?
src/main/kotlin/org/rust/ide/annotator/fixes/AddAttrParenthesesFix.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/rust/ide/annotator/fixes/AddAttrParenthesesFix.kt
Outdated
Show resolved
Hide resolved
6a512c1
to
9857cd7
Compare
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.
Great!
Thank you!
bors r+
@zeroeightysix Would you like to extend this diagnostic for other standard attributes like |
Surely, but in another PR if it's okay with you. |
Yep, of course. |
Build succeeded: |
6398: RES: Fix exception when resolving import in cfg-disabled shadowed mod using new resolve r=vlad20012 a=dima74 Fixes exception in [new resolve](#6217) when we resolve import in shadowed mod (not accessible from `CrateDefMap` root because of some other mod with same `crateRelativePath`). We already ignore such imports if they are collected during collecting explicitly declared items. In this PR we also ignore imports added by macro expansion. <details> ``` java.lang.AssertionError: Can't find ModData for process::imp::reap in crate tokio(lib) at org.rust.lang.core.resolve2.CrateDefMap.doGetModData(CrateDefMap.kt:466) at org.rust.lang.core.resolve2.CrateDefMap.getModData(CrateDefMap.kt:75) at org.rust.lang.core.resolve2.CrateDefMap.tryCastToModData(CrateDefMap.kt:88) at org.rust.lang.core.resolve2.PathResolutionKt.resolvePathFp(PathResolution.kt:67) at org.rust.lang.core.resolve2.DefCollector.resolveImport(DefCollector.kt:108) at org.rust.lang.core.resolve2.DefCollector.resolveImports(DefCollector.kt:74) at org.rust.lang.core.resolve2.DefCollector.collect(DefCollector.kt:59) at org.rust.lang.core.resolve2.FacadeBuildDefMapKt.buildDefMap(FacadeBuildDefMap.kt:31) at org.rust.lang.core.resolve2.DefMapsBuilder.doBuildDefMap(DefMapsBuilder.kt:110) at org.rust.lang.core.resolve2.DefMapsBuilder.buildSync(DefMapsBuilder.kt:79) at org.rust.lang.core.resolve2.DefMapsBuilder.build(DefMapsBuilder.kt:54) at org.rust.lang.core.resolve2.DefMapUpdater.doRun(FacadeUpdateDefMap.kt:159) at org.rust.lang.core.resolve2.DefMapUpdater.runWithStrongReferencesToDefMapHolders(FacadeUpdateDefMap.kt:135) at org.rust.lang.core.resolve2.DefMapUpdater.access$runWithStrongReferencesToDefMapHolders(FacadeUpdateDefMap.kt:93) at org.rust.lang.core.resolve2.DefMapUpdater$run$$inlined$measureTimeMillis$lambda$1.invoke(FacadeUpdateDefMap.kt:120) at org.rust.lang.core.resolve2.DefMapUpdater$run$$inlined$measureTimeMillis$lambda$1.invoke(FacadeUpdateDefMap.kt:93) at org.rust.openapiext.UtilsKt$executeUnderProgress$1.run(utils.kt:313) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:617) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65) at org.rust.openapiext.UtilsKt.executeUnderProgress(utils.kt:313) at org.rust.lang.core.resolve2.DefMapUpdater.run(FacadeUpdateDefMap.kt:119) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt$updateDefMapForAllCrates$1$1.invoke(FacadeUpdateDefMap.kt:73) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt$updateDefMapForAllCrates$1$1.invoke(FacadeUpdateDefMap.kt) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt$sam$com_intellij_openapi_util_ThrowableComputable$0.compute(FacadeUpdateDefMap.kt) at com.intellij.openapi.progress.util.ProgressIndicatorUtils.computeWithLockAndCheckingCanceled(ProgressIndicatorUtils.java:326) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt.withLockAndCheckingCancelled(FacadeUpdateDefMap.kt:265) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt.withLockAndCheckingCancelled$default(FacadeUpdateDefMap.kt:264) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt$updateDefMapForAllCrates$1.invoke(FacadeUpdateDefMap.kt:71) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt$updateDefMapForAllCrates$1.invoke(FacadeUpdateDefMap.kt) at org.rust.openapiext.UtilsKt$runReadActionInSmartMode$1.compute(utils.kt:275) at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$0(DumbService.java:103) at com.intellij.openapi.project.DumbService.lambda$runReadActionInSmartMode$1(DumbService.java:147) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:889) at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:61) at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:140) at com.intellij.openapi.project.DumbService.runReadActionInSmartMode(DumbService.java:103) at org.rust.openapiext.UtilsKt.runReadActionInSmartMode(utils.kt:273) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt.updateDefMapForAllCrates(FacadeUpdateDefMap.kt:70) at org.rust.lang.core.resolve2.FacadeUpdateDefMapKt.updateDefMapForAllCrates$default(FacadeUpdateDefMap.kt:64) at org.rust.lang.core.macros.MacroExpansionTaskBase.run(MacroExpansionTask.kt:97) ``` </details> 6413: INSP: Detect attributes that require parentheses but have no parentheses. r=Undin a=zeroeightysix This PR builds on #6352, making the diagnostic and fix work for all attributes that 'require parentheses', e.g. are not valid as just a name (like `#[test]`). ![image](https://user-images.githubusercontent.com/27009727/99704983-694dc780-2a99-11eb-9bd1-1edb54b32a4f.png) changelog: Detect attributes that require parentheses but have no parentheses, and suggest `Add parentheses` quick-fix Co-authored-by: Dmitry Murzin <diralik@yandex.ru> Co-authored-by: Ridan Vandenbergh <ridanvandenbergh@gmail.com>
6413: INSP: Detect attributes that require parentheses but have no parentheses. r=Undin a=zeroeightysix This PR builds on #6352, making the diagnostic and fix work for all attributes that 'require parentheses', e.g. are not valid as just a name (like `#[test]`). ![image](https://user-images.githubusercontent.com/27009727/99704983-694dc780-2a99-11eb-9bd1-1edb54b32a4f.png) changelog: Detect attributes that require parentheses but have no parentheses, and suggest `Add parentheses` quick-fix Co-authored-by: Ridan Vandenbergh <ridanvandenbergh@gmail.com>
Adds a new error for when a
repr
attribute does not haveRsMetaItemArgs
(thus, no pair of parentheses)Fixes #6336
changelog: Show error if
repr
attribute doesn't have parentheses and provide quick-fix to add them