gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Feature/Attribute fundamental

Open powerboat9 opened this issue 2 years ago • 4 comments

I tried this code:

#![feature(fundamental)]

#[fundamental]
#[allow(unused)]
struct Foo {}

I expected to see this happen: No error

Instead, this happened:

<source>:1:12: error: unknown feature 'fundamental'
    1 | #![feature(fundamental)]
      |            ^~~~~~~~~~~

Meta

  • I tested it on godbolt.com GCCRS master, April 3 2023. I can run it locally and obtain a commit hash if necessary.

powerboat9 avatar Apr 03 '23 19:04 powerboat9

This changes the rules around coherence to indicate that it is promised that the type or trait marked with #[fundamental] will never get new trait impls mentioning it in any future version of the crate defining this type or trait. Thus allowing downstream crates to add trait impls that may otherwise conflict in future versions.

(Note: This is an informal description. You should lookup the exact coherence rules when implementing this.)

bjorn3 avatar Apr 03 '23 20:04 bjorn3

The attribute is used within libcore 1.49 so we'll need to handle it

CohenArthur avatar Apr 04 '23 08:04 CohenArthur

It only needs to be handled once coherency is implemented.

bjorn3 avatar Apr 04 '23 08:04 bjorn3

I think we should keep this issue for properly implementing the fundamental attribute, but as of right now I believe it falls into the category of "only useful for invalid Rust code". I'll open up a separate issue so that we can understand that #[fundamental] is a built-in attribute, and ignore it for now

CohenArthur avatar May 23 '24 15:05 CohenArthur