Skip to content
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

Feat(compiler-base-error): reuse rustc_error 'StyledBuffer' in compiler-base. #142

Merged
merged 1 commit into from
Aug 11, 2022
Merged

Feat(compiler-base-error): reuse rustc_error 'StyledBuffer' in compiler-base. #142

merged 1 commit into from
Aug 11, 2022

Conversation

zong-zhe
Copy link
Contributor

@zong-zhe zong-zhe commented Aug 9, 2022

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

issue #115

2. What is the scope of this PR (e.g. component or file name):

compiler_base/3rdparty/rustc_errors
compiler_base/3rdparty/rustc_span

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

This is the first step for Compiler-Base-Error in issue #115.

Reuse 'styled_buffer.rs' in 'rustc_errors', and 'styled_buffer.rs' has been modified to fit the feature of 'Compiler-Base'.

  • Add method 'appendl()' and 'putl()' to 'StyledBuffer',they can adjust the line and column in the 'StyleBuffer' according to the length of the input string.

  • Replaced the 'enum Style' with 'trait Style' in 'StyledBuffer' to support extending more styles. And 'trait Style' is defined in compiler_base/3rdparty/rustc_errors/src/lib.rs.

  • Add some test cases for 'StyledBuffer'.

  • Add 'LICENSE' and 'README.md' in compiler_base/3rdparty/rustc_errors/src/ for reusing rustc source code.

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

The test case is in the 'compiler_base/lib.rs', and shows how the 'StyledBuffer' work.

6. Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@zong-zhe zong-zhe added enhancement New feature or request error-handling Issues or PRs related to kcl error handling feat labels Aug 9, 2022
@zong-zhe zong-zhe added this to the v0.4.3 Release milestone Aug 9, 2022
@zong-zhe zong-zhe requested review from chai2010, Peefy, ldxdl and a team August 9, 2022 11:58
@zong-zhe zong-zhe self-assigned this Aug 9, 2022
Peefy
Peefy previously approved these changes Aug 9, 2022
@coveralls
Copy link
Collaborator

coveralls commented Aug 9, 2022

Pull Request Test Coverage Report for Build 2832645236

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 358 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.6%) to 59.579%

Files with Coverage Reduction New Missed Lines %
kclvm/compiler/src/codegen/llvm/context.rs 358 74.15%
Totals Coverage Status
Change from base Build 2832567449: 0.6%
Covered Lines: 22391
Relevant Lines: 37582

💛 - Coveralls

kclvm/compiler_base/3rdparty/rustc_errors/src/lib.rs Outdated Show resolved Hide resolved
kclvm/compiler_base/3rdparty/rustc_errors/src/lib.rs Outdated Show resolved Hide resolved
kclvm/compiler_base/3rdparty/rustc_errors/src/README.md Outdated Show resolved Hide resolved
kclvm/compiler_base/3rdparty/rustc_errors/src/README.md Outdated Show resolved Hide resolved
kclvm/compiler_base/3rdparty/rustc_errors/src/lib.rs Outdated Show resolved Hide resolved
kclvm/compiler_base/3rdparty/rustc_errors/src/lib.rs Outdated Show resolved Hide resolved
kclvm/compiler_base/3rdparty/rustc_errors/src/lib.rs Outdated Show resolved Hide resolved
@Peefy Peefy dismissed their stale review August 9, 2022 13:38

Misread the PR number and title

@zong-zhe zong-zhe requested review from Peefy and ldxdl August 10, 2022 06:05
@ldxdl
Copy link
Contributor

ldxdl commented Aug 10, 2022

LGTM

Peefy
Peefy previously approved these changes Aug 10, 2022
Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…tions.

Reuse 'styled_buffer.rs' in 'rustc_errors', and 'styled_buffer.rs' has been modified to fit the feature of 'Compiler-Base'.
- add method 'appendl()' and 'pushs()' to 'StyledBuffer'.
- replaced the `enum Style` with generics `T: Clone + PartialEq + Eq + Style` to support extending more styles.
- add some test cases for 'StyledBuffer'.

issue #115

add comments for `putl()` and `appendl()`

add comments to trait Style

add more README

use generic to replace `dyn trait`

rename `putl` to `pushs`.
rename `appendl` to `append_last_line`.
rename `render_style` to `render_style_to_color_spec`.

fix comments mistake

rename `append_last_line` to `appendl`
Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zong-zhe zong-zhe requested a review from He1pa August 11, 2022 02:37
Copy link
Contributor

@He1pa He1pa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zong-zhe zong-zhe merged commit d918dae into kcl-lang:main Aug 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2022
@zong-zhe zong-zhe deleted the reuse-rustc-errors branch August 15, 2022 06:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request error-handling Issues or PRs related to kcl error handling feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants