Comments (7)
@CohenArthur I'll start working on this could you assign this to me.
from gccrs.
just removing the rust_error_at would remove the error , is there any specific info you would like me to return in the case of an unkown suffix?
Tbh it's been a while since I've created this issue. IIRC this was because proc macros content should be relaxed and the suffixes should be rejected later (when ? during ast validation ?).
You'll have to rework the token structure in order to store custom suffixes. From here I see two ways of doing it:
- Revamp the whole token system to accommodate custom suffixes as well as standard suffixes in an unified way
- A lot of work
- Expect a lot of things to break during the refactor
- Is this really a better way ?
- Extend the current token implementation with a new pointer field for custom suffixes. A new coretype to differentiate those from unsuffixed literals (
CORETYPE_CUSTOM_SUFFIX
?)
- Easier to do
- add a member to an enum
- add a getter to retrieve the suffix from the associated text, we probably want to avoid duplicating the suffix as it is already stored and tokens should be kept slim
- a pointer/reference_wrapper to the suffix position would be ok
- but processing the suffix position everytime might be good too, the getter probably won't be called that much.
- change the parser to build those types
- You should be careful, some components might silently fail after that
I would probably go with solution 2 for now, it'll be easier and such a refactor could be done later anyway.
Do not hesitate to ask more questions about this, it's been a while and I may have forgotten some details.
from gccrs.
Thanks for the detailed response. I'll try and implement solution 2 and will ping you if I run into something odd. Most likely the thing that seems difficult is to catch the things that might fail silently, but I'll get to that when I am done with a rough solution.
from gccrs.
hey @P-E-P , I am not sure how I should go about it, because the rustc also catches this as a lexical error. :3
from gccrs.
@mvvsmk with the following code:
fn foo() {
let a = 15q;
}
and running rustc
with -Z parse-only
, we don't get any error. so the parsing is correct, but rustc
has an extra AST validation step that checks that the suffix is correct.
I'm not sure if this is overkill and if we should just have a parsing error. This is probably useful for custom suffixes and future suffix developments in Rust, but we won't have changes like these in gccrs
- we'll only reflect what rustc
is doing
from gccrs.
@mvvsmk with the following code:
fn foo() { let a = 15q; }and running
rustc
with-Z parse-only
, we don't get any error. so the parsing is correct, butrustc
has an extra AST validation step that checks that the suffix is correct.I'm not sure if this is overkill and if we should just have a parsing error. This is probably useful for custom suffixes and future suffix developments in Rust, but we won't have changes like these in
gccrs
- we'll only reflect whatrustc
is doing
Not only custom suffixes, procedural macros are impacted by this behavior.
from gccrs.
@P-E-P could you hellp me out a bit
gccrs/gcc/rust/lex/rust-lex.cc
Lines 1221 to 1227 in 3fcd86e
just removing the rust_error_at would remove the error , is there any specific info you would like me to return in the case of an unkown suffix?
from gccrs.
Related Issues (20)
- Handle list of const intrinsics properly for 1.49
- Add `discriminant_kind` lang item
- Add `#[rustc_specialization_trait]` attribute HOT 1
- Add `#[rustc_unsafe_specialization_marker]` attribute
- Prevent `#[may_dangle]` attribute from being used in safe impl
- ICE when on invalid-code when construction enum
- Do not link with `-ldl` and `-lpthread` unless necessary
- Handle outer attributes properly for inline assembly
- Improve `-ldl -lpthread` checks in `./configure`
- Safe guard InlineAsm-related structs
- Remove unnecessary #include from rust-expr.h HOT 2
- Fully incorporate tl::expected into InlineAsm parsing
- asm! macro failed to exhaustively parse all of options(), clobber_abis() and register operands
- Typechecking of asm! failed in `let _` HOT 1
- Add ExprType::InlineAsm variant to ExprType enum HOT 1
- Cleanup vector copies from Rust to C++ in BIR HOT 2
- Add special `LangItemPath` AST node
- Make asm parser stores parse result
- Union pattern matching expecting all fields
- asm parser lacking `label` parse functionality
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 gccrs.