Coder Social home page Coder Social logo

Comments (9)

lukas-code avatar lukas-code commented on May 30, 2024 4

I have never been able to find where that cfg might be set by rustfmt so I (wrongly) assumed it was anymore, looks this I was wrong.

It looks like rustfmt will just always treat cfg_attr(anything, rustfmt::skip) as rustfmt::skip, regardless of the actual cfg condition, so this will also work: (playgound)

mod m {
    #![cfg_attr(any(), rustfmt::skip)]
    
    fn dont_format_me ()  {   }
}

from rust.

Urgau avatar Urgau commented on May 30, 2024 1

Another thing that isn't right here is that the rustfmt cfg is not a well known cfg.

I have never been able to find where that cfg might be set by rustfmt so I (wrongly) assumed it was anymore, looks this I was wrong.

@rustbot label -needs-triage +F-check-cfg
@rustbot claim

from rust.

taiki-e avatar taiki-e commented on May 30, 2024 1

they can (stably) be applied directly to the mod, like this:

#[rustfmt::skip]
mod a;

Unfortunately, that is not an option available to me due to a rust-analyzer bug: rust-lang/rust-analyzer#10826 (comment)

from rust.

Urgau avatar Urgau commented on May 30, 2024

I would also expect the #[allow] to work here.

However, I don't think you need the cfg_attr anymore, it can be removed safely.

- #![cfg_attr(rustfmt, rustfmt::skip)]
+ #![rustfmt::skip]

from rust.

taiki-e avatar taiki-e commented on May 30, 2024

it can be removed safely.

No. Custom inner attributes are unstable.

error[E0658]: custom inner attributes are unstable
 --> src/lib.rs:1:4
  |
1 | #![rustfmt::skip]
  |    ^^^^^^^^^^^^^
  |
  = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
  = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
  = note: this compiler was built on 2024-05-04; consider upgrading it if it is out of date

playground

from rust.

Urgau avatar Urgau commented on May 30, 2024

Oh, good point, but they can (stably) be applied directly to the mod, like this:

#[rustfmt::skip]
mod a;

from rust.

fmease avatar fmease commented on May 30, 2024

It looks like rustfmt will just always treat cfg_attr(anything, rustfmt::skip) as rustfmt::skip, regardless of the actual cfg condition

Oh, no! >.<

from rust.

Urgau avatar Urgau commented on May 30, 2024

The rustfmt cfg is now (as of nighlty-2024-05-07) recognized has a well known cfg.
Fixing one of the issue reported by this issue.

from rust.

pnkfelix avatar pnkfelix commented on May 30, 2024

cc #82450

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.