about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-06-01 14:13:57 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-06-01 14:13:57 -0700
commite275f2caf62b452913b301a31a2877d3f2f0711b (patch)
treef5b85ab738a72152c2e004b5c4e2c2ff7c80a60c /src/libsyntax/parse
parentad0d3b5d4064cfd9013c498299a53b3f1586553e (diff)
downloadrust-e275f2caf62b452913b301a31a2877d3f2f0711b.tar.gz
rust-e275f2caf62b452913b301a31a2877d3f2f0711b.zip
Extend docstring
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/diagnostics.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs
index 138b2ccfe35..71d074b99ec 100644
--- a/src/libsyntax/parse/diagnostics.rs
+++ b/src/libsyntax/parse/diagnostics.rs
@@ -1234,6 +1234,13 @@ impl<'a> Parser<'a> {
     }
 
     /// Replace duplicated recovered arguments with `_` pattern to avoid unecessary errors.
+    ///
+    /// This is necessary because at this point we don't know whether we parsed a function with
+    /// anonymous arguments or a function with names but no types. In order to minimize
+    /// unecessary errors, we assume the arguments are in the shape of `fn foo(a, b, c)` where
+    /// the arguments are *names* (so we don't emit errors about not being able to find `b` in
+    /// the local scope), but if we find the same name multiple times, like in `fn foo(i8, i8)`,
+    /// we deduplicate them to not complain about duplicated argument names.
     crate fn deduplicate_recovered_arg_names(&self, fn_inputs: &mut Vec<Arg>) {
         let mut seen_inputs = FxHashSet::default();
         for input in fn_inputs.iter_mut() {