Skip to content
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

Added relax strategy parameter #102

Merged
merged 3 commits into from
Mar 15, 2021
Merged

Conversation

zesterer
Copy link
Collaborator

This currently has issues due to rust-lang/rust#50822. Event fairly mundane examples will not compile because the compiler does not infer the default parameter without a type annotation, and type namespace paths are not type annotations.

The following example...

let mylock = spin::Mutex::new(0);

...fails with...

error[E0282]: type annotations needed for `spin::Mutex<i32, R>`
 --> test.rs:1:14
  |
1 | let mylock = spin::Mutex::new(0);
  |     ------   ^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `R`
  |     |
  |     consider giving `mylock` the explicit type `spin::Mutex<i32, R>`, where the type parameter `R` is specified

error: aborting due to previous error

I'm undecided about what approach to use to solve this. Perhaps we should use a series of type aliases within the crate to specify a default Spin relax strategy, thereby avoiding major breakage for most users but allowing advanced users to opt-in, albeit through a more unconventional way of accessing the types?

@zesterer
Copy link
Collaborator Author

I've updated the branch to add the aforementioned type aliases. This should avoid compiler errors for ordinary users. Advanced users can switch relax strategy by using the fully-qualified path for a lock.

@zesterer zesterer merged commit be400c1 into mvdnes:master Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant