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

Avoid ICE when include! is used by stdin crate #65603

Merged
merged 1 commit into from Oct 21, 2019

Conversation

@mystor
Copy link
Contributor

mystor commented Oct 19, 2019

This should hopefully also eliminate the ICE when using include_bytes!, include_str! and #[doc(include = "...")] with a stdio input.

I couldn't see a clear way to write a compile-fail test using compiletest with a stdio input, so I haven't written any tests for this change.

Fixes #63900

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 19, 2019

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -1072,7 +1072,8 @@ impl<'a> ExtCtxt<'a> {
/// This unifies the logic used for resolving `include_X!`, and `#[doc(include)]` file paths.
///
/// Returns an absolute path to the file that `path` refers to.
pub fn resolve_path(&self, path: impl Into<PathBuf>, span: Span) -> PathBuf {
pub fn resolve_path(&self, path: impl Into<PathBuf>, span: Span)
-> Result<PathBuf, DiagnosticBuilder<'a>> {

This comment has been minimized.

Copy link
@Centril

Centril Oct 19, 2019

Member

Please use the same formatting as the method below.

This comment has been minimized.

Copy link
@mystor

mystor Oct 19, 2019

Author Contributor

OK. Wasn't sure what style to use, so copied from this method:

pub fn expr_to_string(cx: &mut ExtCtxt<'_>, expr: P<ast::Expr>, err_msg: &str)
-> Option<(Symbol, ast::StrStyle)> {

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 19, 2019

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Oct 19, 2019

The job mingw-check of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-10-19T17:28:19.4295857Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-10-19T17:28:19.4482915Z ##[command]git config gc.auto 0
2019-10-19T17:28:19.4558003Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-10-19T17:28:19.4637829Z ##[command]git config --get-all http.proxy
2019-10-19T17:28:19.4779538Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/65603/merge:refs/remotes/pull/65603/merge
---
2019-10-19T17:36:01.5471795Z     Checking syntax_expand v0.0.0 (/checkout/src/libsyntax_expand)
2019-10-19T17:36:01.7972598Z error[E0425]: cannot find value `cx` in this scope
2019-10-19T17:36:01.7973921Z     --> src/libsyntax_expand/expand.rs:1421:42
2019-10-19T17:36:01.7974316Z      |
2019-10-19T17:36:01.7975061Z 1421 |                     let filename = match cx.resolve_path(file, sp) {
2019-10-19T17:36:01.7975670Z      |                                          ^^ help: you might have meant to use the available field: `self.cx`
2019-10-19T17:36:01.7984107Z error[E0425]: cannot find value `sp` in this scope
2019-10-19T17:36:01.7985247Z     --> src/libsyntax_expand/expand.rs:1421:64
2019-10-19T17:36:01.7985867Z      |
2019-10-19T17:36:01.7985867Z      |
2019-10-19T17:36:01.7986480Z 1421 |                     let filename = match cx.resolve_path(file, sp) {
2019-10-19T17:36:01.7990566Z 
2019-10-19T17:36:02.6762754Z error: aborting due to 2 previous errors
2019-10-19T17:36:02.6762859Z 
2019-10-19T17:36:02.6763200Z For more information about this error, try `rustc --explain E0425`.
---
2019-10-19T17:36:02.7110771Z   local time: Sat Oct 19 17:36:02 UTC 2019
2019-10-19T17:36:02.8608549Z   network time: Sat, 19 Oct 2019 17:36:02 GMT
2019-10-19T17:36:02.8608890Z == end clock drift check ==
2019-10-19T17:36:04.1394511Z 
2019-10-19T17:36:04.1499185Z ##[error]Bash exited with code '1'.
2019-10-19T17:36:04.1531087Z ##[section]Starting: Checkout
2019-10-19T17:36:04.1532702Z ==============================================================================
2019-10-19T17:36:04.1532750Z Task         : Get sources
2019-10-19T17:36:04.1532810Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@mystor mystor force-pushed the mystor:resolve_path_ice branch from a2aee5f to 0b97ef8 Oct 19, 2019
This should also eliminate the ICE when using `include_bytes!`, `include_str!`
and `#[doc(include = "...")]`.

Fixes #63900
@mystor mystor force-pushed the mystor:resolve_path_ice branch from 0b97ef8 to 9be0bd8 Oct 19, 2019
@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Oct 20, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 20, 2019

📌 Commit 9be0bd8 has been approved by petrochenkov

Centril added a commit to Centril/rust that referenced this pull request Oct 20, 2019
…nkov

Avoid ICE when include! is used by stdin crate

This should hopefully also eliminate the ICE when using `include_bytes!`, `include_str!` and `#[doc(include = "...")]` with a stdio input.

I couldn't see a clear way to write a compile-fail test using compiletest with a stdio input, so I haven't written any tests for this change.

Fixes rust-lang#63900
bors added a commit that referenced this pull request Oct 20, 2019
Rollup of 8 pull requests

Successful merges:

 - #65314 (rustdoc: forward -Z options to rustc)
 - #65592 (clarify const_prop ICE protection comment)
 - #65603 (Avoid ICE when include! is used by stdin crate)
 - #65614 (Improve error message for APIT with explicit generic arguments)
 - #65629 (Remove `borrowck_graphviz_postflow` from test)
 - #65633 (Remove leading :: from paths in doc examples)
 - #65638 (Rename the default argument 'def' to 'default')
 - #65639 (Fix parameter name in documentation)

Failed merges:

r? @ghost
@bors bors merged commit 9be0bd8 into rust-lang:master Oct 21, 2019
4 checks passed
4 checks passed
pr Build #20191019.63 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.