Skip to content

Conversation

@BennoLossin
Copy link
Owner

@BennoLossin BennoLossin commented Aug 16, 2025

Decisions

Decisions made during the experiment:

  • field representing types are uninhabited and have the same layout as !

  • users may implement any trait for field representing type they want (if either one is local)

    • exceptions to this rule are: Drop and Field/UnalignedField. The former because copying the drop impl data sturctures from ADTs is a lot of code duplication & people aren't going to want to drop field types in the first place. The latter two since they are already implemented by the compiler automatically.
  • field representing types are considered local by the orphan check if and only if:

    • The outer-most container is a local struct,
    • All intermediate bases that are structs must be local (we don't consider the type of the field to be an intermediate base)

    So field_of!(Foo, bar.baz) is local if Foo and Bar are local (Baz is allowed to be foreign). Except for tuples, fundamental types are not handled specially. Tuples are allowed as intermediate bases, as long as the first one isn't a tuple. So field_of!(Foo, bar.0.baz) is considered local if Foo is local & bar has type (Bar0, Bar1, ..., BarN) with Bar0 also being local.

TODOs

In the PR the following bigger items still need to be decided/implemented:

  • allow field representing types to implement Drop. Relevant files:
    • compiler/rustc_ty_utils/src/needs_drop.rs
    • compiler/rustc_trait_selection/src/traits/effects.rs
    • compiler/rustc_trait_selection/src/traits/query/dropck_outlives.rs
    • compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs
    • compiler/rustc_middle/src/ty/significant_drop_order.rs
  • get rid of trailing . when printing the type.
    • compiler/rustc_const_eval/src/util/type_name.rs
    • compiler/rustc_middle/src/ty/print/pretty.rs
  • only ADTs are currently supported by this PR, tuple
  • Do we want to resolve types more when walking a field path?
    • compiler/rustc_middle/src/ty/field_path.rs
  • Should visiting field types mean walking all types in the chain or only
    the base? or also the last one?
    • compiler/rustc_middle/src/ty/structural_impls.rs
  • unable to implement lower_field_path in ItemCtxt?!
    • compiler/rustc_hir_analysis/src/collect.rs
  • add an error when trying to implement UnalignedField/Field for a FRT
  • only implement Field when the base is not repr(packed)!
  • symbol mangling for FTRs.
    • compiler/rustc_symbol_mangling/src/v0.rs
    • compiler/rustc_symbol_mangling/src/export.rs
    • compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
    • compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs
  • offset_of! lowering changed, now we have a new bug! in the ThirBuildCx: compiler/rustc_mir_build/src/thir/cx/expr.rs. should this be handled differently?
  • rustdoc support for FTRs
    • src/librustdoc/passes/collect_intra_doc_links.rs
    • src/librustdoc/json/conversions.rs
    • src/librustdoc/clean/mod.rs

Note that there are some other todos as well, but those are probably smaller

@BennoLossin BennoLossin force-pushed the field-projections branch 15 times, most recently from bc6c00c to 40daa48 Compare August 25, 2025 18:03
BennoLossin pushed a commit that referenced this pull request Sep 2, 2025
…=jieyouxu

Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#1 of Batch rust-lang#2]

Part of rust-lang#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
@BennoLossin BennoLossin force-pushed the field-projections branch 3 times, most recently from a3635bf to 42db8e9 Compare September 3, 2025 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants