rust/src/libsyntax
bors 8df670b6a6 Auto merge of #43540 - petrochenkov:pathrelax, r=nikomatsakis
syntax: Relax path grammar

TLDR: Accept the disambiguator `::` in "type" paths (`Type::<Args>`), accept the disambiguator `::` before parenthesized generic arguments (`Fn::(Args)`).

The "turbofish" disambiguator `::<>` in expression paths is a necessary evil required for path parsing to be both simple and to give reasonable results.
Since paths in expressions usually refer to values (but not necessarily, e.g. `Struct::<u8> { field: 0 }` is disambiguated, but refers to a type), people often consider `::<>` to be inherent to *values*, and not *expressions* and want to write disambiguated paths for values even in contexts where disambiguation is not strictly necessary, for example when a path is passed to a macro `m!(Vec::<i32>::new)`.
The problem is that currently, if the disambiguator is not *required*, then it's *prohibited*. This results in confusion - see https://github.com/rust-lang/rust/issues/41740, https://internals.rust-lang.org/t/macro-path-uses-novel-syntax/5561.

This PR makes the disambiguator *optional* instead of prohibited in contexts where it's not strictly required, so people can pass paths to macros in whatever form they consider natural (e.g. disambiguated form for value paths).
This PR also accepts the disambiguator in paths with parenthesized arguments (`Fn::(Args)`) for consistency and to simplify testing of stuff like https://github.com/rust-lang/rust/pull/41856#issuecomment-301219194.

Closes https://github.com/rust-lang/rust/issues/41740

cc @rust-lang/lang
r? @nikomatsakis
2017-08-21 23:03:57 +00:00
..
diagnostics use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
ext Auto merge of #43540 - petrochenkov:pathrelax, r=nikomatsakis 2017-08-21 23:03:57 +00:00
parse Auto merge of #43540 - petrochenkov:pathrelax, r=nikomatsakis 2017-08-21 23:03:57 +00:00
print use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
util Update and fix a few tests 2017-06-26 02:08:14 +00:00
abi.rs add thiscall calling convention support 2017-05-24 16:40:03 -04:00
ast.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
attr.rs Include the closing paren to the span of ast::NestedMetaItem 2017-08-17 21:58:01 +09:00
build.rs rustc: Add some build scripts for librustc crates 2017-07-22 22:04:13 -07:00
Cargo.toml fix the easy features in libsyntax 2017-05-07 01:20:15 -07:00
codemap.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
config.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
diagnostic_list.rs extended information for E0557 feature has been removed 2017-08-09 01:33:50 -07:00
entry.rs Cleanup InternedString. 2016-11-21 09:00:56 +00:00
feature_gate.rs Stabilize rvalue promotion to 'static. 2017-08-16 20:30:56 +03:00
fold.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
json.rs Rollup merge of #43891 - Fourchaux:master, r=steveklabnik 2017-08-17 10:44:07 -04:00
lib.rs de-orphan extended information 2017-08-06 21:29:05 -07:00
ptr.rs Replace some matches with try. 2017-06-07 12:15:39 +09:00
show_span.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
std_inject.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
str.rs syntax: Copy unstable str::char_at into libsyntax 2015-04-21 10:23:53 -07:00
test.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
test_snippet.rs Position span label correctly when it isn't last 2017-06-15 11:21:19 -07:00
tokenstream.rs Review comments 2017-07-21 16:49:09 -07:00
visit.rs Store all generic arguments for method calls in AST 2017-07-10 00:20:25 +03:00