-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Implement impl Trait
in argument position (RFC1951, Universal quantification)
#45918
Commits on Nov 15, 2017
-
Move E0562 to librustc from librustc_typeck
With the check for impl trait moving from type checking to HIR lowering the error needs to move too.
Configuration menu - View commit details
-
Copy full SHA for 779fc37 - Browse repository at this point
Copy the full SHA 779fc37View commit details -
Split hir::TyImplTrait, move checks to HIR lowering
Replace hir::TyImplTrait with TyImplTraitUniversal and TyImplTraitExistential. Add an ImplTraitContext enum to rustc::hir::lowering to track the kind and allowedness of an impl Trait. Significantly alter lowering to thread ImplTraitContext and one other boolean parameter described below throughought much of lowering. The other parameter is for tracking if lowering a function is in a trait impl, as there is not enough information to otherwise know this information during lowering otherwise. This change also removes the checks from ast_ty_to_ty for impl trait allowedness as they are now all taking place in HIR lowering.
Configuration menu - View commit details
-
Copy full SHA for 8fd48e7 - Browse repository at this point
Copy the full SHA 8fd48e7View commit details -
Add bool item is_in_impl_trait to LoweringContext
This is for tracking if an ImplItem is part of a trait impl. Add a with_trait_impl_ref method to ItemLowerer to appropriately save the state to allow appropriate nesting of trait and non-trait impls.
Configuration menu - View commit details
-
Copy full SHA for e4c7e2c - Browse repository at this point
Copy the full SHA e4c7e2cView commit details -
Alter type collection to collect impl Trait bounds
In ast_generics extraction in generics_of and explicit_predicates_of, also collect inputs if there are any. Then use a Visitor to extract the necessary information from the TyImplTraitUniversal types before extending generics and predicates with the new information.
Configuration menu - View commit details
-
Copy full SHA for 94df3c5 - Browse repository at this point
Copy the full SHA 94df3c5View commit details -
Configuration menu - View commit details
-
Copy full SHA for f225fe4 - Browse repository at this point
Copy the full SHA f225fe4View commit details -
Add new error comparision to hide desugaring
First some background: To the compiler, the following two signatures in the trait vs the impl are the same. ```rust trait Foo { fn foo(&self, &impl Debug); } impl Foo for () { fn foo<U: Debug>(&self, x: &U) { ... } } ``` We do not want to allow this, and so we add a new error and check. The check just tests that all paramters 'syntheticness' match up. As during collection, the impl Trait parameters are transformed into anonymous synthetic generics. Furthermore, causes a check for unused type parameters to be skipped in check_bounds_are_used if there is already a TyError. Thus, an unused input will not trigger `type parameter unused` errors. Update the one test that checked for this error in the case of a TyError.
Configuration menu - View commit details
-
Copy full SHA for 109f2dd - Browse repository at this point
Copy the full SHA 109f2ddView commit details -
Add universal_impl_trait feature gate
Move feature gate check to inside HIR lowering. Change error messages and update tests.
Configuration menu - View commit details
-
Copy full SHA for bdff946 - Browse repository at this point
Copy the full SHA bdff946View commit details -
Configuration menu - View commit details
-
Copy full SHA for 06dff80 - Browse repository at this point
Copy the full SHA 06dff80View commit details -
Configuration menu - View commit details
-
Copy full SHA for a23bea5 - Browse repository at this point
Copy the full SHA a23bea5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d25d2e - Browse repository at this point
Copy the full SHA 7d25d2eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 04ad8fd - Browse repository at this point
Copy the full SHA 04ad8fdView commit details -
Configuration menu - View commit details
-
Copy full SHA for b4c1aef - Browse repository at this point
Copy the full SHA b4c1aefView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2520279 - Browse repository at this point
Copy the full SHA 2520279View commit details -
Configuration menu - View commit details
-
Copy full SHA for ebc4408 - Browse repository at this point
Copy the full SHA ebc4408View commit details -
extend
where-allowed.rs
with many more casesalso merge disallowed and disallowed-2 into that set
Configuration menu - View commit details
-
Copy full SHA for 37dd79f - Browse repository at this point
Copy the full SHA 37dd79fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 6f9fb91 - Browse repository at this point
Copy the full SHA 6f9fb91View commit details -
It'd be good to have a positive test for each case where it is allowed, I should think.
Configuration menu - View commit details
-
Copy full SHA for 9d71bf6 - Browse repository at this point
Copy the full SHA 9d71bf6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 15001ee - Browse repository at this point
Copy the full SHA 15001eeView commit details -
Configuration menu - View commit details
-
Copy full SHA for 2786ea6 - Browse repository at this point
Copy the full SHA 2786ea6View commit details -
Add proper names to impl Trait parameters.
Uses Symbol::intern and hir.node_to_pretty_string to create a name for the impl Trait parameter that is just impl and then a ' + ' separated list of bounds that the user typed.
Configuration menu - View commit details
-
Copy full SHA for 7e9948f - Browse repository at this point
Copy the full SHA 7e9948fView commit details -
Add requested comments, restructure some small bits of code. Fix extern declarations allowing impl Trait.
Configuration menu - View commit details
-
Copy full SHA for 9b4372e - Browse repository at this point
Copy the full SHA 9b4372eView commit details -
Disallow all impl Trait within Fn trait sugar
We already disallowed them to be in the arg list, such as Fn(impl Debug), but now we disallow Fn() -> impl Debug. Also remove the ImplTraitContext argument from the function lower_parenthesized_parameter_data as it is now unused. Comment out part of test run-pass/impl-trait/xcrate.rs that now fails.
Configuration menu - View commit details
-
Copy full SHA for b276429 - Browse repository at this point
Copy the full SHA b276429View commit details -
Configuration menu - View commit details
-
Copy full SHA for f710d41 - Browse repository at this point
Copy the full SHA f710d41View commit details -
Configuration menu - View commit details
-
Copy full SHA for 22f0940 - Browse repository at this point
Copy the full SHA 22f0940View commit details -
Configuration menu - View commit details
-
Copy full SHA for 517db79 - Browse repository at this point
Copy the full SHA 517db79View commit details -
Configuration menu - View commit details
-
Copy full SHA for 337dee4 - Browse repository at this point
Copy the full SHA 337dee4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 98d5db3 - Browse repository at this point
Copy the full SHA 98d5db3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4ce61b7 - Browse repository at this point
Copy the full SHA 4ce61b7View commit details