about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2018-08-22 17:45:39 +0200
committerGitHub <noreply@github.com>2018-08-22 17:45:39 +0200
commitef4b2edbd757bb5042875bc5b1eeebb45bbaea22 (patch)
tree6fde2a439d74c63ed1566c0e72acbd6373759518 /src
parent95bdc6589b44da7abb58dce6abe33ab3c7e5d8ee (diff)
parent3d5fef6f3001beeffde80b57658809fe383ea242 (diff)
downloadrust-ef4b2edbd757bb5042875bc5b1eeebb45bbaea22.tar.gz
rust-ef4b2edbd757bb5042875bc5b1eeebb45bbaea22.zip
Rollup merge of #53562 - varkor:bastion-of-the-turbofish, r=nagisa
Lament the invincibility of the Turbofish

Here a test case is added to ensure that any others attempting to drive the Turbofish to extinction have second thoughts. Previously the [entire test suite would succeed](https://github.com/rust-lang/rust/pull/53511) if generic arguments were accepted without disambiguation, making for [confusing and heartbreaking circumstances](https://github.com/rust-lang/rfcs/pull/2527).
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/bastion-of-the-turbofish.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ui/bastion-of-the-turbofish.rs b/src/test/ui/bastion-of-the-turbofish.rs
new file mode 100644
index 00000000000..bd789737552
--- /dev/null
+++ b/src/test/ui/bastion-of-the-turbofish.rs
@@ -0,0 +1,42 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-pass
+
+// Bastion of the Turbofish
+// ------------------------
+// Beware travellers, lest you venture into waters callous and unforgiving,
+// where hope must be abandoned, ere it is cruelly torn from you. For here
+// stands the bastion of the Turbofish: an impenetrable fortress holding
+// unshaking against those who would dare suggest the supererogation of the
+// Turbofish.
+//
+// Once I was young and foolish and had the impudence to imagine that I could
+// shake free from the coils by which that creature had us tightly bound. I
+// dared to suggest that there was a better way: a brighter future, in which
+// Rustaceans both new and old could be rid of that vile beast. But alas! In
+// my foolhardiness my ignorance was unveiled and my dreams were dashed
+// unforgivingly against the rock of syntactic ambiguity.
+//
+// This humble program, small and insignificant though it might seem,
+// demonstrates that to which we had previously cast a blind eye: an ambiguity
+// in permitting generic arguments to be provided without the consent of the
+// Great Turbofish. Should you be so naïve as to try to revolt against its
+// mighty clutches, here shall its wrath be indomitably displayed. This
+// program must pass for all eternity, fundamentally at odds with an impetuous
+// rebellion against the Turbofish.
+//
+// My heart aches in sorrow, for I know I am defeated. Let this be a warning
+// to all those who come after. Here stands the bastion of the Turbofish.
+
+fn main() {
+    let (oh, woe, is, me) = ("the", "Turbofish", "remains", "undefeated");
+    let _: (bool, bool) = (oh<woe, is>(me));
+}