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

syntax: Tweak parsing bounds on generics paths #13079

Merged
merged 1 commit into from
Mar 27, 2014

Conversation

alexcrichton
Copy link
Member

The previous syntax was Foo:Bound<trait-parameters>, but this is a little
ambiguous because it was being parsed as Foo: (Bound<trait-parameters) rather
than Foo: (Bound) <trait-parameters>

This commit changes the syntax to Foo<trait-parameters>: Bound in order to be
clear where the trait parameters are going.

Closes #9265

fn foo1<T>(_: &A<T>: Send) {}
fn foo2<T>(_: ~A<T>: Send + Freeze) {}
fn foo3<T>(_: ~B<int, uint>: 'static) {}
fn foo4<'a, T>(_: ~C<'a, T>: 'static + Send) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to cover one more case, could you add a test with a mod path? Something like: mymod::D<'a, T>: Share + Send

@flaper87
Copy link
Contributor

I like this change. Makes it more consistent and intuitive, IMHO. 👍

@huonw
Copy link
Member

huonw commented Mar 22, 2014

@flaper87 the best part is how it makes bounded generic trait objects work. ;)

The previous syntax was `Foo:Bound<trait-parameters>`, but this is a little
ambiguous because it was being parsed as `Foo: (Bound<trait-parameters)` rather
than `Foo: (Bound) <trait-parameters>`

This commit changes the syntax to `Foo<trait-parameters>: Bound` in order to be
clear where the trait parameters are going.

Closes rust-lang#9265
bors added a commit that referenced this pull request Mar 27, 2014
The previous syntax was `Foo:Bound<trait-parameters>`, but this is a little
ambiguous because it was being parsed as `Foo: (Bound<trait-parameters)` rather
than `Foo: (Bound) <trait-parameters>`

This commit changes the syntax to `Foo<trait-parameters>: Bound` in order to be
clear where the trait parameters are going.

Closes #9265
@bors bors closed this Mar 27, 2014
@bors bors merged commit 8118406 into rust-lang:master Mar 27, 2014
@alexcrichton alexcrichton deleted the colons branch March 27, 2014 20:15
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this pull request Sep 13, 2022
Remove type alias definition on inline

Fix rust-lang#13079
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 11, 2024
…idance, r=y21

Fix guidance of [`float_cmp`] and [`float_cmp_const`] to not incorrectly recommend `f__::EPSILON` as the error margin.

Using `f32::EPSILON` or `f64::EPSILON` as the floating-point equality comparison error margin is incorrect, yet `float_cmp` has until now recommended this be done. This change fixes the given guidance (both in docs and compiler hints) to not reference these unsuitable constants.

Instead, the guidance now clarifies that the scenarios in which an absolute error margin is usable, provides a sample implementation for using a user-defined absolute error margin (as an absolute error margin can only be used-defined and may be different for different comparisons) and references the floating point guide for a reference implementation of relative error based equality comparison for cases where absolute error margins cannot be identified.

changelog: [`float_cmp`] Fix guidance to not incorrectly recommend `f__::EPSILON` as the error margin.
changelog: [`float_cmp_const`] Fix guidance to not incorrectly recommend `f__::EPSILON` as the error margin.

Fixes rust-lang#6816
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.

No syntax for type of boxed trait with a kind bound and a generic parameter
4 participants