Comments (3)
i wanna solve this issue
from gccrs.
- try this...
- The issue with the code you provided is that trait items, including associated types like type X, cannot be marked as pub. The pub keyword specifies the item's visibility, but associated types in traits are always public by default. Therefore, you can simply remove the pub keyword from the declaration of type X:
fn main() {}
- #[cfg(FALSE)]
trait T
[ ] {
type X;
}
i hope it will solve the issue...
from gccrs.
i wanna solve this issue
Sure @officialhemant511 ! I can assign it to you.
* The issue with the code you provided is that trait items, including associated types like type X, cannot be marked as pub. The pub keyword specifies the item's visibility, but associated types in traits are always public by default. Therefore, you can simply remove the pub keyword from the declaration of type X:
The problem here does not lie in the code in this code but rather in the compiler. rustc
can compile this code without any error (link to the playground).
It compiles because the line has been disabled thanks to #[cfg(FALSE)]
. The step that removes part of the AST with those cfg
directives is called "cfg stripping" in gccrs. This step relies on the ast, this means we shall refer to rust syntax reference:
Syntax
AssociatedItem :
OuterAttribute* (
MacroInvocationSemi
| ( Visibility? ( TypeAlias | ConstantItem | Function ) )
)
from https://doc.rust-lang.org/beta/reference/items/associated-items.html, here pub type
fall in the type alias category.
Note that from the syntax pov, this visibility modifier is expected even if the language reject it at a later stage with the error 0449.
The error message from gccrs states that it originates from the parsing stage of the compiler. This means the AST has not been finished yet. We should be able to parse this syntax, even if rejected later, so it could be eliminated by the cfg stripper.
To sum up
The parser shall be fixed to accept a visibility modifier. The problem probably is in the member function parse_trait_item
in rust-parse-impl.h. The function does not expect pub
and falls to the default case label, which s expecting a macro.
This means we should probably modify the TraitIemType
ast node to store the visibility and reject the line at a later stage.
Do you still want to me to assign you on the issue ? I hope this didn't break your confidence or anything.
from gccrs.
Related Issues (20)
- Impl block after macro expansion triggers macro expansion recursion limit HOT 1
- Unknown reference for resolved name `Self` in impl of `Clone` for `!`
- ICE when implementing `Default` for `()`
- Add `va_list` lang item
- Name resolve `#[fundamental]` attribute properly
- 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
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.