Skip to content

Use trait to abstract emit modes #3616

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

Merged
merged 18 commits into from
Jun 12, 2019
Merged

Use trait to abstract emit modes #3616

merged 18 commits into from
Jun 12, 2019

Conversation

bash
Copy link

@bash bash commented Jun 10, 2019

No description provided.

@bash bash marked this pull request as ready for review June 12, 2019 05:08
@bash bash changed the title Use trait to abstract different emit modes Use trait to abstract emit modes Jun 12, 2019
Copy link
Contributor

@topecongiro topecongiro left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, this looks great.

src/lib.rs Outdated
@@ -469,10 +474,23 @@ impl<'b, T: Write + 'b> Session<'b, T> {
}
}

pub(crate) fn create_emitter<'a>(config: &Config) -> Box<dyn Emitter + 'a> {
match config.emit_mode() {
EmitMode::Files if config.make_backup() => Box::new(emitter::FilesWithBackupEmitter::new()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to use default() over an empty constructor.

Copy link
Author

@bash bash Jun 12, 2019

Choose a reason for hiding this comment

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

Addressed in dc1a440.

src/test/mod.rs Outdated
#[cfg(windows)]
assert_eq!(buf, "fn main() {}\r\n".as_bytes());
assert_eq!(buf, "stdin:\n\r\nfn main() {}\r\n".as_bytes());
Copy link
Contributor

Choose a reason for hiding this comment

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

writeln! only emits the line feed character [1], so the first \r is unnecessary here.

[1] https://doc.rust-lang.org/std/macro.writeln.html

Copy link
Author

Choose a reason for hiding this comment

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

That explains why the windows build was failing 😄. Thanks.

Copy link
Author

@bash bash Jun 12, 2019

Choose a reason for hiding this comment

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

Fixed in a759b83.

@topecongiro topecongiro merged commit dbac28b into rust-lang:master Jun 12, 2019
@topecongiro
Copy link
Contributor

LGTM, thank you!

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.

2 participants