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

Add long explanation for E0726 #87655

Closed
wants to merge 7 commits into from
Closed

Add long explanation for E0726 #87655

wants to merge 7 commits into from

Conversation

codekidX
Copy link

Hey, I think some refactoring of codebase has occurred so the guidance mentioned in #61137 is not updated I think @GuillaumeGomez .

Please let me know if any other changes needs to be added to this PR.

@rust-highfive
Copy link
Collaborator

Some changes occurred in diagnostic error codes

cc @GuillaumeGomez

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @LeSeulArtichaut (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 31, 2021

Erroneous code example:

```rust
Copy link
Member

@GuillaumeGomez GuillaumeGomez Jul 31, 2021

Choose a reason for hiding this comment

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

Suggested change
```rust
```compile_fail,E0726

}
```

Specify the lifetime of struct `Abc` or indicate the anonymous lifetime like `abc: Abc<'_>`.
Copy link
Member

Choose a reason for hiding this comment

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

The explanation is a bit lacking no? Maybe try to explain a bit more.

Copy link
Member

Choose a reason for hiding this comment

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

Also, please add a working version of the code example from above.

Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

The explanation needs to be extending (lifetimes are far from an easy topic in rust) and you also need to add a working version of your previous failing code example.

@@ -423,6 +423,7 @@ E0720: include_str!("./error_codes/E0720.md"),
E0722: include_str!("./error_codes/E0722.md"),
E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"),
E0725: include_str!("./error_codes/E0726.md"),
E0727: include_str!("./error_codes/E0727.md"),
E0728: include_str!("./error_codes/E0728.md"),
E0729: include_str!("./error_codes/E0729.md"),
Copy link
Member

Choose a reason for hiding this comment

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

You need to remove E0725 from the list of error codes from below (it's not supposed to be declared twice in this file).

@@ -423,6 +423,7 @@ E0720: include_str!("./error_codes/E0720.md"),
E0722: include_str!("./error_codes/E0722.md"),
E0724: include_str!("./error_codes/E0724.md"),
E0725: include_str!("./error_codes/E0725.md"),
E0725: include_str!("./error_codes/E0726.md"),
Copy link
Member

Choose a reason for hiding this comment

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

It's also 726 and not 725.

Suggested change
E0725: include_str!("./error_codes/E0726.md"),
E0726: include_str!("./error_codes/E0726.md"),

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@codekidX
Copy link
Author

@GuillaumeGomez does E0726 it not have a test case? if not, where should I add it?

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@codekidX
Copy link
Author

codekidX commented Aug 5, 2021

hey @GuillaumeGomez, I have added detailed explanation, please take a look.

Also the test is failing as

Some errors have detailed explanations: E0277, E0726.
For more information about an error, try `rustc --explain E0277`.

it should be

Some errors have detailed explanations: E0726.

right?

Since its itself E0277. Do let me know if this is an issue or I need to add E0277 above as well.

@@ -0,0 +1,47 @@
When a struct or a type is bound/declared with a lifetime it is important for
Copy link
Member

Choose a reason for hiding this comment

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

Please write a short summary of the error here, the explanation goes below. :)

Something like "An argument's lifetime was elided in an async function".

@GuillaumeGomez
Copy link
Member

@GuillaumeGomez does E0726 it not have a test case? if not, where should I add it?

In src/test/ui/error_codes/ (there are a few others in this folder too so you can check how it works).

For the failing ui test, simply run it with --bless and let the tester do its job. ;)

struct Blog;

impl Blog {
pub async fn create(content: Content) { // error: implicit elided
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need a method btw? Shouldn't an async function be enough?

}
}

fn main() {
Copy link
Member

Choose a reason for hiding this comment

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

No need to declare a main function, please remove it (but keep its content!).

`pub async fn create<'a>(content: Content<'a>) {}` is not allowed here as
lifetime of the `content` can differ from current context.

Know more about lifetime elision in this
Copy link
Member

Choose a reason for hiding this comment

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

Please add a working version of your example above.

@bors
Copy link
Contributor

bors commented Aug 8, 2021

☔ The latest upstream changes (presumably #87697) made this pull request unmergeable. Please resolve the merge conflicts.

@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2021
@JohnCSimon
Copy link
Member

Ping from triage:
@codekidX can you please address the merge conflicts and build failures. Thank you.

@JohnCSimon
Copy link
Member

Ping again from triage:
@codekidX can you please address the merge conflicts and build failures. Thank you.

@codekidX
Copy link
Author

@JohnCSimon I'll rebase and resolve comments by today. Had some busy weeks, thanks for waiting.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-10 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
To only update this specific test, also pass `--test-args issues/issue-10412.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-10412.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-10412" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-10412/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error: lifetimes cannot use keyword names
  --> /checkout/src/test/ui/issues/issue-10412.rs:1:20
   |
LL | trait Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names

error: lifetimes cannot use keyword names
  --> /checkout/src/test/ui/issues/issue-10412.rs:2:25
   |
   |
LL |     fn serialize(val : &'self T) -> Vec<u8>; //~ ERROR lifetimes cannot use keyword names

error: lifetimes cannot use keyword names
  --> /checkout/src/test/ui/issues/issue-10412.rs:3:38
   |
   |
LL |     fn deserialize(repr : &[u8]) -> &'self T; //~ ERROR lifetimes cannot use keyword names

error: lifetimes cannot use keyword names
  --> /checkout/src/test/ui/issues/issue-10412.rs:6:6
   |
   |
LL | impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names

error: lifetimes cannot use keyword names
  --> /checkout/src/test/ui/issues/issue-10412.rs:6:36
   |
   |
LL | impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names

error: lifetimes cannot use keyword names
  --> /checkout/src/test/ui/issues/issue-10412.rs:10:25
   |
   |
LL |     fn serialize(val : &'self str) -> Vec<u8> { //~ ERROR lifetimes cannot use keyword names

error: lifetimes cannot use keyword names
  --> /checkout/src/test/ui/issues/issue-10412.rs:13:37
   |
   |
LL |     fn deserialize(repr: &[u8]) -> &'self str { //~ ERROR lifetimes cannot use keyword names


error[E0726]: implicit elided lifetime not allowed here
   |
   |
LL | impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
   |             ^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `Serializable<'_, str>`
   |
   = note: assuming a `'static` lifetime...
error[E0277]: the size for values of type `str` cannot be known at compilation time
  --> /checkout/src/test/ui/issues/issue-10412.rs:6:13
   |
   |
LL | impl<'self> Serializable<str> for &'self str { //~ ERROR lifetimes cannot use keyword names
   |
   = help: the trait `Sized` is not implemented for `str`
note: required by a bound in `Serializable`
  --> /checkout/src/test/ui/issues/issue-10412.rs:1:27
  --> /checkout/src/test/ui/issues/issue-10412.rs:1:27
   |
LL | trait Serializable<'self, T> { //~ ERROR lifetimes cannot use keyword names
   |                           ^ required by this bound in `Serializable`
help: consider relaxing the implicit `Sized` restriction
   |
LL | trait Serializable<'self, T: ?Sized> { //~ ERROR lifetimes cannot use keyword names

error: aborting due to 9 previous errors

Some errors have detailed explanations: E0277, E0726.
---
test result: FAILED. 12098 passed; 1 failed; 115 ignored; 0 measured; 0 filtered out; finished in 127.22s



command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--suite" "ui" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-10/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python3" "--lldb-python" "/usr/bin/python3" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "10.0.0" "--llvm-components" "aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo cfguard codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver dwarflinker engine executionengine frontendopenmp fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader jitlink lanai lanaiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcerror orcjit passes perfjitevents powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvutils runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86utils xcore xcorecodegen xcoredesc xcoredisassembler xcoreinfo xray" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--channel" "nightly" "--color" "always"


Build completed unsuccessfully in 0:12:58

@apiraino apiraino added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Oct 14, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 31, 2021
@bors
Copy link
Contributor

bors commented Nov 5, 2021

☔ The latest upstream changes (presumably #90616) made this pull request unmergeable. Please resolve the merge conflicts.

@jyn514
Copy link
Member

jyn514 commented Nov 18, 2021

Hi @apiraino, why did you add T-rustdoc here? This is a compiler error, rustdoc doesn't introduce any error codes that I know of.

@jyn514 jyn514 added A-error-codes Area: Explanation of an error code (--explain) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Nov 18, 2021
@apiraino
Copy link
Contributor

apiraino commented Nov 18, 2021

why did you add T-rustdoc here? This is a compiler error, rustdoc doesn't introduce any error codes that I know of.

@jyn514 I sweep the repository and assign the relevant T-* labels when missing. Here I have assigned the wrong one.

I probably didn't have clear the context and having seen a review from Guillaume tricked me into assuming that t-rustdoc had a say on this. Sorry, I hope that didn't cause any issue!

@jyn514
Copy link
Member

jyn514 commented Nov 18, 2021

@apiraino no worries, I changed it to the right label :)

@jyn514 jyn514 closed this Nov 18, 2021
@jyn514 jyn514 reopened this Nov 18, 2021
@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 24, 2021
@jyn514
Copy link
Member

jyn514 commented Nov 24, 2021

Hi @codekidX, do you know how to fix the CI error? I think you just need to pass --bless to the tests :) feel free to ask me here or on Zulip if you're having trouble!

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 12, 2021
@ThrashAbaddon
Copy link

bump!

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 30, 2022
@JohnCSimon
Copy link
Member

@codekidX
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this. Thanks for your contribution.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this Feb 27, 2022
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Feb 27, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 28, 2022
…=Urgau

Add long explanation for E0726

This is the cleaned up version of rust-lang#87655 with the missing fixes.

Part of rust-lang#61137.

r? `@Urgau`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-error-codes Area: Explanation of an error code (--explain) S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.