diff options
85 files changed, 941 insertions, 546 deletions
diff --git a/.mailmap b/.mailmap index 8eaf8f16e4b..317a92b8f43 100644 --- a/.mailmap +++ b/.mailmap @@ -7,142 +7,218 @@ Aaron Todd <github@opprobrio.us> Abhishek Chanda <abhishek.becs@gmail.com> Abhishek Chanda <abhishek@cloudscaling.com> +Adolfo Ochagavía <aochagavia92@gmail.com> +Adrien Tétar <adri-from-59@hotmail.fr> Ahmed Charles <ahmedcharles@gmail.com> <acharles@outlook.com> -Aydin Kim <ladinjin@hanmail.net> aydin.kim <aydin.kim@samsung.com> Alex Burka <durka42+github@gmail.com> Alex Burka <aburka@seas.upenn.edu> Alex Lyon <arcterus@mail.com> <Arcterus@mail.com> Alex Newman <posix4e@gmail.com> Alex HotShot Newman <posix4e@gmail.com> Alex Rønne Petersen <alex@lycus.org> +Alexander Light <allight@cs.brown.edu> Alexander Light <scialexlight@gmail.com> +Alexis Beingessner <a.beingessner@gmail.com> Alfie John <alfie@alfie.wtf> Alfie John <alfiej@fastmail.fm> +Anatoly Ikorsky <aikorsky@gmail.com> +Andre Bogus <bogusandre@gmail.com> Andreas Gal <gal@mozilla.com> <andreas.gal@gmail.com> Andrew Kuchev <0coming.soon@gmail.com> Andrew <0coming.soon@gmail.com> Andrew Poelstra <asp11@sfu.ca> <apoelstra@wpsoftware.net> Anton Löfgren <anton.lofgren@gmail.com> <alofgren@op5.com> -Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> arielb1 <arielb1@mail.tau.ac.il> +Areski Belaid <areski@gmail.com> areski <areski@gmail.com> Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> Ariel Ben-Yehuda <ariel.byd@gmail.com> +Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> arielb1 <arielb1@mail.tau.ac.il> Austin Seipp <mad.one@gmail.com> <as@hacks.yi.org> +Aydin Kim <ladinjin@hanmail.net> aydin.kim <aydin.kim@samsung.com> +Barosl Lee <vcs@barosl.com> Barosl LEE <github@barosl.com> Ben Alpert <ben@benalpert.com> <spicyjalapeno@gmail.com> -Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@bsago.me> Ben S <ogham@users.noreply.github.com> +Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@bsago.me> +Ben Sago <ogham@users.noreply.github.com> Ben S <ogham@users.noreply.github.com> Benjamin Jackman <ben@jackman.biz> +Bheesham Persaud <bheesham123@hotmail.com> Bheesham Persaud <bheesham.persaud@live.ca> Björn Steinbrink <bsteinbr@gmail.com> <B.Steinbrink@gmx.de> blake2-ppc <ulrik.sverdrup@gmail.com> <blake2-ppc> Boris Egorov <jightuse@gmail.com> <egorov@linux.com> +Brandon Sanderson <singingboyo@gmail.com> Brandon Sanderson <singingboyo@hotmail.com> +Brett Cannon <brett@python.org> Brett Cannon <brettcannon@users.noreply.github.com> Brian Anderson <banderson@mozilla.com> <andersrb@gmail.com> Brian Dawn <brian.t.dawn@gmail.com> +Brian Leibig <brian@brianleibig.com> Brian Leibig <brian.leibig@gmail.com> Carl-Anton Ingmarsson <mail@carlanton.se> <ca.ingmarsson@gmail.com> Carol (Nichols || Goulding) <carol.nichols@gmail.com> Carol Nichols <carol.nichols@gmail.com> +Carol (Nichols || Goulding) <carol.nichols@gmail.com> Carol Nichols <cnichols@thinkthroughmath.com> Carol Willing <carolcode@willingconsulting.com> Chris C Cerami <chrisccerami@users.noreply.github.com> Chris C Cerami <chrisccerami@gmail.com> Chris Pressey <cpressey@gmail.com> +Chris Thorn <chris@thorn.co> Chris Thorn <thorn@thoughtbot.com> Clark Gaebel <cg.wowus.cg@gmail.com> <cgaebel@mozilla.com> +Clinton Ryan <clint.ryan3@gmail.com> Corey Farwell <coreyf+rust@rwell.org> Corey Farwell <coreyf@rwell.org> Corey Richardson <corey@octayn.net> Elaine "See More" Nemo <corey@octayn.net> +Damien Schoof <damien.schoof@gmail.com> +Daniel Ramos <dan@daramos.com> David Klein <david.klein@baesystemsdetica.com> David Manescu <david.manescu@gmail.com> <dman2626@uni.sydney.edu.au> -Damien Schoof <damien.schoof@gmail.com> +David Ross <daboross@daboross.net> Derek Chiang <derekchiang93@gmail.com> Derek Chiang (Enchi Jiang) <derekchiang93@gmail.com> Diggory Hardy <diggory.hardy@gmail.com> Diggory Hardy <github@dhardy.name> Dylan Braithwaite <dylanbraithwaite1@gmail.com> <mail@dylanb.me> -Eduardo Bautista <me@eduardobautista.com> <mail@eduardobautista.com> +Dzmitry Malyshau <kvarkus@gmail.com> Eduardo Bautista <me@eduardobautista.com> <=> +Eduardo Bautista <me@eduardobautista.com> <mail@eduardobautista.com> Elliott Slaughter <elliottslaughter@gmail.com> <eslaughter@mozilla.com> Elly Fong-Jones <elly@leptoquark.net> Emily Dunham <edunham@mozilla.com> edunham <edunham@mozilla.com> -Eric Holk <eric.holk@gmail.com> <eholk@mozilla.com> Eric Holk <eric.holk@gmail.com> <eholk@cs.indiana.edu> +Eric Holk <eric.holk@gmail.com> <eholk@mozilla.com> Eric Holmes <eric@ejholmes.net> Eric Reed <ecreed@cs.washington.edu> <ereed@mozilla.com> Erick Tryzelaar <erick.tryzelaar@gmail.com> <etryzelaar@iqt.org> Evgeny Sologubov Falco Hirschenberger <falco.hirschenberger@gmail.com> <hirschen@itwm.fhg.de> Felix S. Klock II <pnkfelix@pnkfx.org> Felix S Klock II <pnkfelix@pnkfx.org> +Flaper Fesp <flaper87@gmail.com> +Florian Wilkens <mrfloya_github@outlook.com> Florian Wilkens <floya@live.de> Gareth Daniel Smith <garethdanielsmith@gmail.com> gareth <gareth@gareth-N56VM.(none)> +Gareth Daniel Smith <garethdanielsmith@gmail.com> Gareth Smith <garethdanielsmith@gmail.com> Georges Dubus <georges.dubus@gmail.com> <georges.dubus@compiletoi.net> -Graham Fawcett <fawcett@uwindsor.ca> <graham.fawcett@gmail.com> +Graham Fawcett <graham.fawcett@gmail.com> Graham Fawcett <fawcett@uwindsor.ca> Graydon Hoare <graydon@pobox.com> Graydon Hoare <graydon@mozilla.com> -Heather <heather@cynede.net> <Heather@cynede.net> +Guillaume Gomez <guillaume1.gomez@gmail.com> Heather <heather@cynede.net> <Cynede@Gentoo.org> +Heather <heather@cynede.net> <Heather@cynede.net> +Herman J. Radtke III <herman@hermanradtke.com> Herman J. Radtke III <hermanradtke@gmail.com> Ilyong Cho <ilyoan@gmail.com> +Ivan Ivaschenko <defuz.net@gmail.com> J. J. Weber <jjweber@gmail.com> Jakub Bukaj <jakub@jakub.cc> Jakub Bukaj <jakub@jakub.cc> <jakubw@jakubw.net> +Jakub Bukaj <jakub@jakub.cc> Jakub Bukaj <jakub.bukaj@yahoo.com> James Deng <cnjamesdeng@gmail.com> <cnJamesDeng@gmail.com> James Miller <bladeon@gmail.com> <james@aatch.net> -Jason Orendorff <jorendorff@mozilla.com> <jason@mozmac-2.local> +James Perry <james.austin.perry@gmail.com> +Jason Fager <jfager@gmail.com> Jason Orendorff <jorendorff@mozilla.com> <jason.orendorff@gmail.com> +Jason Orendorff <jorendorff@mozilla.com> <jason@mozmac-2.local> +Jason Toffaletti <toffaletti@gmail.com> Jason Toffaletti <jason@topsy.com> +Jauhien Piatlicki <jauhien@gentoo.org> Jauhien Piatlicki <jpiatlicki@zertisa.com> +Jay True <glacjay@gmail.com> Jeremy Letang <letang.jeremy@gmail.com> -Jihyun Yu <jihyun@nclab.kaist.ac.kr> jihyun <jihyun@nablecomm.com> -Jihyun Yu <jihyun@nclab.kaist.ac.kr> <yjh0502@gmail.com> -Johann Hofmann <mail@johann-hofmann.com> Johann <git@johann-hofmann.com> Johann Hofmann <git@johann-hofmann.com> +Jihyun Yu <j.yu@navercorp.com> <yjh0502@gmail.com> +Jihyun Yu <j.yu@navercorp.com> jihyun <jihyun@nablecomm.com> +Jihyun Yu <j.yu@navercorp.com> Jihyun Yu <jihyun@nclab.kaist.ac.kr> +Johann Hofmann <git@johann-hofmann.com> Johann <git@johann-hofmann.com> John Clements <clements@racket-lang.org> <clements@brinckerhoff.org> John Hodge <acessdev@gmail.com> John Hodge <tpg@mutabah.net> -Jorge Aparicio <japaric@linux.com> <japaricious@gmail.com> +John Kåre Alsaker <john.kare.alsaker@gmail.com> +John Talling <inrustwetrust@users.noreply.github.com> Jonathan Bailey <jbailey@mozilla.com> <jbailey@jbailey-20809.local> +Jonathan S <gereeter@gmail.com> Jonathan S <gereeter+code@gmail.com> +Jorge Aparicio <japaric@linux.com> <japaricious@gmail.com> +Joseph Martin <pythoner6@gmail.com> +João Oliveira <hello@jxs.pt> joaoxsouls <joaoxsouls@gmail.com> Junyoung Cho <june0.cho@samsung.com> Jyun-Yan You <jyyou.tw@gmail.com> <jyyou@cs.nctu.edu.tw> Kang Seonghoon <kang.seonghoon@mearie.org> <public+git@mearie.org> -Keegan McAllister <kmcallister@mozilla.com> <mcallister.keegan@gmail.com> +Keegan McAllister <mcallister.keegan@gmail.com> <kmcallister@mozilla.com> +Kevin Butler <haqkrs@gmail.com> Kyeongwoon Lee <kyeongwoon.lee@samsung.com> -Lee Wondong <wdlee91@gmail.com> Lee Jeffery <leejeffery@gmail.com> Lee Jeffery <lee@leejeffery.co.uk> +Lee Wondong <wdlee91@gmail.com> Lennart Kudling <github@kudling.de> +Léo Testard <leo.testard@gmail.com> Lindsey Kuper <lindsey@composition.al> <lindsey@rockstargirl.org> Lindsey Kuper <lindsey@composition.al> <lkuper@mozilla.com> -Luqman Aden <me@luqman.ca> <laden@mozilla.com> -Luqman Aden <me@luqman.ca> <laden@csclub.uwaterloo.ca> Luke Metz <luke.metz@students.olin.edu> +Luqman Aden <me@luqman.ca> <laden@csclub.uwaterloo.ca> +Luqman Aden <me@luqman.ca> <laden@mozilla.com> Makoto Nakashima <makoto.nksm+github@gmail.com> <makoto.nksm@gmail.com> Makoto Nakashima <makoto.nksm+github@gmail.com> gifnksm <makoto.nksm+github@gmail.com> -Markus Westerlind <marwes91@gmail.com> Markus <marwes91@gmail.com> +Makoto Nakashima <makoto.nksm+github@gmail.com> NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> +Marcell Pardavi <marcell.pardavi@gmail.com> Margaret Meyerhofer <mmeyerho@andrew.cmu.edu> <mmeyerho@andrew> Mark Sinclair <mark.edward.x@gmail.com> Mark Sinclair <mark.edward.x@gmail.com> =Mark Sinclair <=125axel125@gmail.com> +Markus Westerlind <marwes91@gmail.com> Markus <marwes91@gmail.com> Matej Lach <matej.lach@gmail.com> Matej Ľach <matej.lach@gmail.com> Matt Brubeck <mbrubeck@limpet.net> <mbrubeck@cs.hmc.edu> Matthew Auld <matthew.auld@intel.com> Matthew McPherrin <matthew@mcpherrin.ca> <matt@mcpherrin.ca> Matthijs Hofstra <thiezz@gmail.com> Michael Williams <m.t.williams@live.com> -Michael Woerister <michaelwoerister@gmail> <michaelwoerister@gmail.com> <michaelwoerister@posteo> Michael Woerister <michaelwoerister@posteo> +Michael Woerister <michaelwoerister@posteo> <michaelwoerister@gmail> +Mickaël Raybaud-Roig <raybaudroigm@gmail.com> m-r-r <raybaudroigm@gmail.com> Ms2ger <ms2ger@gmail.com> <Ms2ger@gmail.com> +Mukilan Thiagarajan <mukilanthiagarajan@gmail.com> +NAKASHIMA, Makoto <makoto.nksm+github@gmail.com> +Nathan Wilson <wilnathan@gmail.com> +Nathaniel Herman <nherman@post.harvard.edu> Nathaniel Herman <nherman@college.harvard.edu> Neil Pankey <npankey@gmail.com> <neil@wire.im> Nicholas Mazzuca <npmazzuca@gmail.com> Nicholas <npmazzuca@gmail.com> -Oliver Schneider <github6541940@oli-obk.de> <git1984941651981@oli-obk.de> <git1984941651981@oli-obk.de> Oliver 'ker' Schneider <rust19446194516@oli-obk.de> -Oliver Schneider <github6541940@oli-obk.de> Oliver Schneider <git1984941651981@oli-obk.de> Oliver Schneider <git-spam9815368754983@oli-obk.de> Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> +Nick Platt <platt.nicholas@gmail.com> +Nif Ward <nif.ward@gmail.com> +Oliver Schneider <oliver.schneider@kit.edu> oli-obk <github6541940@oli-obk.de> +Oliver Schneider <oliver.schneider@kit.edu> Oliver 'ker' Schneider <rust19446194516@oli-obk.de> +Oliver Schneider <oliver.schneider@kit.edu> Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> +Oliver Schneider <oliver.schneider@kit.edu> Oliver Schneider <git-spam9815368754983@oli-obk.de> +Oliver Schneider <oliver.schneider@kit.edu> Oliver Schneider <github333195615777966@oli-obk.de> +Oliver Schneider <oliver.schneider@kit.edu> Oliver Schneider <github6541940@oli-obk.de> Ožbolt Menegatti <ozbolt.menegatti@gmail.com> gareins <ozbolt.menegatti@gmail.com> Paul Faria <paul_faria@ultimatesoftware.com> Paul Faria <Nashenas88@gmail.com> Peer Aramillo Irizar <peer.aramillo.irizar@gmail.com> parir <peer.aramillo.irizar@gmail.com> Peter Elmers <peter.elmers@yahoo.com> <peter.elmers@rice.edu> +Peter Zotov <whitequark@whitequark.org> +Phil Dawes <phil@phildawes.net> Phil Dawes <pdawes@drw.com> Philipp Brüschweiler <blei42@gmail.com> <blei42@gmail.com> Philipp Brüschweiler <blei42@gmail.com> <bruphili@student.ethz.ch> -Pradeep Kumar <gohanpra@gmail.com> Przemysław Wesołek <jest@go.art.pl> Przemek Wesołek <jest@go.art.pl> +Rafael Ávila de Espíndola <respindola@mozilla.com> Rafael Avila de Espindola <espindola@dream.(none)> Ralph Giles <giles@thaumas.net> Ralph Giles <giles@mozilla.com> +Renato Riccieri Santos Zannon <renato@rrsz.com.br> Richard Diamond <wichard@vitalitystudios.com> <wichard@hahbee.co> Rob Arnold <robarnold@cs.cmu.edu> +Rob Arnold <robarnold@cs.cmu.edu> Rob Arnold <robarnold@68-26-94-7.pools.spcsdns.net> Robert Foss <dev@robertfoss.se> robertfoss <dev@robertfoss.se> Robert Gawdzik <rgawdzik@hotmail.com> Robert Gawdzik ☢ <rgawdzik@hotmail.com> Robert Millar <robert.millar@cantab.net> +Rohit Joshi <rohitjoshi@users.noreply.github.com> Rohit Joshi <rohit.joshi@capitalone.com> +Russell Johnston <rpjohnst@gmail.com> Ruud van Asseldonk <dev@veniogames.com> Ruud van Asseldonk <ruuda@google.com> Ryan Scheel <ryan.havvy@gmail.com> +S Pradeep Kumar <gohanpra@gmail.com> +Scott Olson <scott@solson.me> Scott Olson <scott@scott-olson.org> Sean Gillespie <sean.william.g@gmail.com> swgillespie <sean.william.g@gmail.com> Seonghyun Kim <sh8281.kim@samsung.com> Simon Barber-Dueck <sbarberdueck@gmail.com> Simon BD <simon@server> Simon Sapin <simon@exyr.org> <simon.sapin@exyr.org> +Simonas Kazlauskas <git@kazlauskas.me> Simonas Kazlauskas <github@kazlauskas.me> startling <tdixon51793@gmail.com> +Stepan Koltsov <stepan.koltsov@gmail.com> Stepan Koltsov <nga@yandex-team.ru> Steven Fackler <sfackler@gmail.com> <sfackler@palantir.com> Steven Stewart-Gallus <sstewartgallus00@langara.bc.ca> <sstewartgallus00@mylangara.bc.ca> +Stuart Pernsteiner <stuart@pernsteiner.org> Stuart Pernsteiner <spernsteiner@mozilla.com> Tamir Duberstein <tamird@gmail.com> Tamir Duberstein <tamird@squareup.com> +Tero Hänninen <lgvz@users.noreply.github.com> Tero Hänninen <tejohann@kapsi.fi> +Theo Belaire <theo.belaire@gmail.com> Theo Belaire <tyr.god.of.war.42@gmail.com> Thiago Pontes <email@thiago.me> thiagopnts <thiagopnts@gmail.com> +Thomas Bracht Laumann Jespersen <laumann.thomas@gmail.com> Ticki <Ticki@users.noreply.github.com> Ticki <@> +Tim Brooks <brooks@cern.ch> Tim Brooks <tim.brooks@staples.com> Tim Chevalier <chevalier@alum.wellesley.edu> <catamorphism@gmail.com> +Tim JIANG <p90eri@gmail.com> +Tim Joseph Dumol <tim@timdumol.com> Torsten Weber <TorstenWeber12@gmail.com> <torstenweber12@gmail.com> -Ulrik Sverdrup <bluss@users.noreply.github.com> Ulrik Sverdrup <root@localhost> +Ty Overby <ty@pre-alpha.com> +Ulrik Sverdrup <bluss@users.noreply.github.com> bluss <bluss> Ulrik Sverdrup <bluss@users.noreply.github.com> bluss <bluss@users.noreply.github.com> bluss <bluss> +Ulrik Sverdrup <bluss@users.noreply.github.com> Ulrik Sverdrup <root@localhost> +Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Vadim Petrochenkov <vadim.petrochenkov@gmail.com> petrochenkov <vadim.petrochenkov@gmail.com> Vitali Haravy <HumaneProgrammer@gmail.com> Vitali Haravy <humaneprogrammer@gmail.com> William Ting <io@williamting.com> <william.h.ting@gmail.com> -Xuefeng Wu <benewu@gmail.com> Xuefeng Wu <xfwu@thoughtworks.com> XuefengWu <benewu@gmail.com> +Xuefeng Wu <benewu@gmail.com> Xuefeng Wu <xfwu@thoughtworks.com> +Xuefeng Wu <benewu@gmail.com> XuefengWu <benewu@gmail.com> +York Xiang <bombless@126.com> Youngsoo Son <ysson83@gmail.com> <ysoo.son@samsung.com> +Zach Pomerantz <zmp@umich.edu> Zack Corr <zack@z0w0.me> <zackcorr95@gmail.com> Zack Slayton <zack.slayton@gmail.com> +Zbigniew Siciarz <zbigniew@siciarz.net> Zbigniew Siciarz <antyqjon@gmail.com> diff --git a/AUTHORS.txt b/AUTHORS.txt index 5f316744021..b7fa4a5a4a7 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -98,7 +98,6 @@ Anton Löfgren <anton.lofgren@gmail.com> Antti Keränen <detegr@gmail.com> Aram Visser <aramvisser@gmail.com> arcnmx <arcnmx@users.noreply.github.com> -Arcterus <Arcterus@mail.com> Areski Belaid <areski@gmail.com> Ariel Ben-Yehuda <arielb1@mail.tau.ac.il> Arjan Topolovec <arjan.top@gmail.com> @@ -136,7 +135,6 @@ Ben Gesoff <ben.gesoff@gmail.com> Ben Harris <mail@bharr.is> Ben Kelly <ben@wanderview.com> Ben Noordhuis <info@bnoordhuis.nl> -Ben S <ogham@users.noreply.github.com> Ben Sago <ogham@users.noreply.github.com> Ben Striegel <ben.striegel@gmail.com> benaryorg <binary@benary.org> @@ -434,7 +432,6 @@ Gábor Horváth <xazax.hun@gmail.com> Gábor Lehel <glaebhoerl@gmail.com> Gabriel <g2p.code@gmail.com> gamazeps <gamaz3ps@gmail.com> -gareth <gareth@gareth-N56VM.(none)> Gareth Daniel Smith <garethdanielsmith@gmail.com> Garming Sam <garming_sam@outlook.com> Garrett Heel <garrettheel@gmail.com> @@ -495,7 +492,6 @@ Igor Strebezhev <xamgore@ya.ru> Ilya Dmitrichenko <ilya@xively.com> Ilyong Cho <ilyoan@gmail.com> Ingo Blechschmidt <iblech@web.de> -inrustwetrust <inrustwetrust@users.noreply.github.com> Irving A.J. Rivas Z. <axel.rivas@gmail.com> Isaac Aggrey <isaac.aggrey@gmail.com> Isaac Dupree <antispam@idupree.com> @@ -733,7 +729,6 @@ Liam Monahan <liam@monahan.io> Liigo Zhuang <com.liigo@gmail.com> Lindsey Kuper <lindsey@composition.al> Lionel Flandrin <lionel.flandrin@parrot.com> -llogiq <bogusandre@gmail.com> Logan Chien <tzuhsiang.chien@gmail.com> Loïc Damien <loic.damien@dzamlo.ch> Lorenz <lorenzb@student.ethz.ch> @@ -760,7 +755,7 @@ Manuel Hoffmann <manuel@polythematik.de> Marc-Antoine Perennou <Marc-Antoine@Perennou.com> Marcel Müller <neikos@neikos.email> Marcel Rodrigues <marcelgmr@gmail.com> -marcell <marcell.pardavi@gmail.com> +Marcell Pardavi <marcell.pardavi@gmail.com> Marcello Seri <marcello.seri@gmail.com> Marcus Klaas <mail@marcusklaas.nl> Margaret Meyerhofer <mmeyerho@andrew.cmu.edu> @@ -924,9 +919,7 @@ Oak <White-Oak@users.noreply.github.com> OGINO Masanori <masanori.ogino@gmail.com> OlegTsyba <idethrone1@gmail.com> Oliver Schneider <git1984941651981@oli-obk.de> -Oliver Schneider <github6541940@oli-obk.de> -Oliver Schneider <git-spam9815368754983@oli-obk.de> -Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> +Oliver Schneider <oliver.schneider@kit.edu> Olivier Saut <osaut@airpost.net> olivren <o.renaud@gmx.fr> Olle Jonsson <olle.jonsson@gmail.com> @@ -937,7 +930,6 @@ Oren Hazi <oren.hazi@gmail.com> Orphée Lafond-Lummis <o@orftz.com> Orpheus Lummis <o@orpheuslummis.com> osa1 <omeragacan@gmail.com> -Overmind JIANG <p90eri@gmail.com> Ožbolt Menegatti <ozbolt.menegatti@gmail.com> P1start <rewi-github@whanau.org> Pablo Brasero <pablo@pablobm.com> @@ -978,7 +970,6 @@ Peter Schuller <peter.schuller@infidyne.com> Peter Williams <peter@newton.cx> Peter Zotov <whitequark@whitequark.org> Petter Remen <petter.remen@gmail.com> -pez <james.austin.perry@gmail.com> Phil Dawes <phil@phildawes.net> Phil Ruffwind <rf@rufflewind.com> Philip Munksgaard <pmunksgaard@gmail.com> @@ -1065,7 +1056,6 @@ Ryan Pendleton <me@ryanp.me> Ryan Prichard <ryan.prichard@gmail.com> Ryan Riginding <marc.riginding@gmail.com> Ryan Scheel <ryan.havvy@gmail.com> -Ryman <haqkrs@gmail.com> Ryo Munakata <afpacket@gmail.com> S Pradeep Kumar <gohanpra@gmail.com> Sae-bom Kim <sae-bom.kim@samsung.com> @@ -1153,7 +1143,6 @@ Swaroop C H <swaroop@swaroopch.com> Sylvestre Ledru <sylvestre@debian.org> Taliesin Beynon <taliesinb@wolfram.com> Tamir Duberstein <tamird@gmail.com> -Tamir Duberstein <tamird@squareup.com> Taras Shpot <mrshpot@gmail.com> tav <tav@espians.com> Taylor Hutchison <seanthutchison@gmail.com> @@ -1169,7 +1158,6 @@ Thiago Pontes <email@thiago.me> Thomas Backman <serenity@exscape.org> Thomas Bracht Laumann Jespersen <laumann.thomas@gmail.com> Thomas Daede <daede003@umn.edu> -Thomas Jespersen <laumann.thomas@gmail.com> Thomas Karpiniec <tk@1.21jiggawatts.net> Tiago Nobrega <tigarmo@gmail.com> Tibor Benke <ihrwein@gmail.com> @@ -1255,7 +1243,6 @@ Wei-Ming Yang <rick68@users.noreply.github.com> Wendell Smith <wendell.smith@yale.edu> Wesley Wiser <wwiser@gmail.com> whataloadofwhat <unusualmoniker@gmail.com> -whitequark <whitequark@whitequark.org> wickerwaka <martin.donlon@gmail.com> Wilfred Hughes <me@wilfred.me.uk> Will <will@glozer.net> @@ -1275,8 +1262,6 @@ Xavier Shay <xavier@rhnh.net> Xiao Chuan Yu <xcyu.se@gmail.com> Xue Fuqiao <xfq.free@gmail.com> Xuefeng Wu <benewu@gmail.com> -Xuefeng Wu <xfwu@thoughtworks.com> -XuefengWu <benewu@gmail.com> Yasuhiro Fujii <y-fujii@mimosa-pudica.net> YawarRaza7349 <YawarRaza7349@gmail.com> Yazhong Liu <yorkiefixer@gmail.com> diff --git a/mk/docs.mk b/mk/docs.mk index 644fbde323c..b0872c88c14 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -22,14 +22,14 @@ # L10N_LANGS are the languages for which the docs have been # translated. ###################################################################### -DOCS := index intro tutorial \ +DOCS := index \ complement-lang-faq complement-design-faq complement-project-faq \ rustdoc reference grammar # Legacy guides, preserved for a while to reduce the number of 404s DOCS += guide-crates guide-error-handling guide-ffi guide-macros guide \ guide-ownership guide-plugins guide-pointers guide-strings guide-tasks \ - guide-testing + guide-testing tutorial intro RUSTDOC_DEPS_reference := doc/full-toc.inc diff --git a/mk/platform.mk b/mk/platform.mk index b8058882f9d..e6669f5c58d 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -14,7 +14,7 @@ # would create a variable HOST_i686-darwin-macos with the value # i386. define DEF_HOST_VAR - HOST_$(1) = $(subst i686,i386,$(word 1,$(subst -, ,$(1)))) + HOST_$(1) = $(patsubst i%86,i386,$(word 1,$(subst -, ,$(1)))) endef $(foreach t,$(CFG_TARGET),$(eval $(call DEF_HOST_VAR,$(t)))) $(foreach t,$(CFG_TARGET),$(info cfg: host for $(t) is $(HOST_$(t)))) @@ -214,9 +214,11 @@ define CFG_MAKE_TOOLCHAIN # On OpenBSD, we need to pass the path of libstdc++.so to the linker # (use path of libstdc++.a which is a known name for the same path) ifeq ($(OSTYPE_$(1)),unknown-openbsd) - RUSTC_FLAGS_$(1)=-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \ - -print-file-name=lib$(CFG_STDCPP_NAME).a))" \ - $(RUSTC_FLAGS_$(1)) + STDCPP_LIBDIR_RUSTFLAGS_$(1)= \ + -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \ + -print-file-name=lib$(CFG_STDCPP_NAME).a))" + else + STDCPP_LIBDIR_RUSTFLAGS_$(1)= endif # On Bitrig, we need the relocation model to be PIC for everything diff --git a/mk/target.mk b/mk/target.mk index ae9fd9d1ada..a88f0a33c07 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -95,6 +95,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \ $$(RUSTFLAGS_$(4)) \ $$(RUSTFLAGS$(1)_$(4)) \ $$(RUSTFLAGS$(1)_$(4)_T_$(2)) \ + $$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) \ --out-dir $$(@D) \ -C extra-filename=-$$(CFG_FILENAME_EXTRA) \ $$< @@ -128,7 +129,9 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \ $$(TSREQ$(1)_T_$(2)_H_$(3)) \ | $$(TBIN$(1)_T_$(2)_H_$(3))/ @$$(call E, rustc: $$@) - $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4) + $$(STAGE$(1)_T_$(2)_H_$(3)) \ + $$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) \ + -o $$@ $$< --cfg $(4) endef diff --git a/mk/tests.mk b/mk/tests.mk index 73aec5de8da..3a0aee77d68 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -393,7 +393,8 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \ $$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \ -L "$$(RT_OUTPUT_DIR_$(2))" \ $$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \ - $$(RUSTFLAGS_$(4)) + $$(RUSTFLAGS_$(4)) \ + $$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) endef @@ -663,9 +664,9 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --android-cross-path=$(CFG_ANDROID_CROSS_PATH) \ --adb-path=$(CFG_ADB) \ --adb-test-dir=$(CFG_ADB_TEST_DIR) \ - --host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \ + --host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(3))" \ --lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \ - --target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \ + --target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(2))" \ $$(CTEST_TESTARGS) ifdef CFG_VALGRIND_RPASS diff --git a/src/doc/index.md b/src/doc/index.md index 992b6eef5e8..5f2ef610729 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -14,9 +14,8 @@ concepts. Upon completing the book, you'll be an intermediate Rust developer, and will have a good grasp of the fundamental ideas behind Rust. -[Rust By Example][rbe] was originally a community resource, but was then -donated to the Rust project. As the name implies, it teaches you Rust through a -series of small examples. +[Rust By Example][rbe] teaches you Rust through a series of small +examples. [rbe]: http://rustbyexample.com/ @@ -32,49 +31,21 @@ library](std/index.html). There's a list of crates on the left with more specific sections, or you can use the search bar at the top to search for something if you know its name. +# The Rustonomicon + +[The Rustonomicon] is an entire book dedicated to explaining +how to write `unsafe` Rust code. It is for advanced Rust programmers. + +[The Rustonomicon]: nomicon/index.html + # Tools -[Cargo](https://crates.io) is the Rust's package manager providing access to libraries +[Cargo](http://doc.crates.io/index.html) is the Rust package manager providing access to libraries beyond the standard one, and its website contains lots of good documentation. [`rustdoc`](book/documentation.html) is the Rust's documentation generator, a tool converting annotated source code into HTML docs. -A bunch of non-official tools are available, such as [Racer](https://github.com/phildawes/racer) -(code completion engine), or [rustfmt](https://github.com/nrc/rustfmt) (source code formatter), -or text editor plugins. - -# Community & Getting Help - -If you need help with something, or just want to talk about Rust with others, -there are a few places you can do that: - -The Rust IRC channels on [irc.mozilla.org](irc://irc.mozilla.org/) are the -fastest way to get help. -[`#rust`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust) is -the general discussion channel, and you'll find people willing to help you with -any questions you may have. - -There are also three specialty channels: -[`#rust-gamedev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev) -and -[`#rust-osdev`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-osdev) -are for game development and operating system development, respectively. -There's also -[`#rust-internals`](http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-internals), which is for discussion of the development of Rust itself. - -You can also get help on [Stack -Overflow](https://stackoverflow.com/questions/tagged/rust). Searching for your -problem might reveal someone who has asked it before! - -There is an active [subreddit](https://reddit.com/r/rust) with lots of -discussion and news about Rust. - -There is also a [user forum](https://users.rust-lang.org), for all -user-oriented discussion, and a [developer -forum](https://internals.rust-lang.org/), where the development of Rust -itself is discussed. - # FAQs There are questions that are asked quite often, so we've made FAQs for them: diff --git a/src/doc/nomicon/other-reprs.md b/src/doc/nomicon/other-reprs.md index e361fbb7ae8..2639c1d4d6f 100644 --- a/src/doc/nomicon/other-reprs.md +++ b/src/doc/nomicon/other-reprs.md @@ -26,6 +26,9 @@ still consumes a byte of space. * DSTs, tuples, and tagged unions are not a concept in C and as such are never FFI safe. +* Tuple structs are like structs with regards to `repr(C)`, as the only + difference from a struct is that the fields aren’t named. + * **If the type would have any [drop flags], they will still be added** * This is equivalent to one of `repr(u*)` (see the next section) for enums. The diff --git a/src/doc/nomicon/unbounded-lifetimes.md b/src/doc/nomicon/unbounded-lifetimes.md index 2c5ba79a507..1f2961b5861 100644 --- a/src/doc/nomicon/unbounded-lifetimes.md +++ b/src/doc/nomicon/unbounded-lifetimes.md @@ -32,6 +32,5 @@ Within a function, bounding lifetimes is more error-prone. The safest and easies way to bound a lifetime is to return it from a function with a bound lifetime. However if this is unacceptable, the reference can be placed in a location with a specific lifetime. Unfortunately it's impossible to name all lifetimes involved -in a function. To get around this, you can in principle use `copy_lifetime`, though -these are unstable due to their awkward nature and questionable utility. +in a function. diff --git a/src/doc/reference.md b/src/doc/reference.md index de9352a4275..b1aa400d1e2 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -147,11 +147,11 @@ a form of constant expression, so is evaluated (primarily) at compile time. | | Example | `#` sets | Characters | Escapes | |----------------------------------------------|-----------------|------------|-------------|---------------------| -| [Character](#character-literals) | `'H'` | `N/A` | All Unicode | `\'` & [Byte](#byte-escapes) & [Unicode](#unicode-escapes) | -| [String](#string-literals) | `"hello"` | `N/A` | All Unicode | `\"` & [Byte](#byte-escapes) & [Unicode](#unicode-escapes) | +| [Character](#character-literals) | `'H'` | `N/A` | All Unicode | [Quote](#quote-escapes) & [Byte](#byte-escapes) & [Unicode](#unicode-escapes) | +| [String](#string-literals) | `"hello"` | `N/A` | All Unicode | [Quote](#quote-escapes) & [Byte](#byte-escapes) & [Unicode](#unicode-escapes) | | [Raw](#raw-string-literals) | `r#"hello"#` | `0...` | All Unicode | `N/A` | -| [Byte](#byte-literals) | `b'H'` | `N/A` | All ASCII | `\'` & [Byte](#byte-escapes) | -| [Byte string](#byte-string-literals) | `b"hello"` | `N/A` | All ASCII | `\"` & [Byte](#byte-escapes) | +| [Byte](#byte-literals) | `b'H'` | `N/A` | All ASCII | [Quote](#quote-escapes) & [Byte](#byte-escapes) | +| [Byte string](#byte-string-literals) | `b"hello"` | `N/A` | All ASCII | [Quote](#quote-escapes) & [Byte](#byte-escapes) | | [Raw byte string](#raw-byte-string-literals) | `br#"hello"#` | `0...` | All ASCII | `N/A` | ##### Byte escapes @@ -163,12 +163,19 @@ a form of constant expression, so is evaluated (primarily) at compile time. | `\r` | Carriage return | | `\t` | Tab | | `\\` | Backslash | +| `\0` | Null | ##### Unicode escapes | | Name | |---|------| | `\u{7FFF}` | 24-bit Unicode character code (up to 6 digits) | +##### Quote escapes +| | Name | +|---|------| +| `\'` | Single quote | +| `\"` | Double quote | + ##### Numbers | [Number literals](#number-literals)`*` | Example | Exponentiation | Suffixes | @@ -2415,9 +2422,9 @@ in meaning to declaring the item outside the statement block. > **Note**: there is no implicit capture of the function's dynamic environment when > declaring a function-local item. -#### Variable declarations +#### `let` statements -A _variable declaration_ introduces a new set of variable, given by a pattern. The +A _`let` statement_ introduces a new set of variables, given by a pattern. The pattern may be followed by a type annotation, and/or an initializer expression. When no type annotation is given, the compiler will infer the type, or signal an error if insufficient type information is available for definite inference. @@ -3190,10 +3197,11 @@ let message = match maybe_digit { ### `if let` expressions -An `if let` expression is semantically identical to an `if` expression but in place -of a condition expression it expects a refutable let statement. If the value of the -expression on the right hand side of the let statement matches the pattern, the corresponding -block will execute, otherwise flow proceeds to the first `else` block that follows. +An `if let` expression is semantically identical to an `if` expression but in +place of a condition expression it expects a `let` statement with a refutable +pattern. If the value of the expression on the right hand side of the `let` +statement matches the pattern, the corresponding block will execute, otherwise +flow proceeds to the first `else` block that follows. ``` let dish = ("Ham", "Eggs"); @@ -3211,11 +3219,11 @@ if let ("Ham", b) = dish { ### `while let` loops -A `while let` loop is semantically identical to a `while` loop but in place of a -condition expression it expects a refutable let statement. If the value of the -expression on the right hand side of the let statement matches the pattern, the -loop body block executes and control returns to the pattern matching statement. -Otherwise, the while expression completes. +A `while let` loop is semantically identical to a `while` loop but in place of +a condition expression it expects `let` statement with a refutable pattern. If +the value of the expression on the right hand side of the `let` statement +matches the pattern, the loop body block executes and control returns to the +pattern matching statement. Otherwise, the while expression completes. ### `return` expressions diff --git a/src/doc/trpl/ffi.md b/src/doc/trpl/ffi.md index 7a58a327b9f..d949bf33b6e 100644 --- a/src/doc/trpl/ffi.md +++ b/src/doc/trpl/ffi.md @@ -8,6 +8,23 @@ foreign code. Rust is currently unable to call directly into a C++ library, but snappy includes a C interface (documented in [`snappy-c.h`](https://github.com/google/snappy/blob/master/snappy-c.h)). +## A note about libc + +Many of these examples use [the `libc` crate][libc], which provides various +type definitions for C types, among other things. If you’re trying these +examples yourself, you’ll need to add `libc` to your `Cargo.toml`: + +```toml +[dependencies] +libc = "0.2.0" +``` + +[libc]: https://crates.io/crates/libc + +and add `extern crate libc;` to your crate root. + +## Calling foreign functions + The following is a minimal example of calling a foreign function which will compile if snappy is installed: diff --git a/src/doc/trpl/lifetimes.md b/src/doc/trpl/lifetimes.md index 13265ab1eba..68bbd0c9899 100644 --- a/src/doc/trpl/lifetimes.md +++ b/src/doc/trpl/lifetimes.md @@ -116,7 +116,8 @@ reference to an `i32` with the lifetime `'a`’. # In `struct`s -You’ll also need explicit lifetimes when working with [`struct`][structs]s: +You’ll also need explicit lifetimes when working with [`struct`][structs]s that +contain references: ```rust struct Foo<'a> { diff --git a/src/doc/trpl/ownership.md b/src/doc/trpl/ownership.md index d8ef44b782a..17b263ef00a 100644 --- a/src/doc/trpl/ownership.md +++ b/src/doc/trpl/ownership.md @@ -187,7 +187,7 @@ fn change_truth(x: bool) -> bool { } ``` -If we would have used types that do not implement the `Copy` trait, +If we had used types that do not implement the `Copy` trait, we would have gotten a compile error because we tried to use a moved value. ```text diff --git a/src/doc/trpl/the-stack-and-the-heap.md b/src/doc/trpl/the-stack-and-the-heap.md index f835322ee71..0c78f876aa0 100644 --- a/src/doc/trpl/the-stack-and-the-heap.md +++ b/src/doc/trpl/the-stack-and-the-heap.md @@ -7,6 +7,14 @@ and a heap. If you’re familiar with how C-like languages use stack allocation, this chapter will be a refresher. If you’re not, you’ll learn about this more general concept, but with a Rust-y focus. +As with most things, when learning about them, we’ll use a simplified model to +start. This lets you get a handle on the basics, without getting bogged down +with details which are, for now, irrelevant. The examples we’ll use aren’t 100% +accurate, but are representative for the level we’re trying to learn at right +now. Once you have the basics down, learning more about how allocators are +implemented, virtual memory, and other advanced topics will reveal the leaks in +this particular abstraction. + # Memory management These two terms are about memory management. The stack and the heap are diff --git a/src/doc/trpl/ufcs.md b/src/doc/trpl/ufcs.md index 2353c63a606..7725970564b 100644 --- a/src/doc/trpl/ufcs.md +++ b/src/doc/trpl/ufcs.md @@ -109,19 +109,28 @@ Here’s an example of using the longer form. ```rust trait Foo { - fn clone(&self); + fn foo() -> i32; } -#[derive(Clone)] struct Bar; -impl Foo for Bar { - fn clone(&self) { - println!("Making a clone of Bar"); +impl Bar { + fn foo() -> i32 { + 20 + } +} - <Bar as Clone>::clone(self); +impl Foo for Bar { + fn foo() -> i32 { + 10 } } + +fn main() { + assert_eq!(10, <Bar as Foo>::foo()); + assert_eq!(20, Bar::foo()); +} ``` -This will call the `Clone` trait’s `clone()` method, rather than `Foo`’s. +Using the angle bracket syntax lets you call the trait method instead of the +inherent one. diff --git a/src/etc/add-authors.sh b/src/etc/add-authors.sh index 3ae0ec73957..e45b803fa07 100644..100755 --- a/src/etc/add-authors.sh +++ b/src/etc/add-authors.sh @@ -30,8 +30,8 @@ range="$1" authors_file="./AUTHORS.txt" tmp_file="./AUTHORS.txt.tmp" old_authors="$(cat "$authors_file" | tail -n +2 | sed "/^$/d" | sort)" -new_authors="$(git log "$range" --format="%aN <%aE>" | sort | uniq)" +new_authors="$(git log "$range" --use-mailmap --format="%aN <%aE>" | sort | uniq)" printf "%s\n\n" "Rust was written by these fine people:" > "$tmp_file" -printf "%s\n%s" "$old_authors" "$new_authors" | sort | uniq >> "$tmp_file" +printf "%s\n%s" "$old_authors" "$new_authors" | sort -fs | uniq >> "$tmp_file" mv -f "$tmp_file" "$authors_file" diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 979ddd45412..769faedf46e 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -24,6 +24,8 @@ use marker::Sized; /// A common trait for cloning an object. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Clone : Sized { /// Returns a copy of the value. diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 5458a7b9c38..3ac4ffb2236 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -43,6 +43,8 @@ use option::Option::{self, Some}; /// in terms of it by default. Any manual implementation of `ne` *must* respect /// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and /// only if `a != b`. +/// +/// This trait can be used with `#[derive]`. #[lang = "eq"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialEq<Rhs: ?Sized = Self> { @@ -69,6 +71,8 @@ pub trait PartialEq<Rhs: ?Sized = Self> { /// /// This property cannot be checked by the compiler, and therefore `Eq` implies /// `PartialEq`, and has no extra methods. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Eq: PartialEq<Self> { // FIXME #13101: this method is used solely by #[deriving] to @@ -171,6 +175,8 @@ impl Ordering { /// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`. /// /// When this trait is `derive`d, it produces a lexicographic ordering. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Ord: Eq + PartialOrd<Self> { /// This method returns an `Ordering` between `self` and `other`. @@ -227,6 +233,8 @@ impl PartialOrd for Ordering { /// However it remains possible to implement the others separately for types which do not have a /// total order. For example, for floating point numbers, `NaN < 0 == false` and `NaN >= 0 == /// false` (cf. IEEE 754-2008 section 5.11). +/// +/// This trait can be used with `#[derive]`. #[lang = "ord"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 8fe65e27c03..dfcc5781f08 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -300,6 +300,8 @@ impl<'a> Display for Arguments<'a> { /// /// [module]: ../../std/fmt/index.html /// +/// This trait can be used with `#[derive]`. +/// /// # Examples /// /// Deriving an implementation: diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 0899dc28848..ea3a2f78d56 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -93,6 +93,8 @@ mod sip; /// /// In other words, if two keys are equal, their hashes should also be equal. /// `HashMap` and `HashSet` both rely on this behavior. +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] pub trait Hash { /// Feeds this value into the state given, updating the hasher as necessary. diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 8558927e4ac..020f7e37a4a 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -2375,32 +2375,118 @@ impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I { } /// Conversion from an `Iterator`. +/// +/// By implementing `FromIterator` for a type, you define how it will be +/// created from an iterator. This is common for types which describe a +/// collection of some kind. +/// +/// `FromIterator`'s [`from_iter()`] is rarely called explicitly, and is instead +/// used through [`Iterator`]'s [`collect()`] method. See [`collect()`]'s +/// documentation for more examples. +/// +/// [`from_iter()`]: #tymethod.from_iter +/// [`Iterator`]: trait.Iterator.html +/// [`collect()`]: trait.Iterator.html#method.collect +/// +/// See also: [`IntoIterator`]. +/// +/// [`IntoIterator`]: trait.IntoIterator.html +/// +/// # Examples +/// +/// Basic usage: +/// +/// ``` +/// use std::iter::FromIterator; +/// +/// let five_fives = std::iter::repeat(5).take(5); +/// +/// let v = Vec::from_iter(five_fives); +/// +/// assert_eq!(v, vec![5, 5, 5, 5, 5]); +/// ``` +/// +/// Using [`collect()`] to implicitly use `FromIterator`: +/// +/// ``` +/// let five_fives = std::iter::repeat(5).take(5); +/// +/// let v: Vec<i32> = five_fives.collect(); +/// +/// assert_eq!(v, vec![5, 5, 5, 5, 5]); +/// ``` +/// +/// Implementing `FromIterator` for your type: +/// +/// ``` +/// use std::iter::FromIterator; +/// +/// // A sample collection, that's just a wrapper over Vec<T> +/// #[derive(Debug)] +/// struct MyCollection(Vec<i32>); +/// +/// // Let's give it some methods so we can create one and add things +/// // to it. +/// impl MyCollection { +/// fn new() -> MyCollection { +/// MyCollection(Vec::new()) +/// } +/// +/// fn add(&mut self, elem: i32) { +/// self.0.push(elem); +/// } +/// } +/// +/// // and we'll implement FromIterator +/// impl FromIterator<i32> for MyCollection { +/// fn from_iter<I: IntoIterator<Item=i32>>(iterator: I) -> Self { +/// let mut c = MyCollection::new(); +/// +/// for i in iterator { +/// c.add(i); +/// } +/// +/// c +/// } +/// } +/// +/// // Now we can make a new iterator... +/// let iter = (0..5).into_iter(); +/// +/// // ... and make a MyCollection out of it +/// let c = MyCollection::from_iter(iter); +/// +/// assert_eq!(c.0, vec![0, 1, 2, 3, 4]); +/// +/// // collect works too! +/// +/// let iter = (0..5).into_iter(); +/// let c: MyCollection = iter.collect(); +/// +/// assert_eq!(c.0, vec![0, 1, 2, 3, 4]); +/// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented="a collection of type `{Self}` cannot be \ built from an iterator over elements of type `{A}`"] pub trait FromIterator<A>: Sized { - /// Builds a container with elements from something iterable. + /// Creates a value from an iterator. + /// + /// See the [module-level documentation] for more. + /// + /// [module-level documentation]: trait.FromIterator.html /// /// # Examples /// - /// ``` - /// use std::collections::HashSet; - /// use std::iter::FromIterator; + /// Basic usage: /// - /// let colors_vec = vec!["red", "red", "yellow", "blue"]; - /// let colors_set = HashSet::<&str>::from_iter(colors_vec); - /// assert_eq!(colors_set.len(), 3); /// ``` + /// use std::iter::FromIterator; /// - /// `FromIterator` is more commonly used implicitly via the - /// `Iterator::collect` method: + /// let five_fives = std::iter::repeat(5).take(5); /// - /// ``` - /// use std::collections::HashSet; + /// let v = Vec::from_iter(five_fives); /// - /// let colors_vec = vec!["red", "red", "yellow", "blue"]; - /// let colors_set = colors_vec.into_iter().collect::<HashSet<&str>>(); - /// assert_eq!(colors_set.len(), 3); + /// assert_eq!(v, vec![5, 5, 5, 5, 5]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn from_iter<T: IntoIterator<Item=A>>(iterator: T) -> Self; @@ -2415,9 +2501,13 @@ pub trait FromIterator<A>: Sized { /// One benefit of implementing `IntoIterator` is that your type will [work /// with Rust's `for` loop syntax](index.html#for-loops-and-intoiterator). /// +/// See also: [`FromIterator`]. +/// +/// [`FromIterator`]: trait.FromIterator.html +/// /// # Examples /// -/// Vectors implement `IntoIterator`: +/// Basic usage: /// /// ``` /// let v = vec![1, 2, 3]; @@ -2489,7 +2579,33 @@ pub trait IntoIterator { #[stable(feature = "rust1", since = "1.0.0")] type IntoIter: Iterator<Item=Self::Item>; - /// Consumes `Self` and returns an iterator over it. + /// Creates an iterator from a value. + /// + /// See the [module-level documentation] for more. + /// + /// [module-level documentation]: trait.IntoIterator.html + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// let v = vec![1, 2, 3]; + /// + /// let mut iter = v.into_iter(); + /// + /// let n = iter.next(); + /// assert_eq!(Some(1), n); + /// + /// let n = iter.next(); + /// assert_eq!(Some(2), n); + /// + /// let n = iter.next(); + /// assert_eq!(Some(3), n); + /// + /// let n = iter.next(); + /// assert_eq!(None, n); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn into_iter(self) -> Self::IntoIter; } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index df7b7c437c3..961acb7a835 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -10,12 +10,15 @@ //! # The Rust Core Library //! -//! The Rust Core Library is the dependency-free foundation of [The +//! The Rust Core Library is the dependency-free[^free] foundation of [The //! Rust Standard Library](../std/index.html). It is the portable glue //! between the language and its libraries, defining the intrinsic and //! primitive building blocks of all Rust code. It links to no //! upstream libraries, no system libraries, and no libc. //! +//! [^free]: Strictly speaking, there are some symbols which are needed but +//! they aren't always neccesary. +//! //! The core library is *minimal*: it isn't even aware of heap allocation, //! nor does it provide concurrency or I/O. These things require //! platform integration, and this library is platform-agnostic. @@ -63,7 +66,6 @@ #![doc(test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] #![no_core] -#![allow(raw_pointer_derive)] #![deny(missing_docs)] #![feature(allow_internal_unstable)] diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 6e6ae618527..84a6196cc87 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -165,6 +165,10 @@ pub trait Unsize<T: ?Sized> { /// to consider though: if you think your type may _not_ be able to implement `Copy` in the future, /// then it might be prudent to not implement `Copy`. This is because removing `Copy` is a breaking /// change: that second example would fail to compile if we made `Foo` non-`Copy`. +/// +/// # Derivable +/// +/// This trait can be used with `#[derive]`. #[stable(feature = "rust1", since = "1.0.0")] #[lang = "copy"] pub trait Copy : Clone { diff --git a/src/liblibc b/src/liblibc -Subproject b1a043feeae3a67f45e75eaf10aa900a1f6832f +Subproject 8531cc11e196b7ae9072ae7b384a930ff7b00df diff --git a/src/librustc/front/map/blocks.rs b/src/librustc/front/map/blocks.rs index 7d4809d457c..e6c165193f0 100644 --- a/src/librustc/front/map/blocks.rs +++ b/src/librustc/front/map/blocks.rs @@ -236,7 +236,7 @@ impl<'a> FnLikeNode<'a> { }, map::NodeImplItem(ii) => { match ii.node { - ast::MethodImplItem(ref sig, ref body) => { + ast::ImplItemKind::Method(ref sig, ref body) => { method(ii.id, ii.name, sig, Some(ii.vis), body, ii.span) } _ => { diff --git a/src/librustc/front/map/collector.rs b/src/librustc/front/map/collector.rs index f255949a9f5..54e2563a123 100644 --- a/src/librustc/front/map/collector.rs +++ b/src/librustc/front/map/collector.rs @@ -224,8 +224,8 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { fn visit_impl_item(&mut self, ii: &'ast ImplItem) { let def_data = match ii.node { - MethodImplItem(..) | ConstImplItem(..) => DefPathData::Value(ii.name), - TypeImplItem(..) => DefPathData::Type(ii.name), + ImplItemKind::Method(..) | ImplItemKind::Const(..) => DefPathData::Value(ii.name), + ImplItemKind::Type(..) => DefPathData::Type(ii.name), }; self.insert_def(ii.id, NodeImplItem(ii), def_data); @@ -234,7 +234,7 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { self.parent_node = ii.id; match ii.node { - ConstImplItem(_, ref expr) => { + ImplItemKind::Const(_, ref expr) => { self.create_def(expr.id, DefPathData::Initializer); } _ => { } @@ -313,4 +313,3 @@ impl<'ast> Visitor<'ast> for NodeCollector<'ast> { self.create_def(macro_def.id, DefPathData::MacroDef(macro_def.name)); } } - diff --git a/src/librustc/front/map/mod.rs b/src/librustc/front/map/mod.rs index 11f0fd1bb2c..fb883c0ca0c 100644 --- a/src/librustc/front/map/mod.rs +++ b/src/librustc/front/map/mod.rs @@ -937,18 +937,18 @@ fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String { } Some(NodeImplItem(ii)) => { match ii.node { - ConstImplItem(..) => { + ImplItemKind::Const(..) => { format!("assoc const {} in {}{}", ii.name, map.path_to_string(id), id_str) } - MethodImplItem(..) => { + ImplItemKind::Method(..) => { format!("method {} in {}{}", ii.name, map.path_to_string(id), id_str) } - TypeImplItem(_) => { + ImplItemKind::Type(_) => { format!("assoc type {} in {}{}", ii.name, map.path_to_string(id), diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 1cd196895e3..bfdbb6dadd4 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -739,7 +739,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>, let elem = ast_map::PathName(m.name); encode_path(rbml_w, impl_path.chain(Some(elem))); if let Some(impl_item) = impl_item_opt { - if let hir::MethodImplItem(ref sig, _) = impl_item.node { + if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node { encode_attributes(rbml_w, &impl_item.attrs); let scheme = ecx.tcx.lookup_item_type(m.def_id); let any_types = !scheme.generics.types.is_empty(); diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index a3eeb12da01..814c7c990bd 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -348,7 +348,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { fn visit_impl_item(&mut self, i: &'v hir::ImplItem) { match i.node { - hir::ConstImplItem(_, ref expr) => { + hir::ImplItemKind::Const(_, ref expr) => { self.global_expr(Mode::Const, &*expr); } _ => self.with_mode(Mode::Var, |v| visit::walk_impl_item(v, i)), diff --git a/src/librustc/middle/check_static_recursion.rs b/src/librustc/middle/check_static_recursion.rs index dd49010c436..ede37eb737f 100644 --- a/src/librustc/middle/check_static_recursion.rs +++ b/src/librustc/middle/check_static_recursion.rs @@ -79,7 +79,7 @@ impl<'a, 'ast: 'a> Visitor<'ast> for CheckCrateVisitor<'a, 'ast> { fn visit_impl_item(&mut self, ii: &'ast hir::ImplItem) { match ii.node { - hir::ConstImplItem(..) => { + hir::ImplItemKind::Const(..) => { let mut recursion_visitor = CheckItemRecursionVisitor::new(self, &ii.span); recursion_visitor.visit_impl_item(ii); diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 34d002d3342..832baa1515f 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -129,7 +129,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, _ => None }, Some(ast_map::NodeImplItem(ii)) => match ii.node { - hir::ConstImplItem(_, ref expr) => { + hir::ImplItemKind::Const(_, ref expr) => { Some(&*expr) } _ => None @@ -171,7 +171,7 @@ pub fn lookup_const_by_id<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, _ => None }, csearch::FoundAst::Found(&InlinedItem::ImplItem(_, ref ii)) => match ii.node { - hir::ConstImplItem(_, ref expr) => Some(expr.id), + hir::ImplItemKind::Const(_, ref expr) => Some(expr.id), _ => None }, _ => None @@ -390,6 +390,8 @@ pub struct ConstEvalErr { pub enum ErrKind { CannotCast, CannotCastTo(&'static str), + InvalidOpForInts(hir::BinOp_), + InvalidOpForUInts(hir::BinOp_), InvalidOpForBools(hir::BinOp_), InvalidOpForFloats(hir::BinOp_), InvalidOpForIntUint(hir::BinOp_), @@ -428,6 +430,8 @@ impl ConstEvalErr { match self.kind { CannotCast => "can't cast this type".into_cow(), CannotCastTo(s) => format!("can't cast this type to {}", s).into_cow(), + InvalidOpForInts(_) => "can't do this op on signed integrals".into_cow(), + InvalidOpForUInts(_) => "can't do this op on unsigned integrals".into_cow(), InvalidOpForBools(_) => "can't do this op on bools".into_cow(), InvalidOpForFloats(_) => "can't do this op on floats".into_cow(), InvalidOpForIntUint(..) => "can't do this op on an isize and usize".into_cow(), @@ -764,8 +768,6 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, e: &Expr, ty_hint: EvalHint<'tcx>, fn_args: FnArgMap) -> EvalResult { - fn fromb(b: bool) -> ConstVal { Int(b as i64) } - // Try to compute the type of the expression based on the EvalHint. // (See also the definition of EvalHint, and the FIXME above EvalHint.) let ety = match ty_hint { @@ -837,13 +839,13 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, hir::BiMul => Float(a * b), hir::BiDiv => Float(a / b), hir::BiRem => Float(a % b), - hir::BiEq => fromb(a == b), - hir::BiLt => fromb(a < b), - hir::BiLe => fromb(a <= b), - hir::BiNe => fromb(a != b), - hir::BiGe => fromb(a >= b), - hir::BiGt => fromb(a > b), - _ => signal!(e, InvalidOpForFloats(op.node)) + hir::BiEq => Bool(a == b), + hir::BiLt => Bool(a < b), + hir::BiLe => Bool(a <= b), + hir::BiNe => Bool(a != b), + hir::BiGe => Bool(a >= b), + hir::BiGt => Bool(a > b), + _ => signal!(e, InvalidOpForFloats(op.node)), } } (Int(a), Int(b)) => { @@ -853,17 +855,18 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, hir::BiMul => try!(const_int_checked_mul(a,b,e,expr_int_type)), hir::BiDiv => try!(const_int_checked_div(a,b,e,expr_int_type)), hir::BiRem => try!(const_int_checked_rem(a,b,e,expr_int_type)), - hir::BiAnd | hir::BiBitAnd => Int(a & b), - hir::BiOr | hir::BiBitOr => Int(a | b), + hir::BiBitAnd => Int(a & b), + hir::BiBitOr => Int(a | b), hir::BiBitXor => Int(a ^ b), hir::BiShl => try!(const_int_checked_shl(a,b,e,expr_int_type)), hir::BiShr => try!(const_int_checked_shr(a,b,e,expr_int_type)), - hir::BiEq => fromb(a == b), - hir::BiLt => fromb(a < b), - hir::BiLe => fromb(a <= b), - hir::BiNe => fromb(a != b), - hir::BiGe => fromb(a >= b), - hir::BiGt => fromb(a > b) + hir::BiEq => Bool(a == b), + hir::BiLt => Bool(a < b), + hir::BiLe => Bool(a <= b), + hir::BiNe => Bool(a != b), + hir::BiGe => Bool(a >= b), + hir::BiGt => Bool(a > b), + _ => signal!(e, InvalidOpForInts(op.node)), } } (Uint(a), Uint(b)) => { @@ -873,17 +876,18 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, hir::BiMul => try!(const_uint_checked_mul(a,b,e,expr_uint_type)), hir::BiDiv => try!(const_uint_checked_div(a,b,e,expr_uint_type)), hir::BiRem => try!(const_uint_checked_rem(a,b,e,expr_uint_type)), - hir::BiAnd | hir::BiBitAnd => Uint(a & b), - hir::BiOr | hir::BiBitOr => Uint(a | b), + hir::BiBitAnd => Uint(a & b), + hir::BiBitOr => Uint(a | b), hir::BiBitXor => Uint(a ^ b), hir::BiShl => try!(const_uint_checked_shl(a,b,e,expr_uint_type)), hir::BiShr => try!(const_uint_checked_shr(a,b,e,expr_uint_type)), - hir::BiEq => fromb(a == b), - hir::BiLt => fromb(a < b), - hir::BiLe => fromb(a <= b), - hir::BiNe => fromb(a != b), - hir::BiGe => fromb(a >= b), - hir::BiGt => fromb(a > b), + hir::BiEq => Bool(a == b), + hir::BiLt => Bool(a < b), + hir::BiLe => Bool(a <= b), + hir::BiNe => Bool(a != b), + hir::BiGe => Bool(a >= b), + hir::BiGt => Bool(a > b), + _ => signal!(e, InvalidOpForUInts(op.node)), } } // shifts can have any integral type as their rhs @@ -996,7 +1000,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>, }, ty::ImplContainer(_) => match tcx.map.find(node_id) { Some(ast_map::NodeImplItem(ii)) => match ii.node { - hir::ConstImplItem(ref ty, ref expr) => { + hir::ImplItemKind::Const(ref ty, ref expr) => { (Some(&**expr), Some(&**ty)) } _ => (None, None) diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index fff080a70e6..5892067ab08 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -358,14 +358,14 @@ impl<'v> Visitor<'v> for LifeSeeder { hir::ItemImpl(_, _, _, ref opt_trait, _, ref impl_items) => { for impl_item in impl_items { match impl_item.node { - hir::ConstImplItem(..) | - hir::MethodImplItem(..) => { + hir::ImplItemKind::Const(..) | + hir::ImplItemKind::Method(..) => { if opt_trait.is_some() || has_allow_dead_code_or_lang_attr(&impl_item.attrs) { self.worklist.push(impl_item.id); } } - hir::TypeImplItem(_) => {} + hir::ImplItemKind::Type(_) => {} } } } @@ -571,21 +571,21 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> { fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) { match impl_item.node { - hir::ConstImplItem(_, ref expr) => { + hir::ImplItemKind::Const(_, ref expr) => { if !self.symbol_is_live(impl_item.id, None) { self.warn_dead_code(impl_item.id, impl_item.span, impl_item.name, "associated const"); } visit::walk_expr(self, expr) } - hir::MethodImplItem(_, ref body) => { + hir::ImplItemKind::Method(_, ref body) => { if !self.symbol_is_live(impl_item.id, None) { self.warn_dead_code(impl_item.id, impl_item.span, impl_item.name, "method"); } visit::walk_block(self, body) } - hir::TypeImplItem(..) => {} + hir::ImplItemKind::Type(..) => {} } } diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index a16ef808bb6..111872f1784 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -948,7 +948,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { } ast_map::NodeImplItem(item) => { match item.node { - hir::MethodImplItem(ref sig, _) => { + hir::ImplItemKind::Method(ref sig, _) => { Some((&sig.decl, &sig.generics, sig.unsafety, @@ -1444,7 +1444,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { hir::TyTup(tys) => { hir::TyTup(tys.into_iter().map(|ty| build_to(ty, to)).collect()) } - hir::TyParen(typ) => hir::TyParen(build_to(typ, to)), other => other }; hir::Ty { id: id, node: new_node, span: span } @@ -1839,7 +1838,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt, }, ast_map::NodeImplItem(ii) => { match ii.node { - hir::MethodImplItem(ref sig, _) => { + hir::ImplItemKind::Method(ref sig, _) => { taken.push_all(&sig.generics.lifetimes); Some(ii.id) } diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 7175fbe0e57..e5bc9030fc9 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -185,8 +185,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } Some(ast_map::NodeImplItem(impl_item)) => { match impl_item.node { - hir::ConstImplItem(..) => true, - hir::MethodImplItem(ref sig, _) => { + hir::ImplItemKind::Const(..) => true, + hir::ImplItemKind::Method(ref sig, _) => { if generics_require_inlining(&sig.generics) || attr::requests_inline(&impl_item.attrs) { true @@ -206,7 +206,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } } } - hir::TypeImplItem(_) => false, + hir::ImplItemKind::Type(_) => false, } } Some(_) => false, @@ -299,16 +299,16 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { } ast_map::NodeImplItem(impl_item) => { match impl_item.node { - hir::ConstImplItem(_, ref expr) => { + hir::ImplItemKind::Const(_, ref expr) => { self.visit_expr(&*expr); } - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItemKind::Method(ref sig, ref body) => { let did = self.tcx.map.get_parent_did(search_item); if method_might_be_inlined(self.tcx, sig, impl_item, did) { visit::walk_block(self, body) } } - hir::TypeImplItem(_) => {} + hir::ImplItemKind::Type(_) => {} } } // Nothing to recurse on for these diff --git a/src/librustc/middle/ty/mod.rs b/src/librustc/middle/ty/mod.rs index 0a9fa1d6ce3..42bba0c8aef 100644 --- a/src/librustc/middle/ty/mod.rs +++ b/src/librustc/middle/ty/mod.rs @@ -1124,7 +1124,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { match cx.map.find(id) { Some(ast_map::NodeImplItem(ref impl_item)) => { match impl_item.node { - hir::TypeImplItem(_) => { + hir::ImplItemKind::Type(_) => { // associated types don't have their own entry (for some reason), // so for now just grab environment for the impl let impl_id = cx.map.get_parent(id); @@ -1136,7 +1136,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { &predicates, id) } - hir::ConstImplItem(_, _) => { + hir::ImplItemKind::Const(_, _) => { let def_id = cx.map.local_def_id(id); let scheme = cx.lookup_item_type(def_id); let predicates = cx.lookup_predicates(def_id); @@ -1145,7 +1145,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> { &predicates, id) } - hir::MethodImplItem(_, ref body) => { + hir::ImplItemKind::Method(_, ref body) => { let method_def_id = cx.map.local_def_id(id); match cx.impl_or_trait_item(method_def_id) { MethodTraitItem(ref method_ty) => { @@ -2158,7 +2158,7 @@ impl<'tcx> ctxt<'tcx> { } ItemImpl(_, _, _, _, _, ref iis) => { iis.iter().filter_map(|ii| { - if let hir::ConstImplItem(_, _) = ii.node { + if let hir::ImplItemKind::Const(_, _) = ii.node { match self.impl_or_trait_item(self.map.local_def_id(ii.id)) { ConstTraitItem(ac) => Some(ac), _ => { diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index ccb48ed2edf..f1eff5f55f2 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -89,7 +89,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> { } fn visit_impl_item(&mut self, ii: &hir::ImplItem) { - if let hir::ConstImplItem(_, ref expr) = ii.node { + if let hir::ImplItemKind::Const(_, ref expr) = ii.node { gather_loans::gather_loans_in_static_initializer(self, &*expr); } visit::walk_impl_item(self, ii); diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index bdad13526b8..04f7938e9ba 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -623,7 +623,7 @@ impl fold::Folder for ReplaceBodyWithLoop { fn fold_impl_item(&mut self, i: P<ast::ImplItem>) -> SmallVector<P<ast::ImplItem>> { match i.node { - ast::ConstImplItem(..) => { + ast::ImplItemKind::Const(..) => { self.within_static_or_const = true; let ret = fold::noop_fold_impl_item(i, self); self.within_static_or_const = false; diff --git a/src/librustc_front/fold.rs b/src/librustc_front/fold.rs index 955de44b43f..b963aba9c07 100644 --- a/src/librustc_front/fold.rs +++ b/src/librustc_front/fold.rs @@ -382,7 +382,6 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> { })) } TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))), - TyParen(ty) => TyParen(fld.fold_ty(ty)), TyPath(qself, path) => { let qself = qself.map(|QSelf { ty, position }| { QSelf { @@ -867,13 +866,13 @@ pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T) -> P<ImplI attrs: fold_attrs(attrs, folder), vis: vis, node: match node { - ConstImplItem(ty, expr) => { - ConstImplItem(folder.fold_ty(ty), folder.fold_expr(expr)) + ImplItemKind::Const(ty, expr) => { + ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr)) } - MethodImplItem(sig, body) => { - MethodImplItem(noop_fold_method_sig(sig, folder), folder.fold_block(body)) + ImplItemKind::Method(sig, body) => { + ImplItemKind::Method(noop_fold_method_sig(sig, folder), folder.fold_block(body)) } - TypeImplItem(ty) => TypeImplItem(folder.fold_ty(ty)), + ImplItemKind::Type(ty) => ImplItemKind::Type(folder.fold_ty(ty)), }, span: folder.new_span(span), } diff --git a/src/librustc_front/hir.rs b/src/librustc_front/hir.rs index b017a07dde0..1fa7c9d301c 100644 --- a/src/librustc_front/hir.rs +++ b/src/librustc_front/hir.rs @@ -19,7 +19,6 @@ pub use self::ExplicitSelf_::*; pub use self::Expr_::*; pub use self::FunctionRetTy::*; pub use self::ForeignItem_::*; -pub use self::ImplItem_::*; pub use self::Item_::*; pub use self::Mutability::*; pub use self::Pat_::*; @@ -771,15 +770,15 @@ pub struct ImplItem { pub name: Name, pub vis: Visibility, pub attrs: Vec<Attribute>, - pub node: ImplItem_, + pub node: ImplItemKind, pub span: Span, } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum ImplItem_ { - ConstImplItem(P<Ty>, P<Expr>), - MethodImplItem(MethodSig, P<Block>), - TypeImplItem(P<Ty>), +pub enum ImplItemKind { + Const(P<Ty>, P<Expr>), + Method(MethodSig, P<Block>), + Type(P<Ty>), } // Bind a type to an associated type: `A=Foo`. @@ -848,8 +847,6 @@ pub enum Ty_ { TyObjectSum(P<Ty>, TyParamBounds), /// A type like `for<'a> Foo<&'a Bar>` TyPolyTraitRef(TyParamBounds), - /// No-op; kept solely so that we can pretty-print faithfully - TyParen(P<Ty>), /// Unused for now TyTypeof(P<Expr>), /// TyInfer means the type should be inferred instead of it having been diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index d13b92c04f8..8ef49d185f7 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -225,7 +225,9 @@ pub fn lower_ty(_lctx: &LoweringContext, t: &Ty) -> P<hir::Ty> { })) } TyTup(ref tys) => hir::TyTup(tys.iter().map(|ty| lower_ty(_lctx, ty)).collect()), - TyParen(ref ty) => hir::TyParen(lower_ty(_lctx, ty)), + TyParen(ref ty) => { + return lower_ty(_lctx, ty); + } TyPath(ref qself, ref path) => { let qself = qself.as_ref().map(|&QSelf { ref ty, position }| { hir::QSelf { @@ -675,14 +677,14 @@ pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P<hir::ImplItem attrs: i.attrs.clone(), vis: lower_visibility(_lctx, i.vis), node: match i.node { - ConstImplItem(ref ty, ref expr) => { - hir::ConstImplItem(lower_ty(_lctx, ty), lower_expr(_lctx, expr)) + ImplItemKind::Const(ref ty, ref expr) => { + hir::ImplItemKind::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr)) } - MethodImplItem(ref sig, ref body) => { - hir::MethodImplItem(lower_method_sig(_lctx, sig), lower_block(_lctx, body)) + ImplItemKind::Method(ref sig, ref body) => { + hir::ImplItemKind::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body)) } - TypeImplItem(ref ty) => hir::TypeImplItem(lower_ty(_lctx, ty)), - MacImplItem(..) => panic!("Shouldn't exist any more"), + ImplItemKind::Type(ref ty) => hir::ImplItemKind::Type(lower_ty(_lctx, ty)), + ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"), }, span: i.span, }) diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index 2fd374f7560..09c814449a9 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -506,11 +506,6 @@ impl<'a> State<'a> { } try!(self.pclose()); } - hir::TyParen(ref typ) => { - try!(self.popen()); - try!(self.print_type(&**typ)); - try!(self.pclose()); - } hir::TyBareFn(ref f) => { let generics = hir::Generics { lifetimes: f.lifetimes.clone(), @@ -1011,16 +1006,16 @@ impl<'a> State<'a> { try!(self.maybe_print_comment(ii.span.lo)); try!(self.print_outer_attributes(&ii.attrs)); match ii.node { - hir::ConstImplItem(ref ty, ref expr) => { + hir::ImplItemKind::Const(ref ty, ref expr) => { try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis)); } - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItemKind::Method(ref sig, ref body) => { try!(self.head("")); try!(self.print_method_sig(ii.name, sig, ii.vis)); try!(self.nbsp()); try!(self.print_block_with_attrs(body, &ii.attrs)); } - hir::TypeImplItem(ref ty) => { + hir::ImplItemKind::Type(ref ty) => { try!(self.print_associated_type(ii.name, None, Some(ty))); } } diff --git a/src/librustc_front/visit.rs b/src/librustc_front/visit.rs index 94986ceced6..ec58f31b6de 100644 --- a/src/librustc_front/visit.rs +++ b/src/librustc_front/visit.rs @@ -349,7 +349,7 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V, pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { match typ.node { - TyVec(ref ty) | TyParen(ref ty) => { + TyVec(ref ty) => { visitor.visit_ty(ty) } TyPtr(ref mutable_type) => { @@ -614,18 +614,18 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt visitor.visit_name(impl_item.span, impl_item.name); walk_list!(visitor, visit_attribute, &impl_item.attrs); match impl_item.node { - ConstImplItem(ref ty, ref expr) => { + ImplItemKind::Const(ref ty, ref expr) => { visitor.visit_ty(ty); visitor.visit_expr(expr); } - MethodImplItem(ref sig, ref body) => { + ImplItemKind::Method(ref sig, ref body) => { visitor.visit_fn(FnKind::Method(impl_item.name, sig, Some(impl_item.vis)), &sig.decl, body, impl_item.span, impl_item.id); } - TypeImplItem(ref ty) => { + ImplItemKind::Type(ref ty) => { visitor.visit_ty(ty); } } diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index 693de1740bf..53fc0824d96 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -351,7 +351,7 @@ impl LateLintPass for NonUpperCaseGlobals { fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) { match ii.node { - hir::ConstImplItem(..) => { + hir::ImplItemKind::Const(..) => { NonUpperCaseGlobals::check_upper_case(cx, "associated constant", ii.name, ii.span); } diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index a001289b196..3e43a2240de 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -46,7 +46,7 @@ use syntax::attr::{self, AttrMetaMethods}; use syntax::codemap::{self, Span}; use rustc_front::hir; -use rustc_front::visit::{self, FnKind, Visitor}; +use rustc_front::visit::FnKind; use bad_style::{MethodLateContext, method_context}; @@ -139,92 +139,6 @@ impl LateLintPass for BoxPointers { } declare_lint! { - RAW_POINTER_DERIVE, - Warn, - "uses of #[derive] with raw pointers are rarely correct" -} - -struct RawPtrDeriveVisitor<'a, 'tcx: 'a> { - cx: &'a LateContext<'a, 'tcx> -} - -impl<'a, 'tcx, 'v> Visitor<'v> for RawPtrDeriveVisitor<'a, 'tcx> { - fn visit_ty(&mut self, ty: &hir::Ty) { - const MSG: &'static str = "use of `#[derive]` with a raw pointer"; - if let hir::TyPtr(..) = ty.node { - self.cx.span_lint(RAW_POINTER_DERIVE, ty.span, MSG); - } - visit::walk_ty(self, ty); - } - // explicit override to a no-op to reduce code bloat - fn visit_expr(&mut self, _: &hir::Expr) {} - fn visit_block(&mut self, _: &hir::Block) {} -} - -pub struct RawPointerDerive { - checked_raw_pointers: NodeSet, -} - -impl RawPointerDerive { - pub fn new() -> RawPointerDerive { - RawPointerDerive { - checked_raw_pointers: NodeSet(), - } - } -} - -impl LintPass for RawPointerDerive { - fn get_lints(&self) -> LintArray { - lint_array!(RAW_POINTER_DERIVE) - } -} - -impl LateLintPass for RawPointerDerive { - fn check_item(&mut self, cx: &LateContext, item: &hir::Item) { - if !attr::contains_name(&item.attrs, "automatically_derived") { - return; - } - let did = match item.node { - hir::ItemImpl(_, _, _, ref t_ref_opt, _, _) => { - // Deriving the Copy trait does not cause a warning - if let &Some(ref trait_ref) = t_ref_opt { - let def_id = cx.tcx.trait_ref_to_def_id(trait_ref); - if Some(def_id) == cx.tcx.lang_items.copy_trait() { - return; - } - } - - match cx.tcx.node_id_to_type(item.id).sty { - ty::TyEnum(def, _) => def.did, - ty::TyStruct(def, _) => def.did, - _ => return, - } - } - _ => return, - }; - let node_id = if let Some(node_id) = cx.tcx.map.as_local_node_id(did) { - node_id - } else { - return; - }; - let item = match cx.tcx.map.find(node_id) { - Some(hir_map::NodeItem(item)) => item, - _ => return, - }; - if !self.checked_raw_pointers.insert(item.id) { - return; - } - match item.node { - hir::ItemStruct(..) | hir::ItemEnum(..) => { - let mut visitor = RawPtrDeriveVisitor { cx: cx }; - visit::walk_item(&mut visitor, &item); - } - _ => {} - } - } -} - -declare_lint! { NON_SHORTHAND_FIELD_PATTERNS, Warn, "using `Struct { x: x }` instead of `Struct { x }`" @@ -505,9 +419,9 @@ impl LateLintPass for MissingDoc { } let desc = match impl_item.node { - hir::ConstImplItem(..) => "an associated constant", - hir::MethodImplItem(..) => "a method", - hir::TypeImplItem(_) => "an associated type", + hir::ImplItemKind::Const(..) => "an associated constant", + hir::ImplItemKind::Method(..) => "a method", + hir::ImplItemKind::Type(_) => "an associated type", }; self.check_missing_docs_attrs(cx, Some(impl_item.id), &impl_item.attrs, diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 920e0341372..2613115d805 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -135,7 +135,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { add_builtin_with_new!(sess, TypeLimits, - RawPointerDerive, MissingDoc, MissingDebugImplementations, ); @@ -152,8 +151,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { store.register_late_pass(sess, false, box lint::GatherNodeLevels); // Insert temporary renamings for a one-time deprecation - store.register_renamed("raw_pointer_deriving", "raw_pointer_derive"); - store.register_renamed("unknown_features", "unused_features"); store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate"); diff --git a/src/librustc_llvm/diagnostic.rs b/src/librustc_llvm/diagnostic.rs index e6350ae44d4..c09048d677e 100644 --- a/src/librustc_llvm/diagnostic.rs +++ b/src/librustc_llvm/diagnostic.rs @@ -37,7 +37,6 @@ impl OptimizationDiagnosticKind { } } -#[allow(raw_pointer_derive)] #[derive(Copy, Clone)] pub struct OptimizationDiagnostic { pub kind: OptimizationDiagnosticKind, diff --git a/src/librustc_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 1359cbc82a6..a6b7169e18b 100644 --- a/src/librustc_mir/mir_map.rs +++ b/src/librustc_mir/mir_map.rs @@ -99,10 +99,10 @@ impl<'a, 'tcx> visit::Visitor<'tcx> for OuterDump<'a, 'tcx> { fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { match impl_item.node { - hir::MethodImplItem(..) => { + hir::ImplItemKind::Method(..) => { self.visit_mir(&impl_item.attrs, |c| visit::walk_impl_item(c, impl_item)); } - hir::ConstImplItem(..) | hir::TypeImplItem(..) => {} + hir::ImplItemKind::Const(..) | hir::ImplItemKind::Type(..) => {} } visit::walk_impl_item(self, impl_item); } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index a8600d91a26..ab9b32383b2 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -553,8 +553,8 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { // where the method was defined? Some(ast_map::NodeImplItem(ii)) => { match ii.node { - hir::ConstImplItem(..) | - hir::MethodImplItem(..) => { + hir::ImplItemKind::Const(..) | + hir::ImplItemKind::Method(..) => { let imp = self.tcx.map .get_parent_did(closest_private_id); match self.tcx.impl_trait_ref(imp) { @@ -565,7 +565,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { _ => ii.vis } } - hir::TypeImplItem(_) => return Allowable, + hir::ImplItemKind::Type(_) => return Allowable, } } Some(ast_map::NodeTraitItem(_)) => { @@ -1293,11 +1293,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { impl_items.iter() .any(|impl_item| { match impl_item.node { - hir::ConstImplItem(..) | - hir::MethodImplItem(..) => { + hir::ImplItemKind::Const(..) | + hir::ImplItemKind::Method(..) => { self.exported_items.contains(&impl_item.id) } - hir::TypeImplItem(_) => false, + hir::ImplItemKind::Type(_) => false, } }); @@ -1316,13 +1316,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { // don't erroneously report errors for private // types in private items. match impl_item.node { - hir::ConstImplItem(..) | - hir::MethodImplItem(..) + hir::ImplItemKind::Const(..) | + hir::ImplItemKind::Method(..) if self.item_is_public(&impl_item.id, impl_item.vis) => { visit::walk_impl_item(self, impl_item) } - hir::TypeImplItem(..) => { + hir::ImplItemKind::Type(..) => { visit::walk_impl_item(self, impl_item) } _ => {} @@ -1347,7 +1347,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { // Those in 3. are warned with this call. for impl_item in impl_items { - if let hir::TypeImplItem(ref ty) = impl_item.node { + if let hir::ImplItemKind::Type(ref ty) = impl_item.node { self.visit_ty(ty); } } @@ -1359,13 +1359,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> { let mut found_pub_static = false; for impl_item in impl_items { match impl_item.node { - hir::ConstImplItem(..) => { + hir::ImplItemKind::Const(..) => { if self.item_is_public(&impl_item.id, impl_item.vis) { found_pub_static = true; visit::walk_impl_item(self, impl_item); } } - hir::MethodImplItem(ref sig, _) => { + hir::ImplItemKind::Method(ref sig, _) => { if sig.explicit_self.node == hir::SelfStatic && self.item_is_public(&impl_item.id, impl_item.vis) { found_pub_static = true; diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index a6665a13786..f35b554d6cf 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -806,6 +806,15 @@ mod something { pub struct Foo; } ``` + +Or, if you tried to use a module from an external crate, you may have missed +the `extern crate` declaration: + +``` +extern crate homura; // Required to use the `homura` crate + +use homura::Madoka; +``` "##, E0433: r##" diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index a402d8310f9..0ead5fad92f 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -79,7 +79,7 @@ use syntax::codemap::{self, Span, Pos}; use rustc_front::visit::{self, FnKind, Visitor}; use rustc_front::hir; use rustc_front::hir::{Arm, BindByRef, BindByValue, BindingMode, Block}; -use rustc_front::hir::{ConstImplItem, Crate}; +use rustc_front::hir::Crate; use rustc_front::hir::{Expr, ExprAgain, ExprBreak, ExprField}; use rustc_front::hir::{ExprLoop, ExprWhile, ExprMethodCall}; use rustc_front::hir::{ExprPath, ExprStruct, FnDecl}; @@ -87,12 +87,11 @@ use rustc_front::hir::{ForeignItemFn, ForeignItemStatic, Generics}; use rustc_front::hir::{ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate}; use rustc_front::hir::{ItemFn, ItemForeignMod, ItemImpl, ItemMod, ItemStatic, ItemDefaultImpl}; use rustc_front::hir::{ItemStruct, ItemTrait, ItemTy, ItemUse}; -use rustc_front::hir::{Local, MethodImplItem}; +use rustc_front::hir::Local; use rustc_front::hir::{Pat, PatEnum, PatIdent, PatLit, PatQPath}; use rustc_front::hir::{PatRange, PatStruct, Path, PrimTy}; use rustc_front::hir::{TraitRef, Ty, TyBool, TyChar, TyFloat, TyInt}; use rustc_front::hir::{TyRptr, TyStr, TyUint, TyPath, TyPtr}; -use rustc_front::hir::TypeImplItem; use rustc_front::util::walk_pat; use std::collections::{HashMap, HashSet}; @@ -2421,7 +2420,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { this.with_current_self_type(self_type, |this| { for impl_item in impl_items { match impl_item.node { - ConstImplItem(..) => { + hir::ImplItemKind::Const(..) => { // If this is a trait impl, ensure the const // exists in trait this.check_trait_item(impl_item.name, @@ -2431,7 +2430,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { visit::walk_impl_item(this, impl_item); }); } - MethodImplItem(ref sig, _) => { + hir::ImplItemKind::Method(ref sig, _) => { // If this is a trait impl, ensure the method // exists in trait this.check_trait_item(impl_item.name, @@ -2448,7 +2447,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { visit::walk_impl_item(this, impl_item); }); } - TypeImplItem(ref ty) => { + hir::ImplItemKind::Type(ref ty) => { // If this is a trait impl, ensure the type // exists in trait this.check_trait_item(impl_item.name, @@ -3545,7 +3544,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { _ => return false, }, hir_map::NodeImplItem(impl_item) => match impl_item.node { - hir::MethodImplItem(ref sig, _) => sig, + hir::ImplItemKind::Method(ref sig, _) => sig, _ => return false, }, _ => return false, diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 3ea631bd7fb..682e203f856 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -992,22 +992,22 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { fn visit_impl_item(&mut self, impl_item: &ast::ImplItem) { match impl_item.node { - ast::ConstImplItem(ref ty, ref expr) => { + ast::ImplItemKind::Const(ref ty, ref expr) => { self.process_const(impl_item.id, impl_item.ident.name, impl_item.span, &ty, &expr); } - ast::MethodImplItem(ref sig, ref body) => { + ast::ImplItemKind::Method(ref sig, ref body) => { self.process_method(sig, Some(body), impl_item.id, impl_item.ident.name, impl_item.span); } - ast::TypeImplItem(_) | - ast::MacImplItem(_) => {} + ast::ImplItemKind::Type(_) | + ast::ImplItemKind::Macro(_) => {} } } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index ecd4c75c9d3..c87d9ab7bf0 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -1326,7 +1326,7 @@ fn build_cfg(tcx: &ty::ctxt, id: ast::NodeId) -> (ast::NodeId, Option<cfg::CFG>) } Some(hir_map::NodeImplItem(impl_item)) => { match impl_item.node { - hir::MethodImplItem(_, ref body) => body, + hir::ImplItemKind::Method(_, ref body) => body, _ => { tcx.sess.bug("unexpected variant: non-method impl item in \ has_nested_returns") @@ -2614,7 +2614,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { hir_map::NodeImplItem(impl_item) => { match impl_item.node { - hir::MethodImplItem(..) => { + hir::ImplItemKind::Method(..) => { register_method(ccx, id, &impl_item.attrs, impl_item.span) } _ => { diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/trans/debuginfo/mod.rs index 9e53d72cfb8..74510de3f31 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/trans/debuginfo/mod.rs @@ -253,7 +253,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } hir_map::NodeImplItem(impl_item) => { match impl_item.node { - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItemKind::Method(ref sig, ref body) => { if contains_nodebug_attribute(&impl_item.attrs) { return FunctionDebugContext::FunctionWithoutDebugInfo; } diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index 14e1ca7675f..0e837d83686 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -160,7 +160,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: DefId) ccx.stats().n_inlines.set(ccx.stats().n_inlines.get() + 1); // Translate monomorphic impl methods immediately. - if let hir::MethodImplItem(ref sig, ref body) = impl_item.node { + if let hir::ImplItemKind::Method(ref sig, ref body) = impl_item.node { let impl_tpt = ccx.tcx().lookup_item_type(impl_did); if impl_tpt.generics.types.is_empty() && sig.generics.ty_params.is_empty() { diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index ff94e4feda2..20388929cbd 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -70,7 +70,7 @@ pub fn trans_impl(ccx: &CrateContext, if !generics.ty_params.is_empty() { for impl_item in impl_items { match impl_item.node { - hir::MethodImplItem(..) => { + hir::ImplItemKind::Method(..) => { visit::walk_impl_item(&mut v, impl_item); } _ => {} @@ -80,7 +80,7 @@ pub fn trans_impl(ccx: &CrateContext, } for impl_item in impl_items { match impl_item.node { - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItemKind::Method(ref sig, ref body) => { if sig.generics.ty_params.is_empty() { let trans_everywhere = attr::requests_inline(&impl_item.attrs); for (ref ccx, is_origin) in ccx.maybe_iter(trans_everywhere) { diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index 1f9116f7491..9c1fcaff7c8 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -206,7 +206,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } hir_map::NodeImplItem(impl_item) => { match impl_item.node { - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItemKind::Method(ref sig, ref body) => { let d = mk_lldecl(abi::Rust); let needs_body = setup_lldecl(d, &impl_item.attrs); if needs_body { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 34378445c60..7de262dfa5b 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1624,7 +1624,6 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, .collect(); tcx.mk_tup(flds) } - hir::TyParen(ref typ) => ast_ty_to_ty(this, rscope, &**typ), hir::TyBareFn(ref bf) => { require_c_abi_if_variadic(tcx, &bf.decl, bf.abi, ast_ty.span); let bare_fn = ty_of_bare_fn(this, bf.unsafety, bf.abi, &*bf.decl); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index cfa32bc073a..5ed6b62e8c3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -764,14 +764,14 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) { for impl_item in impl_items { match impl_item.node { - hir::ConstImplItem(_, ref expr) => { + hir::ImplItemKind::Const(_, ref expr) => { check_const(ccx, impl_item.span, &*expr, impl_item.id) } - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItemKind::Method(ref sig, ref body) => { check_method_body(ccx, &impl_pty.generics, sig, body, impl_item.id, impl_item.span); } - hir::TypeImplItem(_) => { + hir::ImplItemKind::Type(_) => { // Nothing to do here. } } @@ -908,7 +908,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_trait_ref)); }); match impl_item.node { - hir::ConstImplItem(..) => { + hir::ImplItemKind::Const(..) => { let impl_const = match ty_impl_item { ty::ConstTraitItem(ref cti) => cti, _ => tcx.sess.span_bug(impl_item.span, "non-const impl-item for const") @@ -929,7 +929,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_trait_ref) } } - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItemKind::Method(ref sig, ref body) => { check_trait_fn_not_const(ccx, impl_item.span, sig.constness); let impl_method = match ty_impl_item { @@ -952,7 +952,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_trait_ref) } } - hir::TypeImplItem(_) => { + hir::ImplItemKind::Type(_) => { let impl_type = match ty_impl_item { ty::TypeTraitItem(ref tti) => tti, _ => tcx.sess.span_bug(impl_item.span, "non-type impl-item for type") @@ -983,7 +983,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, ty::ConstTraitItem(ref associated_const) => { let is_implemented = impl_items.iter().any(|ii| { match ii.node { - hir::ConstImplItem(..) => { + hir::ImplItemKind::Const(..) => { ii.name == associated_const.name } _ => false, @@ -1003,7 +1003,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let is_implemented = impl_items.iter().any(|ii| { match ii.node { - hir::MethodImplItem(..) => { + hir::ImplItemKind::Method(..) => { ii.name == trait_method.name } _ => false, @@ -1022,7 +1022,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, ty::TypeTraitItem(ref associated_type) => { let is_implemented = impl_items.iter().any(|ii| { match ii.node { - hir::TypeImplItem(_) => { + hir::ImplItemKind::Type(_) => { ii.name == associated_type.name } _ => false, diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index b3ec10a8941..6b2994d9dc0 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -196,13 +196,13 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { impl_items.iter().map(|impl_item| { let impl_def_id = self.crate_context.tcx.map.local_def_id(impl_item.id); match impl_item.node { - hir::ConstImplItem(..) => { + hir::ImplItemKind::Const(..) => { ConstTraitItemId(impl_def_id) } - hir::MethodImplItem(..) => { + hir::ImplItemKind::Method(..) => { MethodTraitItemId(impl_def_id) } - hir::TypeImplItem(_) => { + hir::ImplItemKind::Type(_) => { TypeTraitItemId(impl_def_id) } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 185623a4402..80f90182992 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -821,14 +821,14 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { for impl_item in impl_items { let seen_items = match impl_item.node { - hir::TypeImplItem(_) => &mut seen_type_items, + hir::ImplItemKind::Type(_) => &mut seen_type_items, _ => &mut seen_value_items, }; if !seen_items.insert(impl_item.name) { let desc = match impl_item.node { - hir::ConstImplItem(_, _) => "associated constant", - hir::TypeImplItem(_) => "associated type", - hir::MethodImplItem(ref sig, _) => + hir::ImplItemKind::Const(_, _) => "associated constant", + hir::ImplItemKind::Type(_) => "associated type", + hir::ImplItemKind::Method(ref sig, _) => match sig.explicit_self.node { hir::SelfStatic => "associated function", _ => "method", @@ -838,7 +838,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { span_err!(tcx.sess, impl_item.span, E0201, "duplicate {}", desc); } - if let hir::ConstImplItem(ref ty, _) = impl_item.node { + if let hir::ImplItemKind::Const(ref ty, _) = impl_item.node { let ty = ccx.icx(&ty_predicates) .to_ty(&ExplicitRscope, &*ty); tcx.register_item_type(ccx.tcx.map.local_def_id(impl_item.id), @@ -855,7 +855,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { // Convert all the associated types. for impl_item in impl_items { - if let hir::TypeImplItem(ref ty) = impl_item.node { + if let hir::ImplItemKind::Type(ref ty) = impl_item.node { if opt_trait_ref.is_none() { span_err!(tcx.sess, impl_item.span, E0202, "associated types are not allowed in inherent impls"); @@ -870,7 +870,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { } let methods = impl_items.iter().filter_map(|ii| { - if let hir::MethodImplItem(ref sig, _) = ii.node { + if let hir::ImplItemKind::Method(ref sig, _) = ii.node { // if the method specifies a visibility, use that, otherwise // inherit the visibility from the impl (so `foo` in `pub impl // { fn foo(); }` is public, but private in `impl { fn @@ -889,7 +889,7 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) { &ty_predicates); for impl_item in impl_items { - if let hir::MethodImplItem(ref sig, ref body) = impl_item.node { + if let hir::ImplItemKind::Method(ref sig, ref body) = impl_item.node { let body_id = body.id; check_method_self_type(ccx, &BindingRscope::new(), diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 34ddd5726d3..c88b2dcdb74 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1271,16 +1271,16 @@ impl Clean<Item> for hir::TraitItem { impl Clean<Item> for hir::ImplItem { fn clean(&self, cx: &DocContext) -> Item { let inner = match self.node { - hir::ConstImplItem(ref ty, ref expr) => { + hir::ImplItemKind::Const(ref ty, ref expr) => { ConstantItem(Constant{ type_: ty.clean(cx), expr: expr.span.to_src(cx), }) } - hir::MethodImplItem(ref sig, _) => { + hir::ImplItemKind::Method(ref sig, _) => { MethodItem(sig.clean(cx)) } - hir::TypeImplItem(ref ty) => TypedefItem(Typedef { + hir::ImplItemKind::Type(ref ty) => TypedefItem(Typedef { type_: ty.clean(cx), generics: Generics { lifetimes: Vec::new(), @@ -1606,7 +1606,6 @@ impl Clean<Type> for hir::Ty { } } TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), - TyParen(ref ty) => ty.clean(cx), TyPolyTraitRef(ref bounds) => { PolyTraitRef(bounds.clean(cx)) }, diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index c0cd6d127d2..48631bfc5f9 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -66,7 +66,7 @@ use sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; /// for _ in 0..10 { /// let (data, tx) = (data.clone(), tx.clone()); /// thread::spawn(move || { -/// // The shared static can only be accessed once the lock is held. +/// // The shared state can only be accessed once the lock is held. /// // Our non-atomic increment is safe because we're the only thread /// // which can access the shared state when the lock is held. /// // diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 3c53db53f85..dabc8090270 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -167,22 +167,20 @@ impl StdError for JoinPathsError { #[cfg(target_os = "freebsd")] pub fn current_exe() -> io::Result<PathBuf> { unsafe { - use libc::funcs::bsd44::*; - use libc::consts::os::extra::*; - let mut mib = [CTL_KERN as c_int, - KERN_PROC as c_int, - KERN_PROC_PATHNAME as c_int, + let mut mib = [libc::CTL_KERN as c_int, + libc::KERN_PROC as c_int, + libc::KERN_PROC_PATHNAME as c_int, -1 as c_int]; let mut sz: libc::size_t = 0; - let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, - ptr::null_mut(), &mut sz, ptr::null_mut(), - 0 as libc::size_t); + let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + ptr::null_mut(), &mut sz, ptr::null_mut(), + 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } let mut v: Vec<u8> = Vec::with_capacity(sz as usize); - let err = sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, - v.as_mut_ptr() as *mut libc::c_void, &mut sz, - ptr::null_mut(), 0 as libc::size_t); + let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + v.as_mut_ptr() as *mut libc::c_void, &mut sz, + ptr::null_mut(), 0 as libc::size_t); if err != 0 { return Err(io::Error::last_os_error()); } if sz == 0 { return Err(io::Error::last_os_error()); } v.set_len(sz as usize - 1); // chop off trailing NUL @@ -386,24 +384,33 @@ pub fn env() -> Env { let _g = ENV_LOCK.lock(); return unsafe { let mut environ = *environ(); - if environ as usize == 0 { + if environ == ptr::null() { panic!("os::env() failure getting env string from OS: {}", io::Error::last_os_error()); } let mut result = Vec::new(); while *environ != ptr::null() { - result.push(parse(CStr::from_ptr(*environ).to_bytes())); + if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) { + result.push(key_value); + } environ = environ.offset(1); } Env { iter: result.into_iter(), _dont_send_or_sync_me: ptr::null_mut() } }; - fn parse(input: &[u8]) -> (OsString, OsString) { - let mut it = input.splitn(2, |b| *b == b'='); - let key = it.next().unwrap().to_vec(); - let default: &[u8] = &[]; - let val = it.next().unwrap_or(default).to_vec(); - (OsStringExt::from_vec(key), OsStringExt::from_vec(val)) + fn parse(input: &[u8]) -> Option<(OsString, OsString)> { + // Strategy (copied from glibc): Variable name and value are separated + // by an ASCII equals sign '='. Since a variable name must not be + // empty, allow variable names starting with an equals sign. Skip all + // malformed lines. + if input.is_empty() { + return None; + } + let pos = input[1..].iter().position(|&b| b == b'=').map(|p| p + 1); + pos.map(|p| ( + OsStringExt::from_vec(input[..p].to_vec()), + OsStringExt::from_vec(input[p+1..].to_vec()), + )) } } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1f34af617d5..e4697a7fd91 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -20,7 +20,6 @@ pub use self::Expr_::*; pub use self::FloatTy::*; pub use self::FunctionRetTy::*; pub use self::ForeignItem_::*; -pub use self::ImplItem_::*; pub use self::IntTy::*; pub use self::Item_::*; pub use self::KleeneOp::*; @@ -1230,16 +1229,16 @@ pub struct ImplItem { pub ident: Ident, pub vis: Visibility, pub attrs: Vec<Attribute>, - pub node: ImplItem_, + pub node: ImplItemKind, pub span: Span, } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum ImplItem_ { - ConstImplItem(P<Ty>, P<Expr>), - MethodImplItem(MethodSig, P<Block>), - TypeImplItem(P<Ty>), - MacImplItem(Mac), +pub enum ImplItemKind { + Const(P<Ty>, P<Expr>), + Method(MethodSig, P<Block>), + Type(P<Ty>), + Macro(Mac), } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] @@ -1687,9 +1686,9 @@ pub enum Visibility { impl Visibility { pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility { - match self { - &Inherited => parent_visibility, - &Public => *self + match *self { + Inherited => parent_visibility, + Public => *self } } } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index f1fd8be4728..870dea02212 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -174,6 +174,10 @@ impl SpanHandler { self.handler.emit(Some((&self.cm, sp)), msg, Bug); panic!(ExplicitBug); } + pub fn span_bug_no_panic(&self, sp: Span, msg: &str) { + self.handler.emit(Some((&self.cm, sp)), msg, Bug); + self.handler.bump_err_count(); + } pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! { self.span_bug(sp, &format!("unimplemented {}", msg)); } diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 5a0fc4fda0c..625abf706ca 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -480,7 +480,7 @@ impl<'a> TraitDef<'a> { ident: ident, vis: ast::Inherited, attrs: Vec::new(), - node: ast::TypeImplItem(type_def.to_ty(cx, + node: ast::ImplItemKind::Type(type_def.to_ty(cx, self.span, type_ident, generics @@ -895,7 +895,7 @@ impl<'a> MethodDef<'a> { span: trait_.span, vis: ast::Inherited, ident: method_ident, - node: ast::MethodImplItem(ast::MethodSig { + node: ast::ImplItemKind::Method(ast::MethodSig { generics: fn_generics, abi: abi, explicit_self: explicit_self, diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index 9e8e68c0b8c..67826c9c6cd 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -242,8 +242,8 @@ impl<'a> LifetimeBounds<'a> { cx.lifetime_def(span, cx.ident_of(*lt).name, bounds) }).collect(); let ty_params = self.bounds.iter().map(|t| { - match t { - &(ref name, ref bounds) => { + match *t { + (ref name, ref bounds) => { mk_ty_param(cx, span, *name, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index ba07c452e2a..a0e4fd301a2 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1030,23 +1030,23 @@ fn expand_item_multi_modifier(mut it: Annotatable, fn expand_impl_item(ii: P<ast::ImplItem>, fld: &mut MacroExpander) -> SmallVector<P<ast::ImplItem>> { match ii.node { - ast::MethodImplItem(..) => SmallVector::one(ii.map(|ii| ast::ImplItem { + ast::ImplItemKind::Method(..) => SmallVector::one(ii.map(|ii| ast::ImplItem { id: ii.id, ident: ii.ident, attrs: ii.attrs, vis: ii.vis, node: match ii.node { - ast::MethodImplItem(sig, body) => { + ast::ImplItemKind::Method(sig, body) => { let (sig, body) = expand_and_rename_method(sig, body, fld); - ast::MethodImplItem(sig, body) + ast::ImplItemKind::Method(sig, body) } _ => unreachable!() }, span: fld.new_span(ii.span) })), - ast::MacImplItem(_) => { + ast::ImplItemKind::Macro(_) => { let (span, mac) = ii.and_then(|ii| match ii.node { - ast::MacImplItem(mac) => (ii.span, mac), + ast::ImplItemKind::Macro(mac) => (ii.span, mac), _ => unreachable!() }); let maybe_new_items = diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index d743a601bbb..5e5b8158181 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -63,9 +63,9 @@ pub mod rt { impl<T: ToTokens> ToTokens for Option<T> { fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> { - match self { - &Some(ref t) => t.to_tokens(cx), - &None => Vec::new(), + match *self { + Some(ref t) => t.to_tokens(cx), + None => Vec::new(), } } } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index dded634882d..675482fd644 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -107,16 +107,16 @@ enum TokenTreeOrTokenTreeVec { impl TokenTreeOrTokenTreeVec { fn len(&self) -> usize { - match self { - &TtSeq(ref v) => v.len(), - &Tt(ref tt) => tt.len(), + match *self { + TtSeq(ref v) => v.len(), + Tt(ref tt) => tt.len(), } } fn get_tt(&self, index: usize) -> TokenTree { - match self { - &TtSeq(ref v) => v[index].clone(), - &Tt(ref tt) => tt.get_tt(index), + match *self { + TtSeq(ref v) => v[index].clone(), + Tt(ref tt) => tt.get_tt(index), } } } @@ -144,17 +144,17 @@ pub struct MatcherPos { pub fn count_names(ms: &[TokenTree]) -> usize { ms.iter().fold(0, |count, elt| { - count + match elt { - &TokenTree::Sequence(_, ref seq) => { + count + match *elt { + TokenTree::Sequence(_, ref seq) => { seq.num_captures } - &TokenTree::Delimited(_, ref delim) => { + TokenTree::Delimited(_, ref delim) => { count_names(&delim.tts) } - &TokenTree::Token(_, MatchNt(..)) => { + TokenTree::Token(_, MatchNt(..)) => { 1 } - &TokenTree::Token(_, _) => 0, + TokenTree::Token(_, _) => 0, } }) } @@ -203,18 +203,18 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>]) -> HashMap<Name, Rc<NamedMatch>> { fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>], ret_val: &mut HashMap<Name, Rc<NamedMatch>>, idx: &mut usize) { - match m { - &TokenTree::Sequence(_, ref seq) => { + match *m { + TokenTree::Sequence(_, ref seq) => { for next_m in &seq.tts { n_rec(p_s, next_m, res, ret_val, idx) } } - &TokenTree::Delimited(_, ref delim) => { + TokenTree::Delimited(_, ref delim) => { for next_m in &delim.tts { n_rec(p_s, next_m, res, ret_val, idx) } } - &TokenTree::Token(sp, MatchNt(bind_name, _, _, _)) => { + TokenTree::Token(sp, MatchNt(bind_name, _, _, _)) => { match ret_val.entry(bind_name.name) { Vacant(spot) => { spot.insert(res[*idx].clone()); @@ -228,8 +228,8 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>]) } } } - &TokenTree::Token(_, SubstNt(..)) => panic!("Cannot fill in a NT"), - &TokenTree::Token(_, _) => (), + TokenTree::Token(_, SubstNt(..)) => panic!("Cannot fill in a NT"), + TokenTree::Token(_, _) => (), } } let mut ret_val = HashMap::new(); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 64429336562..ca232963e65 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -998,12 +998,12 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> { fn visit_impl_item(&mut self, ii: &'v ast::ImplItem) { match ii.node { - ast::ConstImplItem(..) => { + ast::ImplItemKind::Const(..) => { self.gate_feature("associated_consts", ii.span, "associated constants are experimental") } - ast::MethodImplItem(ref sig, _) => { + ast::ImplItemKind::Method(ref sig, _) => { if sig.constness == ast::Constness::Const { self.gate_feature("const_fn", ii.span, "const fn is unstable"); } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 66ee5aa12ca..3dba6cbecbd 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1001,15 +1001,15 @@ pub fn noop_fold_impl_item<T: Folder>(i: P<ImplItem>, folder: &mut T) attrs: fold_attrs(attrs, folder), vis: vis, node: match node { - ConstImplItem(ty, expr) => { - ConstImplItem(folder.fold_ty(ty), folder.fold_expr(expr)) + ast::ImplItemKind::Const(ty, expr) => { + ast::ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr)) } - MethodImplItem(sig, body) => { - MethodImplItem(noop_fold_method_sig(sig, folder), + ast::ImplItemKind::Method(sig, body) => { + ast::ImplItemKind::Method(noop_fold_method_sig(sig, folder), folder.fold_block(body)) } - TypeImplItem(ty) => TypeImplItem(folder.fold_ty(ty)), - MacImplItem(mac) => MacImplItem(folder.fold_mac(mac)) + ast::ImplItemKind::Type(ty) => ast::ImplItemKind::Type(folder.fold_ty(ty)), + ast::ImplItemKind::Macro(mac) => ast::ImplItemKind::Macro(folder.fold_mac(mac)) }, span: folder.new_span(span) })) diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index e1d8a4d8c54..cb2181a0831 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -26,6 +26,7 @@ use std::rc::Rc; pub use ext::tt::transcribe::{TtReader, new_tt_reader, new_tt_reader_with_doc_flag}; pub mod comments; +mod unicode_chars; pub trait Reader { fn is_eof(&self) -> bool; @@ -1224,7 +1225,8 @@ impl<'a> StringReader<'a> { c => { let last_bpos = self.last_pos; let bpos = self.pos; - panic!(self.fatal_span_char(last_bpos, bpos, "unknown start of token", c)); + unicode_chars::check_for_substitution(&self, c); + panic!(self.fatal_span_char(last_bpos, bpos, "unknown start of token", c)) } } } diff --git a/src/libsyntax/parse/lexer/unicode_chars.rs b/src/libsyntax/parse/lexer/unicode_chars.rs new file mode 100644 index 00000000000..dbec1a8851c --- /dev/null +++ b/src/libsyntax/parse/lexer/unicode_chars.rs @@ -0,0 +1,186 @@ +// Copyright 2012-2013 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. + +// Characters and their corresponding confusables were collected from +// http://www.unicode.org/Public/security/revision-06/confusables.txt + +use codemap::mk_sp as make_span; +use super::StringReader; + +const UNICODE_ARRAY: &'static [(char, &'static str, char)] = &[ + ('ߺ', "Nko Lajanyalan", '_'), + ('﹍', "Dashed Low Line", '_'), + ('﹎', "Centreline Low Line", '_'), + ('﹏', "Wavy Low Line", '_'), + ('‐', "Hyphen", '-'), + ('‑', "Non-Breaking Hyphen", '-'), + ('‒', "Figure Dash", '-'), + ('–', "En Dash", '-'), + ('﹘', "Small Em Dash", '-'), + ('⁃', "Hyphen Bullet", '-'), + ('˗', "Modifier Letter Minus Sign", '-'), + ('−', "Minus Sign", '-'), + ('٫', "Arabic Decimal Separator", ','), + ('‚', "Single Low-9 Quotation Mark", ','), + ('ꓹ', "Lisu Letter Tone Na Po", ','), + (';', "Greek Question Mark", ';'), + ('ः', "Devanagari Sign Visarga", ':'), + ('ઃ', "Gujarati Sign Visarga", ':'), + (':', "Fullwidth Colon", ':'), + ('։', "Armenian Full Stop", ':'), + ('܃', "Syriac Supralinear Colon", ':'), + ('܄', "Syriac Sublinear Colon", ':'), + ('︰', "Presentation Form For Vertical Two Dot Leader", ':'), + ('᠃', "Mongolian Full Stop", ':'), + ('᠉', "Mongolian Manchu Full Stop", ':'), + ('⁚', "Two Dot Punctuation", ':'), + ('׃', "Hebrew Punctuation Sof Pasuq", ':'), + ('˸', "Modifier Letter Raised Colon", ':'), + ('꞉', "Modifier Letter Colon", ':'), + ('∶', "Ratio", ':'), + ('ː', "Modifier Letter Triangular Colon", ':'), + ('ꓽ', "Lisu Letter Tone Mya Jeu", ':'), + ('!', "Fullwidth Exclamation Mark", '!'), + ('ǃ', "Latin Letter Retroflex Click", '!'), + ('ʔ', "Latin Letter Glottal Stop", '?'), + ('ॽ', "Devanagari Letter Glottal Stop", '?'), + ('Ꭾ', "Cherokee Letter He", '?'), + ('𝅭', "Musical Symbol Combining Augmentation Dot", '.'), + ('․', "One Dot Leader", '.'), + ('۔', "Arabic Full Stop", '.'), + ('܁', "Syriac Supralinear Full Stop", '.'), + ('܂', "Syriac Sublinear Full Stop", '.'), + ('꘎', "Vai Full Stop", '.'), + ('𐩐', "Kharoshthi Punctuation Dot", '.'), + ('٠', "Arabic-Indic Digit Zero", '.'), + ('۰', "Extended Arabic-Indic Digit Zero", '.'), + ('ꓸ', "Lisu Letter Tone Mya Ti", '.'), + ('՝', "Armenian Comma", '\''), + (''', "Fullwidth Apostrophe", '\''), + ('‘', "Left Single Quotation Mark", '\''), + ('’', "Right Single Quotation Mark", '\''), + ('‛', "Single High-Reversed-9 Quotation Mark", '\''), + ('′', "Prime", '\''), + ('‵', "Reversed Prime", '\''), + ('՚', "Armenian Apostrophe", '\''), + ('׳', "Hebrew Punctuation Geresh", '\''), + ('`', "Greek Varia", '\''), + ('`', "Fullwidth Grave Accent", '\''), + ('΄', "Greek Tonos", '\''), + ('´', "Greek Oxia", '\''), + ('᾽', "Greek Koronis", '\''), + ('᾿', "Greek Psili", '\''), + ('῾', "Greek Dasia", '\''), + ('ʹ', "Modifier Letter Prime", '\''), + ('ʹ', "Greek Numeral Sign", '\''), + ('ˊ', "Modifier Letter Acute Accent", '\''), + ('ˋ', "Modifier Letter Grave Accent", '\''), + ('˴', "Modifier Letter Middle Grave Accent", '\''), + ('ʻ', "Modifier Letter Turned Comma", '\''), + ('ʽ', "Modifier Letter Reversed Comma", '\''), + ('ʼ', "Modifier Letter Apostrophe", '\''), + ('ʾ', "Modifier Letter Right Half Ring", '\''), + ('ꞌ', "Latin Small Letter Saltillo", '\''), + ('י', "Hebrew Letter Yod", '\''), + ('ߴ', "Nko High Tone Apostrophe", '\''), + ('ߵ', "Nko Low Tone Apostrophe", '\''), + ('[', "Fullwidth Left Square Bracket", '('), + ('❨', "Medium Left Parenthesis Ornament", '('), + ('❲', "Light Left Tortoise Shell Bracket Ornament", '('), + ('〔', "Left Tortoise Shell Bracket", '('), + ('﴾', "Ornate Left Parenthesis", '('), + (']', "Fullwidth Right Square Bracket", ')'), + ('❩', "Medium Right Parenthesis Ornament", ')'), + ('❳', "Light Right Tortoise Shell Bracket Ornament", ')'), + ('〕', "Right Tortoise Shell Bracket", ')'), + ('﴿', "Ornate Right Parenthesis", ')'), + ('❴', "Medium Left Curly Bracket Ornament", '{'), + ('❵', "Medium Right Curly Bracket Ornament", '}'), + ('⁎', "Low Asterisk", '*'), + ('٭', "Arabic Five Pointed Star", '*'), + ('∗', "Asterisk Operator", '*'), + ('᜵', "Philippine Single Punctuation", '/'), + ('⁁', "Caret Insertion Point", '/'), + ('∕', "Division Slash", '/'), + ('⁄', "Fraction Slash", '/'), + ('╱', "Box Drawings Light Diagonal Upper Right To Lower Left", '/'), + ('⟋', "Mathematical Rising Diagonal", '/'), + ('⧸', "Big Solidus", '/'), + ('㇓', "Cjk Stroke Sp", '/'), + ('〳', "Vertical Kana Repeat Mark Upper Half", '/'), + ('丿', "Cjk Unified Ideograph-4E3F", '/'), + ('⼃', "Kangxi Radical Slash", '/'), + ('\', "Fullwidth Reverse Solidus", '\\'), + ('﹨', "Small Reverse Solidus", '\\'), + ('∖', "Set Minus", '\\'), + ('⟍', "Mathematical Falling Diagonal", '\\'), + ('⧵', "Reverse Solidus Operator", '\\'), + ('⧹', "Big Reverse Solidus", '\\'), + ('㇔', "Cjk Stroke D", '\\'), + ('丶', "Cjk Unified Ideograph-4E36", '\\'), + ('⼂', "Kangxi Radical Dot", '\\'), + ('ꝸ', "Latin Small Letter Um", '&'), + ('﬩', "Hebrew Letter Alternative Plus Sign", '+'), + ('‹', "Single Left-Pointing Angle Quotation Mark", '<'), + ('❮', "Heavy Left-Pointing Angle Quotation Mark Ornament", '<'), + ('˂', "Modifier Letter Left Arrowhead", '<'), + ('꓿', "Lisu Punctuation Full Stop", '='), + ('›', "Single Right-Pointing Angle Quotation Mark", '>'), + ('❯', "Heavy Right-Pointing Angle Quotation Mark Ornament", '>'), + ('˃', "Modifier Letter Right Arrowhead", '>'), + ('Ⲻ', "Coptic Capital Letter Dialect-P Ni", '-'), + ('Ɂ', "Latin Capital Letter Glottal Stop", '?'), + ('Ⳇ', "Coptic Capital Letter Old Coptic Esh", '/'), ]; + +const ASCII_ARRAY: &'static [(char, &'static str)] = &[ + ('_', "Underscore"), + ('-', "Minus/Hyphen"), + (',', "Comma"), + (';', "Semicolon"), + (':', "Colon"), + ('!', "Exclamation Mark"), + ('?', "Question Mark"), + ('.', "Period"), + ('\'', "Single Quote"), + ('(', "Left Parenthesis"), + (')', "Right Parenthesis"), + ('{', "Left Curly Brace"), + ('}', "Right Curly Brace"), + ('*', "Asterisk"), + ('/', "Slash"), + ('\\', "Backslash"), + ('&', "Ampersand"), + ('+', "Plus Sign"), + ('<', "Less-Than Sign"), + ('=', "Equals Sign"), + ('>', "Greater-Than Sign"), ]; + +pub fn check_for_substitution(reader: &StringReader, ch: char) { + UNICODE_ARRAY + .iter() + .find(|&&(c, _, _)| c == ch) + .map(|&(_, u_name, ascii_char)| { + let span = make_span(reader.last_pos, reader.pos); + match ASCII_ARRAY.iter().find(|&&(c, _)| c == ascii_char) { + Some(&(ascii_char, ascii_name)) => { + let msg = + format!("unicode character '{}' ({}) looks much like '{}' ({}), but it's not", + ch, u_name, ascii_char, ascii_name); + reader.help_span(span, &msg); + }, + None => { + reader + .span_diagnostic + .span_bug_no_panic(span, + &format!("substitution character not found for '{}'", ch)); + } + } + }); +} diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index bde910838cb..56a06f70ed4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -17,7 +17,7 @@ use ast::{Public, Unsafety}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block}; use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause}; -use ast::{Constness, ConstImplItem, ConstTraitItem, Crate, CrateConfig}; +use ast::{Constness, ConstTraitItem, Crate, CrateConfig}; use ast::{Decl, DeclItem, DeclLocal, DefaultBlock, DefaultReturn}; use ast::{UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; @@ -39,7 +39,7 @@ use ast::{LitStr, LitInt, Local}; use ast::{MacStmtWithBraces, MacStmtWithSemicolon, MacStmtWithoutBraces}; use ast::{MutImmutable, MutMutable, Mac_}; use ast::{MutTy, BiMul, Mutability}; -use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, UnNot}; +use ast::{NamedField, UnNeg, NoReturn, UnNot}; use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange}; use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild}; use ast::{PolyTraitRef, QSelf}; @@ -52,7 +52,7 @@ use ast::{Ty, Ty_, TypeBinding, TyMac}; use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer}; use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr}; use ast::{TyRptr, TyTup, TyU32, TyVec}; -use ast::{TypeImplItem, TypeTraitItem}; +use ast::TypeTraitItem; use ast::{UnnamedField, UnsafeBlock}; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::{Visibility, WhereClause}; @@ -4425,7 +4425,7 @@ impl<'a> Parser<'a> { try!(self.expect(&token::Eq)); let typ = try!(self.parse_ty_sum()); try!(self.expect(&token::Semi)); - (name, TypeImplItem(typ)) + (name, ast::ImplItemKind::Type(typ)) } else if self.is_const_item() { try!(self.expect_keyword(keywords::Const)); let name = try!(self.parse_ident()); @@ -4434,7 +4434,7 @@ impl<'a> Parser<'a> { try!(self.expect(&token::Eq)); let expr = try!(self.parse_expr()); try!(self.commit_expr_expecting(&expr, token::Semi)); - (name, ConstImplItem(typ, expr)) + (name, ast::ImplItemKind::Const(typ, expr)) } else { let (name, inner_attrs, node) = try!(self.parse_impl_method(vis)); attrs.extend(inner_attrs); @@ -4464,7 +4464,7 @@ impl<'a> Parser<'a> { /// Parse a method or a macro invocation in a trait impl. fn parse_impl_method(&mut self, vis: Visibility) - -> PResult<(Ident, Vec<ast::Attribute>, ast::ImplItem_)> { + -> PResult<(Ident, Vec<ast::Attribute>, ast::ImplItemKind)> { // code copied from parse_macro_use_or_failure... abstraction! if !self.token.is_any_keyword() && self.look_ahead(1, |t| *t == token::Not) @@ -4490,7 +4490,7 @@ impl<'a> Parser<'a> { if delim != token::Brace { try!(self.expect(&token::Semi)) } - Ok((token::special_idents::invalid, vec![], ast::MacImplItem(m))) + Ok((token::special_idents::invalid, vec![], ast::ImplItemKind::Macro(m))) } else { let (constness, unsafety, abi) = try!(self.parse_fn_front_matter()); let ident = try!(self.parse_ident()); @@ -4500,7 +4500,7 @@ impl<'a> Parser<'a> { })); generics.where_clause = try!(self.parse_where_clause()); let (inner_attrs, body) = try!(self.parse_inner_attrs_and_block()); - Ok((ident, inner_attrs, MethodImplItem(ast::MethodSig { + Ok((ident, inner_attrs, ast::ImplItemKind::Method(ast::MethodSig { generics: generics, abi: abi, explicit_self: explicit_self, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5b8f5c0aef6..e9c716017c0 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1263,13 +1263,13 @@ impl<'a> State<'a> { _ => {} } - match opt_trait { - &Some(ref t) => { + match *opt_trait { + Some(ref t) => { try!(self.print_trait_ref(t)); try!(space(&mut self.s)); try!(self.word_space("for")); } - &None => {} + None => {} } try!(self.print_type(&**ty)); @@ -1499,10 +1499,10 @@ impl<'a> State<'a> { try!(self.print_tt(tt)); // There should be no space between the module name and the following `::` in paths, // otherwise imported macros get re-parsed from crate metadata incorrectly (#20701) - suppress_space = match tt { - &TokenTree::Token(_, token::Ident(_, token::ModName)) | - &TokenTree::Token(_, token::MatchNt(_, _, _, token::ModName)) | - &TokenTree::Token(_, token::SubstNt(_, token::ModName)) => true, + suppress_space = match *tt { + TokenTree::Token(_, token::Ident(_, token::ModName)) | + TokenTree::Token(_, token::MatchNt(_, _, _, token::ModName)) | + TokenTree::Token(_, token::SubstNt(_, token::ModName)) => true, _ => false } } @@ -1576,19 +1576,19 @@ impl<'a> State<'a> { try!(self.maybe_print_comment(ii.span.lo)); try!(self.print_outer_attributes(&ii.attrs)); match ii.node { - ast::ConstImplItem(ref ty, ref expr) => { + ast::ImplItemKind::Const(ref ty, ref expr) => { try!(self.print_associated_const(ii.ident, &ty, Some(&expr), ii.vis)); } - ast::MethodImplItem(ref sig, ref body) => { + ast::ImplItemKind::Method(ref sig, ref body) => { try!(self.head("")); try!(self.print_method_sig(ii.ident, sig, ii.vis)); try!(self.nbsp()); try!(self.print_block_with_attrs(body, &ii.attrs)); } - ast::TypeImplItem(ref ty) => { + ast::ImplItemKind::Type(ref ty) => { try!(self.print_associated_type(ii.ident, None, Some(ty))); } - ast::MacImplItem(codemap::Spanned { ref node, .. }) => { + ast::ImplItemKind::Macro(codemap::Spanned { ref node, .. }) => { // code copied from ItemMac: try!(self.print_path(&node.path, false, 0)); try!(word(&mut self.s, "! ")); @@ -2618,8 +2618,8 @@ impl<'a> State<'a> { try!(self.rbox(0, Inconsistent)); let mut first = true; if let Some(explicit_self) = opt_explicit_self { - let m = match explicit_self { - &ast::SelfStatic => ast::MutImmutable, + let m = match *explicit_self { + ast::SelfStatic => ast::MutImmutable, _ => match decl.inputs[0].pat.node { ast::PatIdent(ast::BindByValue(m), _, _) => m, _ => ast::MutImmutable @@ -2804,18 +2804,18 @@ impl<'a> State<'a> { try!(self.word_space(",")); } - match predicate { - &ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bound_lifetimes, - ref bounded_ty, - ref bounds, - ..}) => { + match *predicate { + ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bound_lifetimes, + ref bounded_ty, + ref bounds, + ..}) => { try!(self.print_formal_lifetime_list(bound_lifetimes)); try!(self.print_type(&**bounded_ty)); try!(self.print_bounds(":", bounds)); } - &ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime, - ref bounds, - ..}) => { + ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime, + ref bounds, + ..}) => { try!(self.print_lifetime(lifetime)); try!(word(&mut self.s, ":")); @@ -2827,7 +2827,7 @@ impl<'a> State<'a> { } } } - &ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => { + ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => { try!(self.print_path(path, false, 0)); try!(space(&mut self.s)); try!(self.word_space("=")); diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 7cd44e5fb4e..3e02476443a 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -353,8 +353,8 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool { let has_test_attr = attr::contains_name(&i.attrs, "test"); fn has_test_signature(i: &ast::Item) -> HasTestSignature { - match &i.node { - &ast::ItemFn(ref decl, _, _, _, ref generics, _) => { + match i.node { + ast::ItemFn(ref decl, _, _, _, ref generics, _) => { let no_output = match decl.output { ast::DefaultReturn(..) => true, ast::Return(ref t) if t.node == ast::TyTup(vec![]) => true, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index a35a1c1cffd..5d4a462e844 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -496,25 +496,25 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics } walk_list!(visitor, visit_lifetime_def, &generics.lifetimes); for predicate in &generics.where_clause.predicates { - match predicate { - &WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty, - ref bounds, - ref bound_lifetimes, - ..}) => { + match *predicate { + WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty, + ref bounds, + ref bound_lifetimes, + ..}) => { visitor.visit_ty(bounded_ty); walk_list!(visitor, visit_ty_param_bound, bounds); walk_list!(visitor, visit_lifetime_def, bound_lifetimes); } - &WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime, - ref bounds, - ..}) => { + WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime, + ref bounds, + ..}) => { visitor.visit_lifetime(lifetime); walk_list!(visitor, visit_lifetime, bounds); } - &WherePredicate::EqPredicate(WhereEqPredicate{id, - ref path, - ref ty, - ..}) => { + WherePredicate::EqPredicate(WhereEqPredicate{id, + ref path, + ref ty, + ..}) => { visitor.visit_path(path, id); visitor.visit_ty(ty); } @@ -588,18 +588,18 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt visitor.visit_ident(impl_item.span, impl_item.ident); walk_list!(visitor, visit_attribute, &impl_item.attrs); match impl_item.node { - ConstImplItem(ref ty, ref expr) => { + ImplItemKind::Const(ref ty, ref expr) => { visitor.visit_ty(ty); visitor.visit_expr(expr); } - MethodImplItem(ref sig, ref body) => { + ImplItemKind::Method(ref sig, ref body) => { visitor.visit_fn(FnKind::Method(impl_item.ident, sig, Some(impl_item.vis)), &sig.decl, body, impl_item.span, impl_item.id); } - TypeImplItem(ref ty) => { + ImplItemKind::Type(ref ty) => { visitor.visit_ty(ty); } - MacImplItem(ref mac) => { + ImplItemKind::Macro(ref mac) => { visitor.visit_mac(mac); } } diff --git a/src/test/compile-fail/const-integer-bool-ops.rs b/src/test/compile-fail/const-integer-bool-ops.rs new file mode 100644 index 00000000000..37a93ec954d --- /dev/null +++ b/src/test/compile-fail/const-integer-bool-ops.rs @@ -0,0 +1,46 @@ +// Copyright 2015 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. + +const X: usize = 42 && 39; //~ ERROR: can't do this op on unsigned integrals +const ARR: [i32; X] = [99; 34]; //~ NOTE: for array length here + +const X1: usize = 42 || 39; //~ ERROR: can't do this op on unsigned integrals +const ARR1: [i32; X1] = [99; 47]; //~ NOTE: for array length here + +// FIXME: the error should be `on signed integrals` +const X2: usize = -42 || -39; //~ ERROR: can't do this op on unsigned integrals +const ARR2: [i32; X2] = [99; 18446744073709551607]; //~ NOTE: for array length here + +// FIXME: the error should be `on signed integrals` +const X3: usize = -42 && -39; //~ ERROR: can't do this op on unsigned integrals +const ARR3: [i32; X3] = [99; 6]; //~ NOTE: for array length here + +const Y: usize = 42.0 == 42.0; +const ARRR: [i32; Y] = [99; 1]; //~ ERROR: expected constant integer expression for array length +const Y1: usize = 42.0 >= 42.0; +const ARRR1: [i32; Y] = [99; 1]; //~ ERROR: expected constant integer expression for array length +const Y2: usize = 42.0 <= 42.0; +const ARRR2: [i32; Y] = [99; 1]; //~ ERROR: expected constant integer expression for array length +const Y3: usize = 42.0 > 42.0; +const ARRR3: [i32; Y] = [99; 0]; //~ ERROR: expected constant integer expression for array length +const Y4: usize = 42.0 < 42.0; +const ARRR4: [i32; Y] = [99; 0]; //~ ERROR: expected constant integer expression for array length +const Y5: usize = 42.0 != 42.0; +const ARRR5: [i32; Y] = [99; 0]; //~ ERROR: expected constant integer expression for array length + +fn main() { + let _ = ARR; + let _ = ARRR; + let _ = ARRR1; + let _ = ARRR2; + let _ = ARRR3; + let _ = ARRR4; + let _ = ARRR5; +} diff --git a/src/test/compile-fail/issue-28586.rs b/src/test/compile-fail/issue-28586.rs new file mode 100644 index 00000000000..c8a1e424da2 --- /dev/null +++ b/src/test/compile-fail/issue-28586.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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. + +// Regression test for issue #28586 + +pub trait Foo {} +impl Foo for [u8; usize::BYTES] {} //~ ERROR E0250 + +fn main() { } diff --git a/src/test/compile-fail/lint-raw-ptr-derive.rs b/src/test/compile-fail/lint-raw-ptr-derive.rs deleted file mode 100644 index 4320b3e7441..00000000000 --- a/src/test/compile-fail/lint-raw-ptr-derive.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2013 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. - -#![allow(dead_code)] -#![deny(raw_pointer_derive)] - -#[derive(Clone)] -struct Foo { - x: *const isize //~ ERROR use of `#[derive]` with a raw pointer -} - -#[derive(Clone)] -struct Bar(*mut isize); //~ ERROR use of `#[derive]` with a raw pointer - -#[derive(Clone)] -enum Baz { - A(*const isize), //~ ERROR use of `#[derive]` with a raw pointer - B { x: *mut isize } //~ ERROR use of `#[derive]` with a raw pointer -} - -#[derive(Clone)] -struct Buzz { - x: (*const isize, //~ ERROR use of `#[derive]` with a raw pointer - *const usize) //~ ERROR use of `#[derive]` with a raw pointer -} - -fn main() {} diff --git a/src/test/run-pass/issue-21296.rs b/src/test/parse-fail/unicode-chars.rs index 5e2ac61caa2..adfaf62b5d3 100644 --- a/src/test/run-pass/issue-21296.rs +++ b/src/test/parse-fail/unicode-chars.rs @@ -8,14 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 +// compile-flags: -Z parse-only +// ignore-tidy-linelength -#[forbid(raw_pointer_derive)] -#[derive(Copy)] -struct Test(*const i32); - -impl Clone for Test { - fn clone(&self) -> Test { *self } +fn main() { + let y = 0; + //~^ ERROR unknown start of token: \u{37e} + //~^^ HELP unicode character ';' (Greek Question Mark) looks much like ';' (Semicolon), but it's not } - -fn main() {} diff --git a/src/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs new file mode 100644 index 00000000000..3ee20980747 --- /dev/null +++ b/src/test/run-pass/env-funky-keys.rs @@ -0,0 +1,45 @@ +// Copyright 2015 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. + +// Ignore this test on Android, because it segfaults there. + +// ignore-android +// ignore-windows +// no-prefer-dynamic + +#![feature(convert)] +#![feature(libc)] + +extern crate libc; + +use libc::c_char; +use libc::execve; +use std::env; +use std::ffi::OsStr; +use std::ptr; + +fn main() { + if env::args_os().next().is_none() { + for (key, value) in env::vars_os() { + panic!("found env value {:?} {:?}", key, value); + } + return; + } + + let current_exe = env::current_exe().unwrap().into_os_string().to_cstring().unwrap(); + let new_env_var = OsStr::new("FOOBAR").to_cstring().unwrap(); + let filename: *const c_char = current_exe.as_ptr(); + let argv: &[*const c_char] = &[ptr::null()]; + let envp: &[*const c_char] = &[new_env_var.as_ptr(), ptr::null()]; + unsafe { + execve(filename, &argv[0], &envp[0]); + } + panic!("execve failed"); +} diff --git a/src/test/run-pass/env-vars.rs b/src/test/run-pass/env-vars.rs index d86f63c9cb9..933d9a728db 100644 --- a/src/test/run-pass/env-vars.rs +++ b/src/test/run-pass/env-vars.rs @@ -14,10 +14,7 @@ use std::env::*; fn main() { for (k, v) in vars_os() { let v2 = var_os(&k); - // MingW seems to set some funky environment variables like - // "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned - // from vars() but not visible from var(). - assert!(v2.is_none() || v2.as_ref().map(|s| &**s) == Some(&*v), + assert!(v2.as_ref().map(|s| &**s) == Some(&*v), "bad vars->var transition: {:?} {:?} {:?}", k, v, v2); } } diff --git a/src/test/run-pass/mir_raw_fat_ptr.rs b/src/test/run-pass/mir_raw_fat_ptr.rs index 20c3357d7d2..9bbfbb68224 100644 --- a/src/test/run-pass/mir_raw_fat_ptr.rs +++ b/src/test/run-pass/mir_raw_fat_ptr.rs @@ -76,7 +76,7 @@ fn compare_au8(a: *const [u8], b: *const [u8]) -> ComparisonResults { } } -#[rustc_mir(graphviz="comparefoo.gv")] +#[rustc_mir] fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults { ComparisonResults { lt: a < b, @@ -88,7 +88,7 @@ fn compare_foo<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> ComparisonResults } } -#[rustc_mir(graphviz="simpleeq.gv")] +#[rustc_mir] fn simple_eq<'a>(a: *const (Foo+'a), b: *const (Foo+'a)) -> bool { let result = a == b; result |
