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

Trying to compile my project but it fails. #125328

Open
troindx opened this issue May 20, 2024 · 22 comments
Open

Trying to compile my project but it fails. #125328

troindx opened this issue May 20, 2024 · 22 comments
Labels
A-inference Area: Type inference C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@troindx
Copy link

troindx commented May 20, 2024

(https://github.com/troindx/oxidize/tree/bug-rust)

Meta

 rustc --version --verbose
rustc 1.78.0 (9b00956e5 2024-04-29)
binary: rustc
commit-hash: 9b00956e56009bab2aa15d7bff10916599e3d6d6
commit-date: 2024-04-29
host: x86_64-pc-windows-msvc
release: 1.78.0

Error output

 Compiling oxidize v0.1.0 (C:\Users\troin\www\oxidize)
thread 'rustc' panicked at compiler\rustc_resolve\src\late\diagnostics.rs:821:61:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7fff322e33ca - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:99
   1:     0x7fff322e33ca - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7fff322e33ca - std::sys_common::backtrace::_print_fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:68
   3:     0x7fff322e33ca - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:44
   4:     0x7fff3231634b - core::fmt::rt::Argument::fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\fmt\rt.rs:142
   5:     0x7fff3231634b - core::fmt::write
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\fmt\mod.rs:1153
   6:     0x7fff322d9ac1 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\io\mod.rs:1843
   7:     0x7fff322e31b6 - std::sys_common::backtrace::print
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:34
   8:     0x7fff322e661f - std::panicking::default_hook::closure$1
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:272
   9:     0x7fff322e62b7 - std::panicking::default_hook
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:292
  10:     0x7fff36dba021 - __longjmp_internal
  11:     0x7fff322e6c4c - alloc::boxed::impl$49::call
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\alloc\src\boxed.rs:2034
  12:     0x7fff322e6c4c - std::panicking::rust_panic_with_hook
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:783
  13:     0x7fff322e6a9b - std::panicking::begin_panic_handler::closure$0
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:649
  14:     0x7fff322e3cd9 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys_common\backtrace.rs:171
  15:     0x7fff322e6796 - std::panicking::begin_panic_handler
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\panicking.rs:645
  16:     0x7fff3233cec7 - core::panicking::panic_fmt
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:72
  17:     0x7fff3233cfa2 - core::panicking::panic
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\panicking.rs:145
  18:     0x7fff3233ce68 - core::option::unwrap_failed
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\core\src\option.rs:1985
  19:     0x7fff37420a2f - <rustc_resolve[26bc76c62b7d8db7]::imports::ImportKind as core[a12e26040cc72c4]::fmt::Debug>::fmt
  20:     0x7fff37441534 - <rustc_abi[88a48d514936624a]::ReprFlags as core[a12e26040cc72c4]::fmt::UpperHex>::fmt
  21:     0x7fff3625abc8 - <rustc_resolve[26bc76c62b7d8db7]::Resolver>::into_outputs
  22:     0x7fff361fc7d0 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_poly_trait_ref
  23:     0x7fff361abf95 - <rustc_ast_lowering[bce38aa82744cf9a]::LoweringContext>::lower_generic_param
  24:     0x7fff361fa5c0 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_ty
  25:     0x7fff361faf4d - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_ty
  26:     0x7fff362041d4 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_generic_arg
  27:     0x7fff361faf0d - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_ty
  28:     0x7fff361b1f5c - <rustc_ast_lowering[bce38aa82744cf9a]::LoweringContext>::lower_generic_param
  29:     0x7fff361e0a35 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_item
  30:     0x7fff3620f083 - <<rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor>::find_lifetime_for_self::SelfVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_ty
  31:     0x7fff3620fb12 - <<rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor>::find_lifetime_for_self::SelfVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_ty
  32:     0x7fff3625861c - <rustc_resolve[26bc76c62b7d8db7]::Resolver>::into_outputs
  33:     0x7fff361df135 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_item
  34:     0x7fff361b2013 - <rustc_ast_lowering[bce38aa82744cf9a]::LoweringContext>::lower_generic_param
  35:     0x7fff361e19f6 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_item
  36:     0x7fff361b2013 - <rustc_ast_lowering[bce38aa82744cf9a]::LoweringContext>::lower_generic_param
  37:     0x7fff361e19f6 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_item
  38:     0x7fff361b2013 - <rustc_ast_lowering[bce38aa82744cf9a]::LoweringContext>::lower_generic_param
  39:     0x7fff361e19f6 - <rustc_resolve[26bc76c62b7d8db7]::late::LateResolutionVisitor as rustc_ast[97cebbd51378ca2]::visit::Visitor>::visit_item
  40:     0x7fff362343bd - <rustc_resolve[26bc76c62b7d8db7]::Resolver>::into_outputs
  41:     0x7fff35623444 - <rustc_resolve[26bc76c62b7d8db7]::Resolver>::resolve_crate
  42:     0x7fff35aeb535 - <rustc_interface[c379e6340dfc8ff4]::passes::LintStoreExpandImpl as rustc_expand[ac7fa28d9271a0f1]::base::LintStoreExpand>::pre_expansion_lint
  43:     0x7fff3575ede1 - <rustc_mir_dataflow[c558c2d92ad223ea]::value_analysis::Map>::find_discr
  44:     0x7fff3574802d - <rustc_mir_dataflow[c558c2d92ad223ea]::value_analysis::Map>::find_discr
  45:     0x7fff356d2518 - <rustc_mir_dataflow[c558c2d92ad223ea]::value_analysis::Map>::find_discr
  46:     0x7fff3576642e - rustc_query_impl[35a1e4ec0f2bf1cb]::query_system
  47:     0x7fff359ee962 - <rustc_middle[df39feebc6eef2ee]::ty::context::TyCtxt>::resolver_for_lowering
  48:     0x7fff32b6413e - __ImageBase
  49:     0x7fff32b61777 - __ImageBase
  50:     0x7fff32b692b0 - __ImageBase
  51:     0x7fff322f7d3c - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library\std\src\sys\pal\windows\thread.rs:54
  52:     0x7fffb9cc7344 - BaseThreadInitThunk
  53:     0x7fffb9e426b1 - RtlUserThreadStart

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.78.0 (9b00956e5 2024-04-29) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

I am a noob at rust, just trying to teach myself how to code in rust when this showed up.

@troindx troindx added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 20, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 20, 2024
@troindx
Copy link
Author

troindx commented May 20, 2024

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: could not compile oxidize (bin "oxidize")

@pacak
Copy link
Contributor

pacak commented May 20, 2024

@workingjubilee
Copy link
Contributor

workingjubilee commented May 20, 2024

@pacak Your example seems to be a different ICE, as it has a different query stack and panics in a different place:

query stack during panic:
0 [typeck] type-checking <impl at src/lib.rs:21:1: 21:14>::finalize
1 [analysis] running analysis passes on this crate
end of query stack

the issue gets reported as:

error: internal compiler error: compiler/rustc_infer/src/infer/at.rs:400:21: relating different kinds: (?2t,) ReEarlyParam(DefId(0:7 ~ playground[c60f]::{impl#0}::'r), 0, 'r)

@pacak
Copy link
Contributor

pacak commented May 20, 2024

has a different query stack and panics in a different place:

Hmm... I wonder when it changed. Will try again. I guess both ICEs should be fixed.

@pacak
Copy link
Contributor

pacak commented May 20, 2024

Made a single file version again, trying to minimize

@pacak
Copy link
Contributor

pacak commented May 20, 2024

original file

@troindx
Copy link
Author

troindx commented May 21, 2024

hi back. thanks for the quick responses . i'll investigate all that you have provided me and reach back
.. .. in this context.
..... what is an ICE?

@troindx
Copy link
Author

troindx commented May 21, 2024

i ... don't know where or how to continue... is this something I'm doing wrong? is it a bug from compiler?
I cant tell where I'm making the error. I try to prune the project and reinstall all dependencies but it doesn't seem to work properly. I'm unsure of how to continue. any suggestions as to what should I try to do to continue? or how to debug ? any comment in advance would be amazing.

@pacak
Copy link
Contributor

pacak commented May 21, 2024

..... what is an ICE?

Internal Compiler Error, you are doing something compiler doesn't expect

is this something I'm doing wrong? is it a bug from compiler?

You are doing something unexpected, this is a bug in the compiler. I'm not sure what the best path forward would be though.

@troindx
Copy link
Author

troindx commented May 21, 2024 via email

@troindx
Copy link
Author

troindx commented May 21, 2024

how can I see, or know, where is this bug coming from? so I can... undo stuff.,.. program things in a different way so that the bug does not happen again?
i have removed all Options<> and it still does not work

@pacak
Copy link
Contributor

pacak commented May 21, 2024

You can take my "original file" link and whack at it until it stops panicking. devs at rocket might be of some help...

@troindx
Copy link
Author

troindx commented May 21, 2024 via email

@pacak
Copy link
Contributor

pacak commented May 21, 2024

Where is that original file?

#125328 (comment)

I see the link that you provided and I read the file but I'm not sure of how to include it in my code

You don't really include in your code. Its a smaller example of whatever causes compiler to panic that doesn't have any external dependencies. So paste it into a new crate and start experimenting. If you manage to convince rustc to compile it without problems - you'll need to apply similar change to your project.

@workingjubilee
Copy link
Contributor

workingjubilee commented May 21, 2024

@troindx The code you are working with includes macros, which can expand to large implementations that themselves may induce compiler errors. Basically, nothing you personally wrote was independently responsible for the error, but rather the macro author's code has inflicted this on you.

You can see this by applying the following diff, which cures your compilation issues:

diff --git a/src/modules/user/dto.rs b/src/modules/user/dto.rs
index be80520..6cbe8e2 100644
--- a/src/modules/user/dto.rs
+++ b/src/modules/user/dto.rs
@@ -32,7 +32,7 @@ impl<'v> FromFormField<'v> for UserId {
     }
 }
 
-#[derive(Debug, Deserialize, Serialize,Clone, FromForm)]
+#[derive(Debug, Deserialize, Serialize,Clone)]
 pub struct User<'r> {
     pub email : &'r str ,
     pub password : &'r str,
@@ -49,10 +49,10 @@ pub enum UserRole {
     Admin
 }
 
-#[derive(Debug, FromForm, Deserialize, Serialize,Clone)]
+#[derive(Debug, Deserialize, Serialize,Clone)]
 pub struct UserDTO<'a> {
     pub user : 'a+ User,
     pub jwt_secret : String,
     #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
     pub id : Option <String> 
-}
\ No newline at end of file
+}

I mean, the code fails typechecking still, but it doesn't ICE.

@workingjubilee
Copy link
Contributor

The following more significant diff, makes the macros stop producing ICE-generating code:

diff --git a/src/modules/user/dto.rs b/src/modules/user/dto.rs
index be80520..f7cc922 100644
--- a/src/modules/user/dto.rs
+++ b/src/modules/user/dto.rs
@@ -33,10 +33,10 @@ impl<'v> FromFormField<'v> for UserId {
 }
 
 #[derive(Debug, Deserialize, Serialize,Clone, FromForm)]
-pub struct User<'r> {
-    pub email : &'r str ,
-    pub password : &'r str,
-    pub description : &'r str,
+pub struct User {
+    pub email : String,
+    pub password : String,
+    pub description : String,
     pub role : u8,
     #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
     pub _id : Option <UserId> 
@@ -50,9 +50,9 @@ pub enum UserRole {
 }
 
 #[derive(Debug, FromForm, Deserialize, Serialize,Clone)]
-pub struct UserDTO<'a> {
-    pub user : 'a+ User,
+pub struct UserDTO {
+    pub user : User,
     pub jwt_secret : String,
     #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
     pub id : Option <String> 
-}
\ No newline at end of file
+}

@troindx I recommend you apply that for now.

@troindx
Copy link
Author

troindx commented May 21, 2024 via email

@troindx
Copy link
Author

troindx commented May 21, 2024 via email

@jieyouxu jieyouxu added A-inference Area: Type inference E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 22, 2024
@troindx troindx closed this as completed May 23, 2024
@troindx
Copy link
Author

troindx commented May 23, 2024

I learned why this happened. thanks for accompanying me in my path to becoming a rustacean.

@pacak
Copy link
Contributor

pacak commented May 23, 2024

I learned why this happened. thanks for accompanying me in my path to becoming a rustacean.

You solved your problem, but compiler shouldn't panic on invalid input either, this ticket needs to be reopened.

@troindx
Copy link
Author

troindx commented May 23, 2024

sure.

@troindx troindx reopened this May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inference Area: Type inference C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants