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

DestructionScopeData can leak into error messages #27942

Closed
arielb1 opened this issue Aug 22, 2015 · 1 comment · Fixed by #38552
Closed

DestructionScopeData can leak into error messages #27942

arielb1 opened this issue Aug 22, 2015 · 1 comment · Fixed by #38552
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@arielb1
Copy link
Contributor

arielb1 commented Aug 22, 2015

pub trait Resources<'a> {}

pub trait Buffer<'a, R: Resources<'a>> {
    fn select(&self) -> BufferViewHandle<R>; // should be BufferViewHandle<'a, R>
}

pub struct BufferViewHandle<'a, R: 'a+Resources<'a>>(&'a R);

fn main() {}

Post-RFC1214, this gives the not-particularly-comprehensible error message

<anon>:6:5: 6:45 error: mismatched types:
 expected `Resources<'_>`,
    found `Resources<'a>`
(lifetime mismatch) [E0308]
<anon>:6     fn select(&self) -> BufferViewHandle<R>;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:6:5: 6:45 help: see the detailed explanation for E0308
note: the anonymous lifetime #1 defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }...
note: ...does not necessarily outlive the lifetime 'a as defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }
<anon>:6:5: 6:45 error: mismatched types:
 expected `Resources<'_>`,
    found `Resources<'a>`
(lifetime mismatch) [E0308]
<anon>:6     fn select(&self) -> BufferViewHandle<R>;
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:6:5: 6:45 help: see the detailed explanation for E0308
note: the lifetime 'a as defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }...
note: ...does not necessarily outlive the anonymous lifetime #1 defined on unknown free region bounded by scope DestructionScopeData { node_id: 9 }
error: aborting due to 2 previous errors

In general, debug output of compiler structs shouldn't leak into error messages (also see #13998).

@arielb1 arielb1 added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 22, 2015
@arielb1 arielb1 changed the title DestructionScopeData can leak to error messages DestructionScopeData can leak into error messages Aug 22, 2015
bors added a commit that referenced this issue Jan 4, 2017
Don't leak the compiler's internal representation of scopes in error messages.

Fixes #37884 (actually fixes #27942, which was made worse by #37412) by handling more node types.
Ideally we'd turn the unknown node type situations into ICEs and fix them as they show up in errors.
But we might want to backport this patch so I was less aggressive.
@Eh2406
Copy link
Contributor

Eh2406 commented Sep 3, 2017

There is a FIXME related to this issue,
https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L215
Now that the issue is closed can the FIXME be fix, or made more specific?

ljedrz added a commit to ljedrz/rust-1 that referenced this issue Jul 12, 2018
kennytm added a commit to kennytm/rust that referenced this issue Jul 12, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 13, 2018
bors added a commit that referenced this issue Jul 13, 2018
Rollup of 16 pull requests

Successful merges:

 - #51962 (Provide llvm-strip in llvm-tools component)
 - #52003 (Implement `Option::replace` in the core library)
 - #52156 (Update std::ascii::ASCIIExt deprecation notes)
 - #52242 (NLL: Suggest `ref mut` and `&mut self`)
 - #52244 (Don't display default generic parameters in diagnostics that compare types)
 - #52290 (Deny bare trait objects in src/librustc_save_analysis)
 - #52293 (Deny bare trait objects in librustc_typeck)
 - #52299 (Deny bare trait objects in src/libserialize)
 - #52300 (Deny bare trait objects in librustc_target and libtest)
 - #52302 (Deny bare trait objects in the rest of rust)
 - #52310 (Backport 1.27.1 release notes to master)
 - #52314 (Fix ICE when using a pointer cast as array size)
 - #52315 (Resolve FIXME(#27942))
 - #52316 (task: remove wrong comments about non-existent LocalWake trait)
 - #52322 (Update llvm-rebuild-trigger in light of LLVM 7 upgrade)
 - #52332 (dead-code lint: say "constructed", "called" for structs, functions)

Failed merges:

r? @ghost
kennytm added a commit to kennytm/rust that referenced this issue Jul 13, 2018
bors added a commit that referenced this issue Jul 13, 2018
Rollup of 17 pull requests

Successful merges:

 - #51962 (Provide llvm-strip in llvm-tools component)
 - #52003 (Implement `Option::replace` in the core library)
 - #52156 (Update std::ascii::ASCIIExt deprecation notes)
 - #52280 (llvm-tools-preview: fix build-manifest)
 - #52290 (Deny bare trait objects in src/librustc_save_analysis)
 - #52293 (Deny bare trait objects in librustc_typeck)
 - #52299 (Deny bare trait objects in src/libserialize)
 - #52300 (Deny bare trait objects in librustc_target and libtest)
 - #52302 (Deny bare trait objects in the rest of rust)
 - #52310 (Backport 1.27.1 release notes to master)
 - #52315 (Resolve FIXME(#27942))
 - #52316 (task: remove wrong comments about non-existent LocalWake trait)
 - #52322 (Update llvm-rebuild-trigger in light of LLVM 7 upgrade)
 - #52330 (Don't silently ignore invalid data in target spec)
 - #52333 (CI: Enable core dump on Linux, and print their stack trace on segfault. )
 - #52346 (Fix typo in improper_ctypes suggestion)
 - #52350 (Bump bootstrap compiler to 1.28.0-beta.10)

Failed merges:

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants