Comments (5)
Should $item allow safe functions at all? (I think "yes", since it already accepts extern-block items.)
Yes, I don't think we need to be doing any context-specific parsing of macro item fragments. Validation that safe
is only placed on items in an extern block should be done post-expansion IMO. That lets us write:
macro_rules! wrap_in_extern { ($i:item) => { unsafe extern { $i } } }
wrap_in_extern! { safe fn foo(); }
Should that be split out into a separate fragment, such as $item_2021 does not allow safe, and $item does in 2024?
We already allow item macro fragment specifiers start with the safe
identifier, since safe
might begin a macro item e.g. safe::hello_world! {}
, so I don't think this is necessary.
from rust.
Another issue appears that safe
is not feature-gated. The following seems to build without a feature gate:
safe fn foo() {}
from rust.
Thanks. I'll fix the feature gating at least, since it's regressed to beta. Let me break that out into another issue.
from rust.
But to repeat myself just for clarity, I think we just need to do post-expansion validation of function signatures to guarantee that safe
is only written on items in extern
blocks.
from rust.
Thanks @compiler-errors your fix at least make this thing not compile. I'm going to fix the underlying issue that I think started to happen as I ended going to a scheme where we have hir::Safety (safe|unsafe) and we do not have a default variant. I'm pretty sure that this thing originally wasn't happening but I've failed to add tests for this.
Anyway, going to fix this.
from rust.
Related Issues (20)
- ICE: `None` in compiler/rustc_middle/src/ty/sty.rs HOT 2
- Specific inline ASM in specific project generates invalid ASM HOT 3
- multiple platforms incorrectly impl `thread::sleep` with `Duration::as_micros` HOT 4
- ICE: `Encountered error SignatureMismatch`
- ICE: no `enclosing_body_owner` for hir_id HOT 1
- ICE: `associated type missing default`
- ICE: invalid pointer unsizing &dyn Foo -> [i32]
- using extern "x86-interrupt" + #[naked] + kernel address sanitizer crashes compiler HOT 4
- Compiler panics when i run cargo check HOT 3
- const_heap feature can be used to leak mutable memory into final value of constant
- `-Zthreads` is slower the more cores I add HOT 1
- `std::fs::canonicalize` failed to process path mounted with cppcryptfs/dokan under windows HOT 1
- rustc_driver: There is no explanation of when the IRs (HIR, THIR, MIR) become available.
- Delay def creation for expression-like nodes HOT 1
- Refining generic bounds in trait method HOT 4
- Unsized parameters are not flagged in trait definitions
- E0382: Add help for fixing a partially moved struct by manual assignment
- `single_use_lifetimes`: false positive (suggests unstable anonymous lifetimes in `impl Trait`)
- argon2rs is broken in nightly in `LoweringContext>::create_def.cold` HOT 1
- ICE: field should be captured by immutable ref if we have an `Fn` instance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.