]> git.lizzy.rs Git - rust.git/commitdiff
Typos and style fixes.
authorDiogo Sousa <diogogsousa@gmail.com>
Fri, 10 Aug 2018 17:13:43 +0000 (18:13 +0100)
committerDiogo Sousa <diogogsousa@gmail.com>
Sun, 30 Sep 2018 19:01:28 +0000 (20:01 +0100)
src/librustc/traits/auto_trait.rs
src/librustc/traits/fulfill.rs
src/librustc/traits/mod.rs
src/librustc/traits/select.rs
src/librustc_data_structures/obligation_forest/mod.rs
src/librustc_data_structures/obligation_forest/test.rs

index 8f106a08125386a56ee32998d2b3cbe0eeb554eb..79fc9b449238db0e2b16731ed56000ef65ca553c 100644 (file)
@@ -73,16 +73,16 @@ pub fn new(tcx: &'a TyCtxt<'a, 'tcx, 'tcx>) -> Self {
     /// ```
     /// struct Foo<T> { data: Box<T> }
     /// ```
-
+    ///
     /// then this might return that Foo<T>: Send if T: Send (encoded in the AutoTraitResult type).
     /// The analysis attempts to account for custom impls as well as other complex cases. This
     /// result is intended for use by rustdoc and other such consumers.
-
+    ///
     /// (Note that due to the coinductive nature of Send, the full and correct result is actually
     /// quite simple to generate. That is, when a type has no custom impl, it is Send iff its field
     /// types are all Send. So, in our example, we might have that Foo<T>: Send if Box<T>: Send.
     /// But this is often not the best way to present to the user.)
-
+    ///
     /// Warning: The API should be considered highly unstable, and it may be refactored or removed
     /// in the future.
     pub fn find_auto_trait_generics<A>(
@@ -288,7 +288,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
     // hold.
     //
     // One additional consideration is supertrait bounds. Normally, a ParamEnv is only ever
-    // consutrcted once for a given type. As part of the construction process, the ParamEnv will
+    // constructed once for a given type. As part of the construction process, the ParamEnv will
     // have any supertrait bounds normalized - e.g. if we have a type 'struct Foo<T: Copy>', the
     // ParamEnv will contain 'T: Copy' and 'T: Clone', since 'Copy: Clone'. When we construct our
     // own ParamEnv, we need to do this ourselves, through traits::elaborate_predicates, or else
index 19ee2c1aabfa47c8c0e9bd10b4f21b0a9ea920bd..0f330504334a6a38e4bf0e443af53b028c2a48b4 100644 (file)
@@ -45,7 +45,6 @@ fn as_predicate(&self) -> &Self::Predicate { &self.obligation.predicate }
 /// along. Once all type inference constraints have been generated, the
 /// method `select_all_or_error` can be used to report any remaining
 /// ambiguous cases as errors.
-
 pub struct FulfillmentContext<'tcx> {
     // A list of all obligations that have been registered with this
     // fulfillment context.
@@ -89,7 +88,7 @@ pub fn new_ignoring_regions() -> FulfillmentContext<'tcx> {
 
     /// Attempts to select obligations using `selcx`.
     fn select(&mut self, selcx: &mut SelectionContext<'a, 'gcx, 'tcx>)
-              -> Result<(),Vec<FulfillmentError<'tcx>>> {
+              -> Result<(), Vec<FulfillmentError<'tcx>>> {
         debug!("select(obligation-forest-size={})", self.predicates.len());
 
         let mut errors = Vec::new();
index 6b1092814a4043616ab8d119d5078c6c7c70359b..f394fbd9c7b4cd7b902dc8fe5d87052c45725e26 100644 (file)
@@ -644,7 +644,7 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     // have the errors get reported at a defined place (e.g.,
     // during typeck). Instead I have all parameter
     // environments, in effect, going through this function
-    // and hence potentially reporting errors. This ensurse of
+    // and hence potentially reporting errors. This ensures of
     // course that we never forget to normalize (the
     // alternative seemed like it would involve a lot of
     // manual invocations of this fn -- and then we'd have to
index ab71d13ab0686d1818257c8170ed3c3d456eb439..7e504094ad86f7d91db056c04ca7cca8089ff792 100644 (file)
@@ -582,7 +582,7 @@ pub fn select(&mut self, obligation: &TraitObligation<'tcx>)
         match self.confirm_candidate(obligation, candidate) {
             Err(SelectionError::Overflow) => {
                 assert!(self.query_mode == TraitQueryMode::Canonical);
-                return Err(SelectionError::Overflow);
+                Err(SelectionError::Overflow)
             },
             Err(e) => Err(e),
             Ok(candidate) => Ok(Some(candidate))
@@ -879,7 +879,7 @@ fn evaluate_stack<'o>(&mut self,
         // must be met of course). One obvious case this comes up is
         // marker traits like `Send`. Think of a linked list:
         //
-        //    struct List<T> { data: T, next: Option<Box<List<T>>> {
+        //    struct List<T> { data: T, next: Option<Box<List<T>>> }
         //
         // `Box<List<T>>` will be `Send` if `T` is `Send` and
         // `Option<Box<List<T>>>` is `Send`, and in turn
@@ -1407,7 +1407,7 @@ fn assemble_candidates<'o>(&mut self,
                                stack: &TraitObligationStack<'o, 'tcx>)
                                -> Result<SelectionCandidateSet<'tcx>, SelectionError<'tcx>>
     {
-        let TraitObligationStack { obligation, .. } = *stack;
+        let obligation = stack.obligation;
         let ref obligation = Obligation {
             param_env: obligation.param_env,
             cause: obligation.cause.clone(),
@@ -1788,9 +1788,9 @@ fn assemble_candidates_from_impls(&mut self,
     }
 
     fn assemble_candidates_from_auto_impls(&mut self,
-                                              obligation: &TraitObligation<'tcx>,
-                                              candidates: &mut SelectionCandidateSet<'tcx>)
-                                              -> Result<(), SelectionError<'tcx>>
+                                           obligation: &TraitObligation<'tcx>,
+                                           candidates: &mut SelectionCandidateSet<'tcx>)
+                                           -> Result<(), SelectionError<'tcx>>
     {
         // OK to skip binder here because the tests we do below do not involve bound regions
         let self_ty = *obligation.self_ty().skip_binder();
@@ -2433,7 +2433,7 @@ fn collect_predicates_for_types(&mut self,
     fn confirm_candidate(&mut self,
                          obligation: &TraitObligation<'tcx>,
                          candidate: SelectionCandidate<'tcx>)
-                         -> Result<Selection<'tcx>,SelectionError<'tcx>>
+                         -> Result<Selection<'tcx>, SelectionError<'tcx>>
     {
         debug!("confirm_candidate({:?}, {:?})",
                obligation,
@@ -2612,11 +2612,11 @@ fn vtable_auto_impl(&mut self,
         let mut obligations = self.collect_predicates_for_types(
             obligation.param_env,
             cause,
-            obligation.recursion_depth+1,
+            obligation.recursion_depth + 1,
             trait_def_id,
             nested);
 
-        let trait_obligations = self.in_snapshot(|this, snapshot| {
+        let trait_obligations: Vec<PredicateObligation<'_>> = self.in_snapshot(|this, snapshot| {
             let poly_trait_ref = obligation.predicate.to_poly_trait_ref();
             let (trait_ref, skol_map) =
                 this.infcx().skolemize_late_bound_regions(&poly_trait_ref);
@@ -2630,6 +2630,8 @@ fn vtable_auto_impl(&mut self,
                                            snapshot)
         });
 
+        // Adds the predicates from the trait.  Note that this contains a `Self: Trait`
+        // predicate as usual.  It won't have any effect since auto traits are coinductive.
         obligations.extend(trait_obligations);
 
         debug!("vtable_auto_impl: obligations={:?}", obligations);
index 7ef88852685d5bd33a836f193e20bad0b6834c2b..094c1cec31acce8847cc221139642c525e8d88b2 100644 (file)
@@ -187,7 +187,7 @@ fn register_obligation_at(&mut self, obligation: O, parent: Option<NodeIndex>)
                               -> Result<(), ()>
     {
         if self.done_cache.contains(obligation.as_predicate()) {
-            return Ok(())
+            return Ok(());
         }
 
         match self.waiting_cache.entry(obligation.as_predicate().clone()) {
@@ -269,8 +269,8 @@ pub fn process_obligations<P>(&mut self, processor: &mut P) -> Outcome<O, P::Err
                    self.nodes[index]);
 
             let result = match self.nodes[index] {
-                Node { state: ref _state, ref mut obligation, .. }
-                    if _state.get() == NodeState::Pending =>
+                Node { ref state, ref mut obligation, .. }
+                    if state.get() == NodeState::Pending =>
                 {
                     processor.process_obligation(obligation)
                 }
index 527a1ef0ec441052c60823cf079466316e330e90..c27a65e34310ff19e774a6d0029366d5ffeaa8f2 100644 (file)
@@ -59,8 +59,9 @@ fn process_obligation(&mut self,
 
     fn process_backedge<'c, I>(&mut self, _cycle: I,
                                _marker: PhantomData<&'c Self::Obligation>)
-        where I: Clone + Iterator<Item=&'c Self::Obligation> {
-        }
+        where I: Clone + Iterator<Item=&'c Self::Obligation>
+    {
+    }
 }
 
 
@@ -350,11 +351,8 @@ fn done_dependency() {
         }, |_|{}));
     assert_eq!(ok, vec!["(A,B,C): Sized"]);
     assert_eq!(err.len(), 0);
-
-
 }
 
-
 #[test]
 fn orphan() {
     // check that orphaned nodes are handled correctly