-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Received "note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on unknown free region bounded by scope CodeExtent(9898/CallSiteScope { fn_id: NodeId(4519), body_id: NodeId(18425) })..." #37884
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
Comments
This seems to be more common than I first thought: Made pub fn accept_cmd(tcp_ctx: &'static Arc<RwLock<TCP>>, dl_ctx: &Arc<RwLock<DataLink>>, port: u16) { resulted in: error[E0491]: in type `&'static std::sync::Arc<std::sync::RwLock<tcp::TCP<'_>>>`, reference has a longer lifetime than the data it references
--> src/main.rs:106:1
|
106 | pub fn accept_cmd(tcp_ctx: &'static Arc<RwLock<TCP>>, dl_ctx: &Arc<RwLock<DataLink>>, port: u16) {
| ^
|
= note: the pointer is valid for the static lifetime
= note: but the referenced data is only valid for the anonymous lifetime #1 defined on unknown free region bounded by scope CodeExtent(9898/CallSiteScope { fn_id: NodeId(4519), body_id: NodeId(18427) }) |
Issue exists in latest nightly as well.
|
Can confirm experiencing it. Smaller sample: struct RepeatMut<'a, T>(T, &'a ());
impl<'a, T: 'a> Iterator for RepeatMut<'a, T> {
type Item = &'a mut T;
fn next(&'a mut self) -> Option<Self::Item> {
Some(&mut self.0)
}
} Not an issue in current stable or beta, which reports
rather than
|
Does this qualify as a regression? @rust-lang/core @rust-lang/compiler @rust-lang/lang |
Yes, though not the kind we'd do a point release for, IMO |
should mark as such then :) |
Here's another small one: pub struct Foo<'a>(&'a i32);
pub trait Bar {
fn bar(n: &i32) -> Self;
}
impl<'a> Bar for Foo<'a> {
fn bar(n: &'a i32) -> Foo<'a> {
Foo(n)
}
}
|
It took me a minute to figure out that this issue is about the error message & not the error. I've also been getting CallSiteScope and so on nonsense in my error output recently. This seems like a pretty serious regression in the usability of our error messages! My impression has been that this impacts just about every lifetime issue I've been getting recently, but I could be wrong. Could we get this fixed by next stable release? I disagree with @nrc that this isn't worth making a point release for (currently its only in nightly, so that's not an issue). |
Nominated for consideration by the compiler team. |
This appears to be in beta (testing on the playground). Super tiny repro: fn test(mut a: &i32, b: &i32) {
a = b;
}
fn main() {} gives
|
triage: P-high We have a fix though =) |
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.
Receiving info about MIR or some other intermediate form in a user error report.
I tried this code which most likely has some lifetime issue that I am yet to resolve:
I should have received information about the scope defined by some part of my code or if the issue is with auto-generated code then possibly no information about an internal scope.
Instead, this happened:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: