Skip to content

Conversation

@reddevilmidzy
Copy link
Contributor

@reddevilmidzy reddevilmidzy commented Dec 9, 2025

resolve: #149809
resolve: #148949

(todo: change PR title)

@rustbot rustbot added 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. labels Dec 9, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/const-generics/mgca/resolution-with-inherent-associated-types/resolution-with-inherent-associated-types.stderr`
diff of stderr:

14 LL | type Alias<T: Trait> = Struct<{ Struct<N>::N }>;
15    |                                       +++
16 
- error: aborting due to 1 previous error
+ error[E0220]: associated constant `N` not found for `Struct<{const error}>` in the current scope
+   --> $DIR/resolution-with-inherent-associated-types.rs:12:41
+    |
+ LL | struct Struct<const N: usize>;
+    | ----------------------------- associated constant `N` not found for this struct
+ LL |
+ LL | type Alias<T: Trait> = Struct<{ Struct::N }>;
+    |                                         ^ associated item not found in `Struct<{const error}>`
+    |
+    = note: the associated constant was found for
+            
18 
- For more information about this error, try `rustc --explain E0107`.
---
20 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs:12:41
+ error[E0220]: associated constant `N` not found for `Struct<{const error}>` in the current scope
+   --> $DIR/resolution-with-inherent-associated-types.rs:12:41
+    |
+ LL | struct Struct<const N: usize>;
+    | ----------------------------- associated constant `N` not found for this struct
+ LL |
+ LL | type Alias<T: Trait> = Struct<{ Struct::N }>;
+    |                                         ^ associated item not found in `Struct<{const error}>`
+    |
+    = note: the associated constant was found for
+            
+ error: aborting due to 2 previous errors
+ 
---
To only update this specific test, also pass `--test-args const-generics/mgca/resolution-with-inherent-associated-types.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/const-generics/mgca/resolution-with-inherent-associated-types" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--crate-type=lib"
stdout: none
--- stderr -------------------------------
error[E0107]: missing generics for struct `Struct`
##[error]  --> /checkout/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs:12:33
   |
LL | type Alias<T: Trait> = Struct<{ Struct::N }>;
   |                                 ^^^^^^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `N`
  --> /checkout/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs:10:8
   |
LL | struct Struct<const N: usize>;
   |        ^^^^^^ --------------
help: add missing generic argument
   |
LL | type Alias<T: Trait> = Struct<{ Struct<N>::N }>;
   |                                       +++

error[E0220]: associated constant `N` not found for `Struct<{const error}>` in the current scope
##[error]  --> /checkout/tests/ui/const-generics/mgca/resolution-with-inherent-associated-types.rs:12:41
   |
LL | struct Struct<const N: usize>;
   | ----------------------------- associated constant `N` not found for this struct
LL |
LL | type Alias<T: Trait> = Struct<{ Struct::N }>;
   |                                         ^ associated item not found in `Struct<{const error}>`
   |
   = note: the associated constant was found for
           

error: aborting due to 2 previous errors

// At the moment, we actually bail out with a hard error if the selection of an inherent
// associated item fails (see below). This means we never consider trait associated items
// as potential fallback candidates (#142006). To temporarily mask that issue, let's not
// select at all if there are no early inherent candidates.
Copy link
Member

Choose a reason for hiding this comment

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

This comment needs to be moved above the Type branch then, otherwise it no longer makes sense

return Ok(None);
return match assoc_tag {
ty::AssocTag::Type => Ok(None),
ty::AssocTag::Const => Err(self.report_unresolved_inherent_assoc_item(
Copy link
Member

@fmease fmease Dec 9, 2025

Choose a reason for hiding this comment

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

Just so we're clear, this is not the correct fix long term because we need to probe trait candidates, too, if there are no inherent candidates.

Moreover, adding this error back in just means we're likely just papering over some deeper mGCA issue that ultimately needs to be fixed some other way, possible. Well, I haven't really looked into the cause of the ICEs but Boxy knew of their existence all the way back when she worked on #140247.

Copy link
Member

@fmease fmease Dec 9, 2025

Choose a reason for hiding this comment

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

This should reside in tests/ui/const-generics/mgca/& be called differently. mGCA just reuses the feature gate of IATs for type-level assoc const resolution since they share the impl. Otherwise, mGCA is completely unrelated to IATs.

@rustbot
Copy link
Collaborator

rustbot commented Dec 9, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

ICE unelided lifetime in signature ICE unelided lifetime in signature

5 participants