Skip to content

E0495 documentation wrongly states it is no longer emitted by the compiler #136827

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

Closed
nodakai opened this issue Feb 10, 2025 · 10 comments · Fixed by #137059
Closed

E0495 documentation wrongly states it is no longer emitted by the compiler #136827

nodakai opened this issue Feb 10, 2025 · 10 comments · Fixed by #137059
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nodakai
Copy link
Contributor

nodakai commented Feb 10, 2025

Location

https://doc.rust-lang.org/error_codes/E0495.html

Note: this error code is no longer emitted by the compiler.

Summary

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=0a915b8449387a0b5162ada85854dfa6

It is emitted by the latest stable 1.84.1 & nightly

@nodakai nodakai added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Feb 10, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 10, 2025
@workingjubilee
Copy link
Member

Nice catch!

@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-diagnostics Area: Messages for errors, warnings, and lints and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 11, 2025
@chenyukang
Copy link
Member

E0495 now is emitted at here, https://github.com/chenyukang/rust/blob/a917fd5f98913a04b839cccca43558f4e4fc831b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs#L1032-L1038

the meaning of error seems changed, we need to update the document for E0495.

@xizheyin
Copy link
Contributor

Could I help with update the doc?

@chenyukang
Copy link
Member

Could I help with update the doc?

yeah, go ahead!

@xizheyin
Copy link
Contributor

@rustbot claim

@workingjubilee
Copy link
Member

Either the doc for the error code should be updated or another error code should be used and the diagnostics with the drifted meaning should be attached to this new error. I'm not attached to either particular course of action.

progressive-galib added a commit to progressive-galib/rust that referenced this issue Feb 14, 2025
@progressive-galib
Copy link
Contributor

progressive-galib commented Feb 14, 2025

#137042 documentation update done

@progressive-galib
Copy link
Contributor

A trait implementation returns a reference without an explicit lifetime linking it to self`.

trait Tr<X> {
    fn f(&self) -> X;
}

struct Wr<'b> {
    ri: &'b i32,
    f: f32,
}

impl<'b> Tr<&f32> for Wr<'b> {
    fn f(&self) -> &f32 { // error: missing lifetime linking &f32 to self
        &self.f
    }
}

Specify an explicit lifetime in the trait to ensure that the reference returned is valid for at least as long as self:

trait Tr<'a, X> {
    fn f(&'a self) -> X;
}

struct Wr<'b> {
    ri: &'b i32,
    f: f32,
}

impl<'a, 'b: 'a> Tr<'a, &'a f32> for Wr<'b> {
    fn f(&'a self) -> &'a f32 { // ok!
        &self.f
    }
}

`

@progressive-galib
Copy link
Contributor

E0495 now is emitted at here, https://github.com/chenyukang/rust/blob/a917fd5f98913a04b839cccca43558f4e4fc831b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs#L1032-L1038

the meaning of error seems changed, we need to update the document for E0495.

after reading this and doing some digging i think current error from
`trait Tr {
fn f(&self) -> X;
}

struct Wr<'b> {
ri: &'b i32,
f: f32,
}

impl<'b> Tr<&f32> for Wr<'b> {
fn f(&self) -> &f32 {
&self.f
}
}`

is very different from current E095, so we should create a new error and document his behavior there. that way we can preserve documentation for old versions of compiler and keep the documentation consistent.

@xizheyin
Copy link
Contributor

Ok, I have alloced a new errorcode.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 19, 2025
fix: Alloc new errorcode E0803 for E0495

As discussion in rust-lang#136827, I alloc a new errorcode.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 19, 2025
Rollup merge of rust-lang#137059 - xizheyin:issue-136827, r=davidtwco

fix: Alloc new errorcode E0803 for E0495

As discussion in rust-lang#136827, I alloc a new errorcode.
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 A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants