-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make getter
s, setter
s, and constructor
s compiler errors for enums
#4278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
daxpedda
merged 24 commits into
rustwasm:main
from
RunDevelopment:error-enum-getter-setter-constructor
Dec 9, 2024
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
ad495c9
Make `getter`s, `setter`s, and `constructor`s compiler errors for enums
RunDevelopment e967962
Better error messages
RunDevelopment 888ead1
rustfmt
RunDevelopment 77c3696
Merge branch 'main' into error-enum-getter-setter-constructor
RunDevelopment f07b885
Add `rustversion` and `diagnostic` feature
RunDevelopment 526400f
Different code gen for static asserts
RunDevelopment 81f2d43
Use Rust 1.78.0 to run UI tests
RunDevelopment 9342b6d
Fixed span
RunDevelopment 0f75414
Updated other ui tests
RunDevelopment 95715ec
Export marker traits under `::__rt::marker`
RunDevelopment 4a83589
Merge branch 'main' into error-enum-getter-setter-constructor
RunDevelopment 053c60e
Feature suggestions
RunDevelopment db953cc
Shared check struct
RunDevelopment ed462cc
Fixed main debug warning
RunDevelopment 6ac1419
Terser error messages
RunDevelopment 2802d40
Removed `extern crate rustversion`
RunDevelopment 9355f5c
Merge branch 'main' into error-enum-getter-setter-constructor
RunDevelopment 49f6c4d
Move `marker.rs` file under `rt`
RunDevelopment 7512b07
Document `msrv` feature
RunDevelopment 5e461ff
Remove useless `automatically_derived`
RunDevelopment bd9f847
Updated UI tests
RunDevelopment 80ab2ef
Update changelog
RunDevelopment b240d26
Apply suggestions from code review
RunDevelopment e1d2358
Test MSRV and resolver v1 of new crate feature
daxpedda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,20 @@ error: the main function has to be called main | |
| | ||
10 | fn fail() {} | ||
| ^^^^ | ||
|
||
warning: unreachable expression | ||
--> ui-tests/main-infallible.rs:4:1 | ||
| | ||
4 | #[wasm_bindgen(main)] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| unreachable expression | ||
| any code following this expression is unreachable | ||
| | ||
note: this expression has type `Infallible`, which is uninhabited | ||
--> ui-tests/main-infallible.rs:4:1 | ||
| | ||
4 | #[wasm_bindgen(main)] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
= note: `#[warn(unreachable_code)]` on by default | ||
= note: this warning originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
Comment on lines
+6
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fun. That's a bug. We should avoid emitting this warning somehow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub struct RustStruct { | ||
data: u32, | ||
} | ||
|
||
#[wasm_bindgen] | ||
impl RustStruct { | ||
pub fn instance_method(&self) {} | ||
fn priv_instance_method(&self) {} | ||
pub fn static_method() {} | ||
|
||
#[wasm_bindgen(constructor)] | ||
pub fn new() -> Self { | ||
Self { data: 0 } | ||
} | ||
|
||
#[wasm_bindgen(getter)] | ||
pub fn prop(self) -> u32 { | ||
32 | ||
} | ||
#[wasm_bindgen(setter)] | ||
pub fn set_prop(self, _value: u32) {} | ||
|
||
#[wasm_bindgen(getter)] | ||
pub fn static_prop() -> u32 { | ||
32 | ||
} | ||
#[wasm_bindgen(setter)] | ||
pub fn set_static_prop(_value: u32) {} | ||
|
||
#[wasm_bindgen(indexing_getter)] | ||
pub fn indexing_getter(self) -> u32 { | ||
32 | ||
} | ||
#[wasm_bindgen(indexing_setter)] | ||
pub fn indexing_setter(self, _value: u32) {} | ||
#[wasm_bindgen(indexing_deleter)] | ||
pub fn indexing_deleter(self, _value: u32) {} | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub enum RustEnum { | ||
A = 0, | ||
B = 1, | ||
} | ||
|
||
#[wasm_bindgen] | ||
impl RustEnum { | ||
pub fn instance_method(self) {} | ||
fn priv_instance_method(self) {} | ||
pub fn static_method() {} | ||
|
||
#[wasm_bindgen(constructor)] | ||
pub fn new() -> Self { | ||
Self::A | ||
} | ||
|
||
#[wasm_bindgen(getter)] | ||
pub fn prop(self) -> u32 { | ||
32 | ||
} | ||
#[wasm_bindgen(setter)] | ||
pub fn set_prop(self, _value: u32) {} | ||
|
||
#[wasm_bindgen(getter)] | ||
pub fn static_prop() -> u32 { | ||
32 | ||
} | ||
#[wasm_bindgen(setter)] | ||
pub fn set_static_prop(_value: u32) {} | ||
} | ||
|
||
pub struct NonWasmType; | ||
|
||
#[wasm_bindgen] | ||
impl NonWasmType { | ||
pub fn static_method() {} | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.