From 58e2baa1097c14a43e332b236245cb811abfe8ea Mon Sep 17 00:00:00 2001 From: Bruno Tavares Date: Mon, 2 Nov 2015 23:44:08 -0200 Subject: [PATCH 01/38] Closes #28586 --- src/test/compile-fail/issue-28586.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/compile-fail/issue-28586.rs diff --git a/src/test/compile-fail/issue-28586.rs b/src/test/compile-fail/issue-28586.rs new file mode 100644 index 0000000000000..c8a1e424da2e2 --- /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 or the MIT license +// , 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() { } From ad900dae925b11c7999fc5dbb2dc7eba3dd274b4 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 3 Nov 2015 12:46:06 -0800 Subject: [PATCH 02/38] mk: Move some old docs to the deprecated list --- mk/docs.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mk/docs.mk b/mk/docs.mk index 644fbde323c93..b0872c88c141a 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 From be9afcca8928a5fc484efe06f93d7256c95c00b6 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 3 Nov 2015 12:47:57 -0800 Subject: [PATCH 03/38] doc: Remove irrelevant info about rbe --- src/doc/index.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/doc/index.md b/src/doc/index.md index 992b6eef5e801..70d3e9781aac3 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/ From f553292cf69afcaf9975bb0226e4167caa4eebd4 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 3 Nov 2015 12:48:47 -0800 Subject: [PATCH 04/38] doc: Remove non-documentation tool links --- src/doc/index.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/doc/index.md b/src/doc/index.md index 70d3e9781aac3..e60468e483f1b 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -39,10 +39,6 @@ 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, From 53fad90608491474cfde1604ccb54dbde68cea40 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 3 Nov 2015 12:49:21 -0800 Subject: [PATCH 05/38] doc: Remove community info --- src/doc/index.md | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/doc/index.md b/src/doc/index.md index e60468e483f1b..d0dde957a7517 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -39,37 +39,6 @@ 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. -# 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: From 6ca0fa9af2ec96439ef2cbb4047f78c7adb2fe5e Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 3 Nov 2015 12:52:18 -0800 Subject: [PATCH 06/38] doc: Add the Rustonomicon --- src/doc/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/doc/index.md b/src/doc/index.md index d0dde957a7517..79f3e0aad4d02 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -31,6 +31,13 @@ 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 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 From 48c170df36ed5e7ee47ca011b0169a0a7acd199c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 3 Nov 2015 12:55:03 -0800 Subject: [PATCH 07/38] doc: Link to cargo docs, not just crates.io --- src/doc/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/index.md b/src/doc/index.md index 79f3e0aad4d02..89fa45a3ad6fe 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -40,7 +40,7 @@ how to write `unsafe` Rust code. It is for advanced Rust programmers. # 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's 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 From fcc79f2d60d55114ae890e1112393ef0e2e8d93f Mon Sep 17 00:00:00 2001 From: Alexander Bulaev Date: Wed, 4 Nov 2015 15:03:33 +0300 Subject: [PATCH 08/38] liballoc: implement From for Box, Rc, Arc Sometimes when writing generic code you want to abstract over owning/pointer type so that calling code isn't restricted by one concrete owning/pointer type. This commit makes possible such code: ``` fn i_will_work_with_arc>>(t: T) { let the_arc = t.into(); // Do something } i_will_work_with_arc(MyTy::new()); i_will_work_with_arc(Box::new(MyTy::new())); let arc_that_i_already_have = Arc::new(MyTy::new()); i_will_work_with_arc(arc_that_i_already_have); ``` Please note that this patch doesn't work with DSTs. --- src/liballoc/arc.rs | 31 +++++++++++++++++++++++++++++++ src/liballoc/boxed.rs | 8 ++++++++ src/liballoc/rc.rs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 95dcdd22fd084..36f915d19e9ca 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -84,6 +84,7 @@ use core::ptr::{self, Shared}; use core::marker::Unsize; use core::hash::{Hash, Hasher}; use core::{usize, isize}; +use core::convert::From; use heap::deallocate; const MAX_REFCOUNT: usize = (isize::MAX) as usize; @@ -894,8 +895,23 @@ impl Hash for Arc { } } +#[stable(feature = "rust1", since = "1.6.0")] +impl From for Arc { + fn from(t: T) -> Self { + Arc::new(t) + } +} + +#[stable(feature = "rust1", since = "1.6.0")] +impl From> for Arc { + fn from(t: Box) -> Self { + Arc::new(*t) + } +} + #[cfg(test)] mod tests { + use std::boxed::Box; use std::clone::Clone; use std::sync::mpsc::channel; use std::mem::drop; @@ -908,6 +924,7 @@ mod tests { use std::vec::Vec; use super::{Arc, Weak}; use std::sync::Mutex; + use std::convert::From; struct Canary(*mut atomic::AtomicUsize); @@ -1137,6 +1154,20 @@ mod tests { drop(x); assert!(y.upgrade().is_none()); } + + #[test] + fn test_from_owned() { + let foo = 123; + let foo_arc = Arc::from(foo); + assert!(123 == *foo_arc); + } + + #[test] + fn test_from_box() { + let foo_box = Box::new(123); + let foo_arc = Arc::from(foo_box); + assert!(123 == *foo_arc); + } } impl borrow::Borrow for Arc { diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 4783b4339dac3..3899c9be46d61 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -67,6 +67,7 @@ use core::ops::{CoerceUnsized, Deref, DerefMut}; use core::ops::{Placer, Boxed, Place, InPlace, BoxPlace}; use core::ptr::{self, Unique}; use core::raw::TraitObject; +use core::convert::From; /// A value that represents the heap. This is the default place that the `box` /// keyword allocates into when no place is supplied. @@ -375,6 +376,13 @@ impl Hash for Box { } } +#[stable(feature = "rust1", since = "1.6.0")] +impl From for Box { + fn from(t: T) -> Self { + Box::new(t) + } +} + impl Box { #[inline] #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index d229d1c815c2d..e7deceb94c370 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -165,6 +165,7 @@ use core::marker::{self, Unsize}; use core::mem::{self, align_of_val, size_of_val, forget}; use core::ops::{CoerceUnsized, Deref}; use core::ptr::{self, Shared}; +use core::convert::From; use heap::deallocate; @@ -698,6 +699,20 @@ impl fmt::Pointer for Rc { } } +#[stable(feature = "rust1", since = "1.6.0")] +impl From for Rc { + fn from(t: T) -> Self { + Rc::new(t) + } +} + +#[stable(feature = "rust1", since = "1.6.0")] +impl From> for Rc { + fn from(t: Box) -> Self { + Rc::new(*t) + } +} + /// A weak version of `Rc`. /// /// Weak references do not count when determining if the inner value should be @@ -903,6 +918,7 @@ mod tests { use std::result::Result::{Err, Ok}; use std::mem::drop; use std::clone::Clone; + use std::convert::From; #[test] fn test_clone() { @@ -1105,6 +1121,20 @@ mod tests { let foo: Rc<[i32]> = Rc::new([1, 2, 3]); assert_eq!(foo, foo.clone()); } + + #[test] + fn test_from_owned() { + let foo = 123; + let foo_rc = Rc::from(foo); + assert!(123 == *foo_rc); + } + + #[test] + fn test_from_box() { + let foo_box = Box::new(123); + let foo_rc = Rc::from(foo_box); + assert!(123 == *foo_rc); + } } impl borrow::Borrow for Rc { From 646b0b639228bcc5e506959e5e758f33fe6f4fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Wed, 11 Nov 2015 20:16:17 +0100 Subject: [PATCH 09/38] pass stdc++ library path after LVVM library path under openbsd, the library path of libstdc++ need to be explicit (due to the fact the default linker `cc` is gcc-4.2, and not gcc-4.9). but when a recent LLVM is installed, rustc compilation pikes the bad LLVM version (which live in /usr/local/lib, which is same directory of libestdc++.so for gcc-4.9). this patch move the libstdc++ path from RUST_FLAGS_ to special variable, and use it *after* LLVM_LIBDIR_RUSTFLAGS_ in arguments. --- mk/platform.mk | 8 +++++--- mk/target.mk | 5 ++++- mk/tests.mk | 7 ++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mk/platform.mk b/mk/platform.mk index b8058882f9d94..9d27f6b2a679e 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -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 da52b2f4d5e5b..25f0ebfd54fb9 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 052d0c18ed4e2..1dddb30376a7b 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -392,7 +392,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 @@ -662,9 +663,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 From 8ce9c19b5bf6259eeaa4482a824893cdf3dfe0e3 Mon Sep 17 00:00:00 2001 From: Alexander Bulaev Date: Thu, 12 Nov 2015 10:40:02 +0300 Subject: [PATCH 10/38] Remove impls for cases considered `niche` --- src/liballoc/arc.rs | 15 --------------- src/liballoc/rc.rs | 14 -------------- 2 files changed, 29 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 36f915d19e9ca..a2ccac3ba7eee 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -902,16 +902,8 @@ impl From for Arc { } } -#[stable(feature = "rust1", since = "1.6.0")] -impl From> for Arc { - fn from(t: Box) -> Self { - Arc::new(*t) - } -} - #[cfg(test)] mod tests { - use std::boxed::Box; use std::clone::Clone; use std::sync::mpsc::channel; use std::mem::drop; @@ -1161,13 +1153,6 @@ mod tests { let foo_arc = Arc::from(foo); assert!(123 == *foo_arc); } - - #[test] - fn test_from_box() { - let foo_box = Box::new(123); - let foo_arc = Arc::from(foo_box); - assert!(123 == *foo_arc); - } } impl borrow::Borrow for Arc { diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index e7deceb94c370..626abb0b43a0c 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -706,13 +706,6 @@ impl From for Rc { } } -#[stable(feature = "rust1", since = "1.6.0")] -impl From> for Rc { - fn from(t: Box) -> Self { - Rc::new(*t) - } -} - /// A weak version of `Rc`. /// /// Weak references do not count when determining if the inner value should be @@ -1128,13 +1121,6 @@ mod tests { let foo_rc = Rc::from(foo); assert!(123 == *foo_rc); } - - #[test] - fn test_from_box() { - let foo_box = Box::new(123); - let foo_rc = Rc::from(foo_box); - assert!(123 == *foo_rc); - } } impl borrow::Borrow for Rc { From 0b510641d3a4c4db54fed5b49fe923b1482c8ab4 Mon Sep 17 00:00:00 2001 From: Barosl Lee Date: Thu, 12 Nov 2015 18:05:45 +0900 Subject: [PATCH 11/38] Improve the detailed error message for E0432 The command-line error message for E0432 does mention the possibility of missing the `extern crate` declaration, but the detailed error message for it doesn't. Fixes #29517. --- src/librustc_resolve/diagnostics.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 4147f2bea4850..6ce70ecdd5522 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##" From 7b9b9df309f4508cd81d50d443d8c74f30fcec30 Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Thu, 12 Nov 2015 10:35:53 -0800 Subject: [PATCH 12/38] Update references and borrowing (Fixes #29730) Fixes #29730 --- src/doc/trpl/references-and-borrowing.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/doc/trpl/references-and-borrowing.md b/src/doc/trpl/references-and-borrowing.md index 944417d1096b0..d8758e0c695c2 100644 --- a/src/doc/trpl/references-and-borrowing.md +++ b/src/doc/trpl/references-and-borrowing.md @@ -171,9 +171,9 @@ to the definition of a data race: > operations are not synchronized. With references, you may have as many as you’d like, since none of them are -writing. If you are writing, you need two or more pointers to the same memory, -and you can only have one `&mut` at a time. This is how Rust prevents data -races at compile time: we’ll get errors if we break the rules. +writing. However, as we can only have one `&mut` at a time, it is impossible to +have a data race. This is how Rust prevents data races at compile time: we’ll +get errors if we break the rules. With this in mind, let’s consider our example again. @@ -378,3 +378,4 @@ statement 1 at 3:14 In the above example, `y` is declared before `x`, meaning that `y` lives longer than `x`, which is not allowed. + From d84d92bbdd049aafd7962d2133bd91b2afcfdad5 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Sat, 14 Nov 2015 23:11:20 -0500 Subject: [PATCH 13/38] AUTHORS and .mailmap cleanup --- .mailmap | 124 +++++++++++++++++++++++++++++++++-------- AUTHORS.txt | 19 +------ src/etc/add-authors.sh | 4 +- 3 files changed, 104 insertions(+), 43 deletions(-) mode change 100644 => 100755 src/etc/add-authors.sh diff --git a/.mailmap b/.mailmap index 8eaf8f16e4b6a..317a92b8f43cb 100644 --- a/.mailmap +++ b/.mailmap @@ -7,142 +7,218 @@ Aaron Todd Abhishek Chanda Abhishek Chanda +Adolfo Ochagavía +Adrien Tétar Ahmed Charles -Aydin Kim aydin.kim Alex Burka Alex Burka Alex Lyon Alex Newman Alex HotShot Newman Alex Rønne Petersen +Alexander Light Alexander Light +Alexis Beingessner Alfie John Alfie John +Anatoly Ikorsky +Andre Bogus Andreas Gal Andrew Kuchev <0coming.soon@gmail.com> Andrew <0coming.soon@gmail.com> Andrew Poelstra Anton Löfgren -Ariel Ben-Yehuda arielb1 +Areski Belaid areski Ariel Ben-Yehuda Ariel Ben-Yehuda +Ariel Ben-Yehuda arielb1 Austin Seipp +Aydin Kim aydin.kim +Barosl Lee Barosl LEE Ben Alpert -Ben Sago Ben S Ben S +Ben Sago Ben S +Ben Sago Ben S Benjamin Jackman +Bheesham Persaud Bheesham Persaud Björn Steinbrink blake2-ppc Boris Egorov +Brandon Sanderson Brandon Sanderson +Brett Cannon Brett Cannon Brian Anderson Brian Dawn +Brian Leibig Brian Leibig Carl-Anton Ingmarsson Carol (Nichols || Goulding) Carol Nichols +Carol (Nichols || Goulding) Carol Nichols Carol Willing Chris C Cerami Chris C Cerami Chris Pressey +Chris Thorn Chris Thorn Clark Gaebel +Clinton Ryan Corey Farwell Corey Farwell Corey Richardson Elaine "See More" Nemo +Damien Schoof +Daniel Ramos David Klein David Manescu -Damien Schoof +David Ross Derek Chiang Derek Chiang (Enchi Jiang) Diggory Hardy Diggory Hardy Dylan Braithwaite -Eduardo Bautista +Dzmitry Malyshau Eduardo Bautista <=> +Eduardo Bautista Elliott Slaughter Elly Fong-Jones Emily Dunham edunham -Eric Holk Eric Holk +Eric Holk Eric Holmes Eric Reed Erick Tryzelaar Evgeny Sologubov Falco Hirschenberger Felix S. Klock II Felix S Klock II +Flaper Fesp +Florian Wilkens Florian Wilkens Gareth Daniel Smith gareth +Gareth Daniel Smith Gareth Smith Georges Dubus -Graham Fawcett +Graham Fawcett Graham Fawcett Graydon Hoare Graydon Hoare -Heather +Guillaume Gomez Heather +Heather +Herman J. Radtke III Herman J. Radtke III Ilyong Cho +Ivan Ivaschenko J. J. Weber Jakub Bukaj Jakub Bukaj +Jakub Bukaj Jakub Bukaj James Deng James Miller -Jason Orendorff +James Perry +Jason Fager Jason Orendorff +Jason Orendorff +Jason Toffaletti Jason Toffaletti +Jauhien Piatlicki Jauhien Piatlicki +Jay True Jeremy Letang -Jihyun Yu jihyun -Jihyun Yu -Johann Hofmann Johann Johann Hofmann +Jihyun Yu +Jihyun Yu jihyun +Jihyun Yu Jihyun Yu +Johann Hofmann Johann John Clements John Hodge John Hodge -Jorge Aparicio +John Kåre Alsaker +John Talling Jonathan Bailey +Jonathan S Jonathan S +Jorge Aparicio +Joseph Martin +João Oliveira joaoxsouls Junyoung Cho Jyun-Yan You Kang Seonghoon -Keegan McAllister +Keegan McAllister +Kevin Butler Kyeongwoon Lee -Lee Wondong Lee Jeffery Lee Jeffery +Lee Wondong Lennart Kudling +Léo Testard Lindsey Kuper Lindsey Kuper -Luqman Aden -Luqman Aden Luke Metz +Luqman Aden +Luqman Aden Makoto Nakashima Makoto Nakashima gifnksm -Markus Westerlind Markus +Makoto Nakashima NAKASHIMA, Makoto +Marcell Pardavi Margaret Meyerhofer Mark Sinclair Mark Sinclair =Mark Sinclair <=125axel125@gmail.com> +Markus Westerlind Markus Matej Lach Matej Ľach Matt Brubeck Matthew Auld Matthew McPherrin Matthijs Hofstra Michael Williams -Michael Woerister Michael Woerister +Michael Woerister +Mickaël Raybaud-Roig m-r-r Ms2ger +Mukilan Thiagarajan +NAKASHIMA, Makoto +Nathan Wilson +Nathaniel Herman Nathaniel Herman Neil Pankey Nicholas Mazzuca Nicholas -Oliver Schneider Oliver 'ker' Schneider -Oliver Schneider Oliver Schneider Oliver Schneider Oliver Schneider +Nick Platt +Nif Ward +Oliver Schneider oli-obk +Oliver Schneider Oliver 'ker' Schneider +Oliver Schneider Oliver Schneider +Oliver Schneider Oliver Schneider +Oliver Schneider Oliver Schneider +Oliver Schneider Oliver Schneider Ožbolt Menegatti gareins Paul Faria Paul Faria Peer Aramillo Irizar parir Peter Elmers +Peter Zotov +Phil Dawes Phil Dawes Philipp Brüschweiler Philipp Brüschweiler -Pradeep Kumar Przemysław Wesołek Przemek Wesołek +Rafael Ávila de Espíndola Rafael Avila de Espindola Ralph Giles Ralph Giles +Renato Riccieri Santos Zannon Richard Diamond Rob Arnold +Rob Arnold Rob Arnold Robert Foss robertfoss Robert Gawdzik Robert Gawdzik ☢ Robert Millar +Rohit Joshi Rohit Joshi +Russell Johnston Ruud van Asseldonk Ruud van Asseldonk Ryan Scheel +S Pradeep Kumar +Scott Olson Scott Olson Sean Gillespie swgillespie Seonghyun Kim Simon Barber-Dueck Simon BD Simon Sapin +Simonas Kazlauskas Simonas Kazlauskas startling +Stepan Koltsov Stepan Koltsov Steven Fackler Steven Stewart-Gallus +Stuart Pernsteiner Stuart Pernsteiner Tamir Duberstein Tamir Duberstein +Tero Hänninen Tero Hänninen +Theo Belaire Theo Belaire Thiago Pontes thiagopnts +Thomas Bracht Laumann Jespersen Ticki Ticki <@> +Tim Brooks Tim Brooks Tim Chevalier +Tim JIANG +Tim Joseph Dumol Torsten Weber -Ulrik Sverdrup Ulrik Sverdrup +Ty Overby +Ulrik Sverdrup bluss Ulrik Sverdrup bluss bluss +Ulrik Sverdrup Ulrik Sverdrup +Vadim Petrochenkov Vadim Petrochenkov petrochenkov Vitali Haravy Vitali Haravy William Ting -Xuefeng Wu Xuefeng Wu XuefengWu +Xuefeng Wu Xuefeng Wu +Xuefeng Wu XuefengWu +York Xiang Youngsoo Son +Zach Pomerantz Zack Corr Zack Slayton +Zbigniew Siciarz Zbigniew Siciarz diff --git a/AUTHORS.txt b/AUTHORS.txt index 5f316744021ef..b7fa4a5a4a73b 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -98,7 +98,6 @@ Anton Löfgren Antti Keränen Aram Visser arcnmx -Arcterus Areski Belaid Ariel Ben-Yehuda Arjan Topolovec @@ -136,7 +135,6 @@ Ben Gesoff Ben Harris Ben Kelly Ben Noordhuis -Ben S Ben Sago Ben Striegel benaryorg @@ -434,7 +432,6 @@ Gábor Horváth Gábor Lehel Gabriel gamazeps -gareth Gareth Daniel Smith Garming Sam Garrett Heel @@ -495,7 +492,6 @@ Igor Strebezhev Ilya Dmitrichenko Ilyong Cho Ingo Blechschmidt -inrustwetrust Irving A.J. Rivas Z. Isaac Aggrey Isaac Dupree @@ -733,7 +729,6 @@ Liam Monahan Liigo Zhuang Lindsey Kuper Lionel Flandrin -llogiq Logan Chien Loïc Damien Lorenz @@ -760,7 +755,7 @@ Manuel Hoffmann Marc-Antoine Perennou Marcel Müller Marcel Rodrigues -marcell +Marcell Pardavi Marcello Seri Marcus Klaas Margaret Meyerhofer @@ -924,9 +919,7 @@ Oak OGINO Masanori OlegTsyba Oliver Schneider -Oliver Schneider -Oliver Schneider -Oliver Schneider +Oliver Schneider Olivier Saut olivren Olle Jonsson @@ -937,7 +930,6 @@ Oren Hazi Orphée Lafond-Lummis Orpheus Lummis osa1 -Overmind JIANG Ožbolt Menegatti P1start Pablo Brasero @@ -978,7 +970,6 @@ Peter Schuller Peter Williams Peter Zotov Petter Remen -pez Phil Dawes Phil Ruffwind Philip Munksgaard @@ -1065,7 +1056,6 @@ Ryan Pendleton Ryan Prichard Ryan Riginding Ryan Scheel -Ryman Ryo Munakata S Pradeep Kumar Sae-bom Kim @@ -1153,7 +1143,6 @@ Swaroop C H Sylvestre Ledru Taliesin Beynon Tamir Duberstein -Tamir Duberstein Taras Shpot tav Taylor Hutchison @@ -1169,7 +1158,6 @@ Thiago Pontes Thomas Backman Thomas Bracht Laumann Jespersen Thomas Daede -Thomas Jespersen Thomas Karpiniec Tiago Nobrega Tibor Benke @@ -1255,7 +1243,6 @@ Wei-Ming Yang Wendell Smith Wesley Wiser whataloadofwhat -whitequark wickerwaka Wilfred Hughes Will @@ -1275,8 +1262,6 @@ Xavier Shay Xiao Chuan Yu Xue Fuqiao Xuefeng Wu -Xuefeng Wu -XuefengWu Yasuhiro Fujii YawarRaza7349 Yazhong Liu diff --git a/src/etc/add-authors.sh b/src/etc/add-authors.sh old mode 100644 new mode 100755 index 3ae0ec73957e7..e45b803fa07e2 --- 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" From 67c07d445036e8db7782f3c661a8eb4a70fbe417 Mon Sep 17 00:00:00 2001 From: Alexander Bulaev Date: Mon, 16 Nov 2015 11:04:17 +0300 Subject: [PATCH 14/38] Fix feature name --- src/liballoc/arc.rs | 2 +- src/liballoc/boxed.rs | 2 +- src/liballoc/rc.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index a2ccac3ba7eee..1456baffdc9bc 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -895,7 +895,7 @@ impl Hash for Arc { } } -#[stable(feature = "rust1", since = "1.6.0")] +#[stable(feature = "from_for_ptrs", since = "1.6.0")] impl From for Arc { fn from(t: T) -> Self { Arc::new(t) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 3899c9be46d61..a40b9eb2b557c 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -376,7 +376,7 @@ impl Hash for Box { } } -#[stable(feature = "rust1", since = "1.6.0")] +#[stable(feature = "from_for_ptrs", since = "1.6.0")] impl From for Box { fn from(t: T) -> Self { Box::new(t) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 626abb0b43a0c..a835cdf129a6f 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -699,7 +699,7 @@ impl fmt::Pointer for Rc { } } -#[stable(feature = "rust1", since = "1.6.0")] +#[stable(feature = "from_for_ptrs", since = "1.6.0")] impl From for Rc { fn from(t: T) -> Self { Rc::new(t) From eaaa60dbea0aad371116cda05542cd4039942e26 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 11 Nov 2015 10:37:25 +0100 Subject: [PATCH 15/38] rename ImplItem_::*ImplItem to ImplItem_::* [breaking change] --- src/librustc/front/map/blocks.rs | 2 +- src/librustc/front/map/collector.rs | 7 +++--- src/librustc/front/map/mod.rs | 6 ++--- src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_static_recursion.rs | 2 +- src/librustc/middle/const_eval.rs | 6 ++--- src/librustc/middle/dead.rs | 12 +++++----- src/librustc/middle/infer/error_reporting.rs | 4 ++-- src/librustc/middle/reachable.rs | 12 +++++----- src/librustc/middle/ty/mod.rs | 8 +++---- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_front/fold.rs | 10 ++++---- src/librustc_front/hir.rs | 7 +++--- src/librustc_front/lowering.rs | 6 ++--- src/librustc_front/print/pprust.rs | 6 ++--- src/librustc_front/visit.rs | 6 ++--- src/librustc_lint/bad_style.rs | 2 +- src/librustc_lint/builtin.rs | 6 ++--- src/librustc_mir/mir_map.rs | 4 ++-- src/librustc_privacy/lib.rs | 24 +++++++++---------- src/librustc_resolve/lib.rs | 13 +++++----- src/librustc_trans/trans/base.rs | 4 ++-- src/librustc_trans/trans/debuginfo/mod.rs | 2 +- src/librustc_trans/trans/inline.rs | 2 +- src/librustc_trans/trans/meth.rs | 4 ++-- src/librustc_trans/trans/monomorphize.rs | 2 +- src/librustc_typeck/check/mod.rs | 18 +++++++------- src/librustc_typeck/coherence/mod.rs | 6 ++--- src/librustc_typeck/collect.rs | 16 ++++++------- src/librustdoc/clean/mod.rs | 6 ++--- 31 files changed, 103 insertions(+), 106 deletions(-) diff --git a/src/librustc/front/map/blocks.rs b/src/librustc/front/map/blocks.rs index 7d4809d457c80..d208a2cd6db84 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::ImplItem_::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 f255949a9f519..114ee53a6f4a7 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), + ImplItem_::Method(..) | ImplItem_::Const(..) => DefPathData::Value(ii.name), + ImplItem_::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) => { + ImplItem_::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 11f0fd1bb2c5e..c26616e618604 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(..) => { + ImplItem_::Const(..) => { format!("assoc const {} in {}{}", ii.name, map.path_to_string(id), id_str) } - MethodImplItem(..) => { + ImplItem_::Method(..) => { format!("method {} in {}{}", ii.name, map.path_to_string(id), id_str) } - TypeImplItem(_) => { + ImplItem_::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 1cd196895e3a4..213790ef0fbd8 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::ImplItem_::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 a3eeb12da0114..8f032c59ef569 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::ImplItem_::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 dd49010c43672..4de278e1c8d9a 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::ImplItem_::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 34d002d334277..984002f53845c 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::ImplItem_::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::ImplItem_::Const(_, ref expr) => Some(expr.id), _ => None }, _ => None @@ -996,7 +996,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::ImplItem_::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 fff080a70e622..b45c5c9bdc396 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::ImplItem_::Const(..) | + hir::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::Type(..) => {} } } diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index a16ef808bb6d3..6e07ca84c6770 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::ImplItem_::Method(ref sig, _) => { Some((&sig.decl, &sig.generics, sig.unsafety, @@ -1839,7 +1839,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt, }, ast_map::NodeImplItem(ii) => { match ii.node { - hir::MethodImplItem(ref sig, _) => { + hir::ImplItem_::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 7175fbe0e570d..3e2f24e9f45fb 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::ImplItem_::Const(..) => true, + hir::ImplItem_::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::ImplItem_::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::ImplItem_::Const(_, ref expr) => { self.visit_expr(&*expr); } - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItem_::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::ImplItem_::Type(_) => {} } } // Nothing to recurse on for these diff --git a/src/librustc/middle/ty/mod.rs b/src/librustc/middle/ty/mod.rs index 0a9fa1d6ce394..55eaa85f50898 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::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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 ccb48ed2edfaa..4f6c5ec50554b 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::ImplItem_::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_front/fold.rs b/src/librustc_front/fold.rs index 955de44b43f6e..474281008cc0d 100644 --- a/src/librustc_front/fold.rs +++ b/src/librustc_front/fold.rs @@ -867,13 +867,13 @@ pub fn noop_fold_impl_item(i: P, folder: &mut T) -> P { - ConstImplItem(folder.fold_ty(ty), folder.fold_expr(expr)) + ImplItem_::Const(ty, expr) => { + ImplItem_::Const(folder.fold_ty(ty), folder.fold_expr(expr)) } - MethodImplItem(sig, body) => { - MethodImplItem(noop_fold_method_sig(sig, folder), folder.fold_block(body)) + ImplItem_::Method(sig, body) => { + ImplItem_::Method(noop_fold_method_sig(sig, folder), folder.fold_block(body)) } - TypeImplItem(ty) => TypeImplItem(folder.fold_ty(ty)), + ImplItem_::Type(ty) => ImplItem_::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 b017a07dde0a1..b4f1d7405386d 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_::*; @@ -777,9 +776,9 @@ pub struct ImplItem { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum ImplItem_ { - ConstImplItem(P, P), - MethodImplItem(MethodSig, P), - TypeImplItem(P), + Const(P, P), + Method(MethodSig, P), + Type(P), } // Bind a type to an associated type: `A=Foo`. diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index d13b92c04f82a..1efecf16070d3 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -676,12 +676,12 @@ pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P { - hir::ConstImplItem(lower_ty(_lctx, ty), lower_expr(_lctx, expr)) + hir::ImplItem_::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)) + hir::ImplItem_::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body)) } - TypeImplItem(ref ty) => hir::TypeImplItem(lower_ty(_lctx, ty)), + TypeImplItem(ref ty) => hir::ImplItem_::Type(lower_ty(_lctx, ty)), MacImplItem(..) => 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 2fd374f756050..b4ed1d20d69d7 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -1011,16 +1011,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::ImplItem_::Const(ref ty, ref expr) => { try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis)); } - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItem_::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::ImplItem_::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 94986ceced60a..00c99a6bb8dc4 100644 --- a/src/librustc_front/visit.rs +++ b/src/librustc_front/visit.rs @@ -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) => { + ImplItem_::Const(ref ty, ref expr) => { visitor.visit_ty(ty); visitor.visit_expr(expr); } - MethodImplItem(ref sig, ref body) => { + ImplItem_::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) => { + ImplItem_::Type(ref ty) => { visitor.visit_ty(ty); } } diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index 693de1740bfee..779b772348ff1 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::ImplItem_::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 a001289b196a9..2ab28e6f2c2f9 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -505,9 +505,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::ImplItem_::Const(..) => "an associated constant", + hir::ImplItem_::Method(..) => "a method", + hir::ImplItem_::Type(_) => "an associated type", }; self.check_missing_docs_attrs(cx, Some(impl_item.id), &impl_item.attrs, diff --git a/src/librustc_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 1359cbc82a662..06700dbd40ba8 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::ImplItem_::Method(..) => { self.visit_mir(&impl_item.attrs, |c| visit::walk_impl_item(c, impl_item)); } - hir::ConstImplItem(..) | hir::TypeImplItem(..) => {} + hir::ImplItem_::Const(..) | hir::ImplItem_::Type(..) => {} } visit::walk_impl_item(self, impl_item); } diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index a8600d91a2689..a8059b676b808 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::ImplItem_::Const(..) | + hir::ImplItem_::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::ImplItem_::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::ImplItem_::Const(..) | + hir::ImplItem_::Method(..) => { self.exported_items.contains(&impl_item.id) } - hir::TypeImplItem(_) => false, + hir::ImplItem_::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::ImplItem_::Const(..) | + hir::ImplItem_::Method(..) if self.item_is_public(&impl_item.id, impl_item.vis) => { visit::walk_impl_item(self, impl_item) } - hir::TypeImplItem(..) => { + hir::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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/lib.rs b/src/librustc_resolve/lib.rs index a402d8310f96a..ea6b943e3e083 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::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::Method(ref sig, _) => sig, _ => return false, }, _ => return false, diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index ecd4c75c9d35d..ff472e4cf8848 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) } Some(hir_map::NodeImplItem(impl_item)) => { match impl_item.node { - hir::MethodImplItem(_, ref body) => body, + hir::ImplItem_::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::ImplItem_::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 9e53d72cfb8b9..7debb71cb3836 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::ImplItem_::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 14e1ca7675f79..7cccd6b38593f 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::ImplItem_::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 ff94e4feda216..8b843afdd6d78 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::ImplItem_::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::ImplItem_::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 1f9116f7491d1..976a98b077e18 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::ImplItem_::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/check/mod.rs b/src/librustc_typeck/check/mod.rs index cfa32bc073a1f..8ce4637be2628 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::ImplItem_::Const(_, ref expr) => { check_const(ccx, impl_item.span, &*expr, impl_item.id) } - hir::MethodImplItem(ref sig, ref body) => { + hir::ImplItem_::Method(ref sig, ref body) => { check_method_body(ccx, &impl_pty.generics, sig, body, impl_item.id, impl_item.span); } - hir::TypeImplItem(_) => { + hir::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::Type(_) => { ii.name == associated_type.name } _ => false, diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index b3ec10a8941dc..21d1e04d3bf76 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::ImplItem_::Const(..) => { ConstTraitItemId(impl_def_id) } - hir::MethodImplItem(..) => { + hir::ImplItem_::Method(..) => { MethodTraitItemId(impl_def_id) } - hir::TypeImplItem(_) => { + hir::ImplItem_::Type(_) => { TypeTraitItemId(impl_def_id) } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 185623a440253..869b162175e64 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::ImplItem_::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::ImplItem_::Const(_, _) => "associated constant", + hir::ImplItem_::Type(_) => "associated type", + hir::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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::ImplItem_::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 34ddd5726d385..bc07d4d937784 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1271,16 +1271,16 @@ impl Clean for hir::TraitItem { impl Clean for hir::ImplItem { fn clean(&self, cx: &DocContext) -> Item { let inner = match self.node { - hir::ConstImplItem(ref ty, ref expr) => { + hir::ImplItem_::Const(ref ty, ref expr) => { ConstantItem(Constant{ type_: ty.clean(cx), expr: expr.span.to_src(cx), }) } - hir::MethodImplItem(ref sig, _) => { + hir::ImplItem_::Method(ref sig, _) => { MethodItem(sig.clean(cx)) } - hir::TypeImplItem(ref ty) => TypedefItem(Typedef { + hir::ImplItem_::Type(ref ty) => TypedefItem(Typedef { type_: ty.clean(cx), generics: Generics { lifetimes: Vec::new(), From e36872da5b252b4cfb023c4249d68be30848ddbb Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Thu, 12 Nov 2015 15:57:51 +0100 Subject: [PATCH 16/38] ImplItem_ -> ImplItemKind rename --- src/librustc/front/map/collector.rs | 6 ++--- src/librustc/front/map/mod.rs | 6 ++--- src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_static_recursion.rs | 2 +- src/librustc/middle/const_eval.rs | 6 ++--- src/librustc/middle/dead.rs | 12 +++++----- src/librustc/middle/infer/error_reporting.rs | 4 ++-- src/librustc/middle/reachable.rs | 12 +++++----- src/librustc/middle/ty/mod.rs | 8 +++---- src/librustc_borrowck/borrowck/mod.rs | 2 +- src/librustc_front/fold.rs | 10 ++++---- src/librustc_front/hir.rs | 4 ++-- src/librustc_front/lowering.rs | 6 ++--- src/librustc_front/print/pprust.rs | 6 ++--- src/librustc_front/visit.rs | 6 ++--- src/librustc_lint/bad_style.rs | 2 +- src/librustc_lint/builtin.rs | 6 ++--- src/librustc_mir/mir_map.rs | 4 ++-- src/librustc_privacy/lib.rs | 24 +++++++++---------- src/librustc_resolve/lib.rs | 8 +++---- src/librustc_trans/trans/base.rs | 4 ++-- src/librustc_trans/trans/debuginfo/mod.rs | 2 +- src/librustc_trans/trans/inline.rs | 2 +- src/librustc_trans/trans/meth.rs | 4 ++-- src/librustc_trans/trans/monomorphize.rs | 2 +- src/librustc_typeck/check/mod.rs | 18 +++++++------- src/librustc_typeck/coherence/mod.rs | 6 ++--- src/librustc_typeck/collect.rs | 16 ++++++------- src/librustdoc/clean/mod.rs | 6 ++--- 30 files changed, 99 insertions(+), 99 deletions(-) diff --git a/src/librustc/front/map/collector.rs b/src/librustc/front/map/collector.rs index 114ee53a6f4a7..54e2563a123ba 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 { - ImplItem_::Method(..) | ImplItem_::Const(..) => DefPathData::Value(ii.name), - ImplItem_::Type(..) => 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 { - ImplItem_::Const(_, ref expr) => { + ImplItemKind::Const(_, ref expr) => { self.create_def(expr.id, DefPathData::Initializer); } _ => { } diff --git a/src/librustc/front/map/mod.rs b/src/librustc/front/map/mod.rs index c26616e618604..fb883c0ca0c08 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 { - ImplItem_::Const(..) => { + ImplItemKind::Const(..) => { format!("assoc const {} in {}{}", ii.name, map.path_to_string(id), id_str) } - ImplItem_::Method(..) => { + ImplItemKind::Method(..) => { format!("method {} in {}{}", ii.name, map.path_to_string(id), id_str) } - ImplItem_::Type(_) => { + 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 213790ef0fbd8..bfdbb6dadd43c 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::ImplItem_::Method(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 8f032c59ef569..814c7c990bd6a 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::ImplItem_::Const(_, 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 4de278e1c8d9a..ede37eb737f83 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::ImplItem_::Const(..) => { + 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 984002f53845c..2660b6447fae7 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::ImplItem_::Const(_, 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::ImplItem_::Const(_, ref expr) => Some(expr.id), + hir::ImplItemKind::Const(_, ref expr) => Some(expr.id), _ => None }, _ => None @@ -996,7 +996,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::ImplItem_::Const(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 b45c5c9bdc396..5892067ab08fe 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::ImplItem_::Const(..) | - hir::ImplItem_::Method(..) => { + 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::ImplItem_::Type(_) => {} + 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::ImplItem_::Const(_, 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::ImplItem_::Method(_, 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::ImplItem_::Type(..) => {} + hir::ImplItemKind::Type(..) => {} } } diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 6e07ca84c6770..b5f964c870d5f 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::ImplItem_::Method(ref sig, _) => { + hir::ImplItemKind::Method(ref sig, _) => { Some((&sig.decl, &sig.generics, sig.unsafety, @@ -1839,7 +1839,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt, }, ast_map::NodeImplItem(ii) => { match ii.node { - hir::ImplItem_::Method(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 3e2f24e9f45fb..e5bc9030fc97d 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::ImplItem_::Const(..) => true, - hir::ImplItem_::Method(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::ImplItem_::Type(_) => 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::ImplItem_::Const(_, ref expr) => { + hir::ImplItemKind::Const(_, ref expr) => { self.visit_expr(&*expr); } - hir::ImplItem_::Method(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::ImplItem_::Type(_) => {} + 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 55eaa85f50898..42bba0c8aeff6 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::ImplItem_::Type(_) => { + 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::ImplItem_::Const(_, _) => { + 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::ImplItem_::Method(_, 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::ImplItem_::Const(_, _) = 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 4f6c5ec50554b..f1eff5f55f29c 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::ImplItem_::Const(_, 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_front/fold.rs b/src/librustc_front/fold.rs index 474281008cc0d..f6abf46a2c43a 100644 --- a/src/librustc_front/fold.rs +++ b/src/librustc_front/fold.rs @@ -867,13 +867,13 @@ pub fn noop_fold_impl_item(i: P, folder: &mut T) -> P { - ImplItem_::Const(folder.fold_ty(ty), folder.fold_expr(expr)) + ImplItemKind::Const(ty, expr) => { + ImplItemKind::Const(folder.fold_ty(ty), folder.fold_expr(expr)) } - ImplItem_::Method(sig, body) => { - ImplItem_::Method(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)) } - ImplItem_::Type(ty) => ImplItem_::Type(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 b4f1d7405386d..eca591ef4ff52 100644 --- a/src/librustc_front/hir.rs +++ b/src/librustc_front/hir.rs @@ -770,12 +770,12 @@ pub struct ImplItem { pub name: Name, pub vis: Visibility, pub attrs: Vec, - pub node: ImplItem_, + pub node: ImplItemKind, pub span: Span, } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum ImplItem_ { +pub enum ImplItemKind { Const(P, P), Method(MethodSig, P), Type(P), diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index 1efecf16070d3..432d839796d53 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -676,12 +676,12 @@ pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P { - hir::ImplItem_::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr)) + hir::ImplItemKind::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr)) } MethodImplItem(ref sig, ref body) => { - hir::ImplItem_::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body)) + hir::ImplItemKind::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body)) } - TypeImplItem(ref ty) => hir::ImplItem_::Type(lower_ty(_lctx, ty)), + TypeImplItem(ref ty) => hir::ImplItemKind::Type(lower_ty(_lctx, ty)), MacImplItem(..) => 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 b4ed1d20d69d7..9306e60c139ba 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -1011,16 +1011,16 @@ impl<'a> State<'a> { try!(self.maybe_print_comment(ii.span.lo)); try!(self.print_outer_attributes(&ii.attrs)); match ii.node { - hir::ImplItem_::Const(ref ty, ref expr) => { + hir::ImplItemKind::Const(ref ty, ref expr) => { try!(self.print_associated_const(ii.name, &ty, Some(&expr), ii.vis)); } - hir::ImplItem_::Method(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::ImplItem_::Type(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 00c99a6bb8dc4..015e66a22399f 100644 --- a/src/librustc_front/visit.rs +++ b/src/librustc_front/visit.rs @@ -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 { - ImplItem_::Const(ref ty, ref expr) => { + ImplItemKind::Const(ref ty, ref expr) => { visitor.visit_ty(ty); visitor.visit_expr(expr); } - ImplItem_::Method(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); } - ImplItem_::Type(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 779b772348ff1..53fc0824d9673 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::ImplItem_::Const(..) => { + 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 2ab28e6f2c2f9..516c9dcae71a3 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -505,9 +505,9 @@ impl LateLintPass for MissingDoc { } let desc = match impl_item.node { - hir::ImplItem_::Const(..) => "an associated constant", - hir::ImplItem_::Method(..) => "a method", - hir::ImplItem_::Type(_) => "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_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 06700dbd40ba8..a6b7169e18b40 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::ImplItem_::Method(..) => { + hir::ImplItemKind::Method(..) => { self.visit_mir(&impl_item.attrs, |c| visit::walk_impl_item(c, impl_item)); } - hir::ImplItem_::Const(..) | hir::ImplItem_::Type(..) => {} + 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 a8059b676b808..ab9b32383b221 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::ImplItem_::Const(..) | - hir::ImplItem_::Method(..) => { + 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::ImplItem_::Type(_) => 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::ImplItem_::Const(..) | - hir::ImplItem_::Method(..) => { + hir::ImplItemKind::Const(..) | + hir::ImplItemKind::Method(..) => { self.exported_items.contains(&impl_item.id) } - hir::ImplItem_::Type(_) => 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::ImplItem_::Const(..) | - hir::ImplItem_::Method(..) + 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::ImplItem_::Type(..) => { + 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::ImplItem_::Type(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::ImplItem_::Const(..) => { + 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::ImplItem_::Method(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/lib.rs b/src/librustc_resolve/lib.rs index ea6b943e3e083..0ead5fad92f82 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2420,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 { - hir::ImplItem_::Const(..) => { + hir::ImplItemKind::Const(..) => { // If this is a trait impl, ensure the const // exists in trait this.check_trait_item(impl_item.name, @@ -2430,7 +2430,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { visit::walk_impl_item(this, impl_item); }); } - hir::ImplItem_::Method(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, @@ -2447,7 +2447,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { visit::walk_impl_item(this, impl_item); }); } - hir::ImplItem_::Type(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, @@ -3544,7 +3544,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { _ => return false, }, hir_map::NodeImplItem(impl_item) => match impl_item.node { - hir::ImplItem_::Method(ref sig, _) => sig, + hir::ImplItemKind::Method(ref sig, _) => sig, _ => return false, }, _ => return false, diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index ff472e4cf8848..c87d9ab7bf049 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) } Some(hir_map::NodeImplItem(impl_item)) => { match impl_item.node { - hir::ImplItem_::Method(_, 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::ImplItem_::Method(..) => { + 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 7debb71cb3836..74510de3f318a 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::ImplItem_::Method(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 7cccd6b38593f..0e837d83686af 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::ImplItem_::Method(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 8b843afdd6d78..20388929cbd7a 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::ImplItem_::Method(..) => { + 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::ImplItem_::Method(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 976a98b077e18..9c1fcaff7c895 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::ImplItem_::Method(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/check/mod.rs b/src/librustc_typeck/check/mod.rs index 8ce4637be2628..5ed6b62e8c3ef 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::ImplItem_::Const(_, ref expr) => { + hir::ImplItemKind::Const(_, ref expr) => { check_const(ccx, impl_item.span, &*expr, impl_item.id) } - hir::ImplItem_::Method(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::ImplItem_::Type(_) => { + 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::ImplItem_::Const(..) => { + 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::ImplItem_::Method(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::ImplItem_::Type(_) => { + 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::ImplItem_::Const(..) => { + 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::ImplItem_::Method(..) => { + 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::ImplItem_::Type(_) => { + 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 21d1e04d3bf76..6b2994d9dc06a 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::ImplItem_::Const(..) => { + hir::ImplItemKind::Const(..) => { ConstTraitItemId(impl_def_id) } - hir::ImplItem_::Method(..) => { + hir::ImplItemKind::Method(..) => { MethodTraitItemId(impl_def_id) } - hir::ImplItem_::Type(_) => { + hir::ImplItemKind::Type(_) => { TypeTraitItemId(impl_def_id) } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 869b162175e64..80f9018299245 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::ImplItem_::Type(_) => &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::ImplItem_::Const(_, _) => "associated constant", - hir::ImplItem_::Type(_) => "associated type", - hir::ImplItem_::Method(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::ImplItem_::Const(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::ImplItem_::Type(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::ImplItem_::Method(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::ImplItem_::Method(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 bc07d4d937784..6c0931155f7b1 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1271,16 +1271,16 @@ impl Clean for hir::TraitItem { impl Clean for hir::ImplItem { fn clean(&self, cx: &DocContext) -> Item { let inner = match self.node { - hir::ImplItem_::Const(ref ty, ref expr) => { + hir::ImplItemKind::Const(ref ty, ref expr) => { ConstantItem(Constant{ type_: ty.clean(cx), expr: expr.span.to_src(cx), }) } - hir::ImplItem_::Method(ref sig, _) => { + hir::ImplItemKind::Method(ref sig, _) => { MethodItem(sig.clean(cx)) } - hir::ImplItem_::Type(ref ty) => TypedefItem(Typedef { + hir::ImplItemKind::Type(ref ty) => TypedefItem(Typedef { type_: ty.clean(cx), generics: Generics { lifetimes: Vec::new(), From d09220de13a72b283d824285a2883da9e014f3f7 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 13 Nov 2015 14:15:04 +0100 Subject: [PATCH 17/38] rename `ast::ImplItem_::*ImplItem` to `ast::ImplItemKind::*` --- src/librustc/front/map/blocks.rs | 2 +- src/librustc_driver/pretty.rs | 2 +- src/librustc_front/lowering.rs | 8 ++++---- src/librustc_trans/save/dump_csv.rs | 8 ++++---- src/libsyntax/ast.rs | 13 ++++++------- src/libsyntax/ext/deriving/generic/mod.rs | 4 ++-- src/libsyntax/ext/expand.rs | 10 +++++----- src/libsyntax/feature_gate.rs | 4 ++-- src/libsyntax/fold.rs | 12 ++++++------ src/libsyntax/parse/parser.rs | 16 ++++++++-------- src/libsyntax/print/pprust.rs | 8 ++++---- src/libsyntax/visit.rs | 8 ++++---- 12 files changed, 47 insertions(+), 48 deletions(-) diff --git a/src/librustc/front/map/blocks.rs b/src/librustc/front/map/blocks.rs index d208a2cd6db84..e6c165193f032 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::ImplItem_::Method(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_driver/pretty.rs b/src/librustc_driver/pretty.rs index bdad13526b882..04f7938e9ba4f 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) -> SmallVector> { 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/lowering.rs b/src/librustc_front/lowering.rs index 432d839796d53..1a3b03a87a1a2 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -675,14 +675,14 @@ pub fn lower_impl_item(_lctx: &LoweringContext, i: &ImplItem) -> P { + ImplItemKind::Const(ref ty, ref expr) => { hir::ImplItemKind::Const(lower_ty(_lctx, ty), lower_expr(_lctx, expr)) } - MethodImplItem(ref sig, ref body) => { + ImplItemKind::Method(ref sig, ref body) => { hir::ImplItemKind::Method(lower_method_sig(_lctx, sig), lower_block(_lctx, body)) } - TypeImplItem(ref ty) => hir::ImplItemKind::Type(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_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 3ea631bd7fb67..682e203f85617 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/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1f34af617d588..cb36ceb8a9f20 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, - pub node: ImplItem_, + pub node: ImplItemKind, pub span: Span, } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] -pub enum ImplItem_ { - ConstImplItem(P, P), - MethodImplItem(MethodSig, P), - TypeImplItem(P), - MacImplItem(Mac), +pub enum ImplItemKind { + Const(P, P), + Method(MethodSig, P), + Type(P), + Macro(Mac), } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 5a0fc4fda0cca..625abf706caa4 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/expand.rs b/src/libsyntax/ext/expand.rs index ba07c452e2a59..a0e4fd301a2fb 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, fld: &mut MacroExpander) -> SmallVector> { 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/feature_gate.rs b/src/libsyntax/feature_gate.rs index 64429336562c5..ca232963e65a9 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 66ee5aa12ca88..3dba6cbecbd1c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1001,15 +1001,15 @@ pub fn noop_fold_impl_item(i: P, 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/parser.rs b/src/libsyntax/parse/parser.rs index bde910838cbae..56a06f70ed4b4 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::ImplItem_)> { + -> PResult<(Ident, Vec, 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 5b8f5c0aef6f7..2c07d75f1fa5a 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -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, "! ")); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index a35a1c1cffd28..516c983c20855 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -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); } } From 54db4d6c685e50e0162a7f48ceacca3c9eab8a1d Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 10:38:25 -0500 Subject: [PATCH 18/38] Reaffirm that this is an abstraction Fixes #29853 Fixes #29852 While these points are true, we're not going for 100% accuracy here, this is introductory material. Changing these things would be more confusing, but it is important to note that we're presenting an abstraction here. --- src/doc/trpl/the-stack-and-the-heap.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/doc/trpl/the-stack-and-the-heap.md b/src/doc/trpl/the-stack-and-the-heap.md index f835322ee716e..0c78f876aa037 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 From c545b33a7d959a05bcfc7ef6b4c303b6b87870ac Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Mon, 16 Nov 2015 17:43:09 +0100 Subject: [PATCH 19/38] Make `min_value()` and `max_value()` const functions --- src/libcore/num/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 3afc89c984142..c0f65fea7db38 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -124,15 +124,15 @@ macro_rules! int_impl { /// Returns the smallest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn min_value() -> Self { + pub const fn min_value() -> Self { (-1 as Self) << ($BITS - 1) } /// Returns the largest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn max_value() -> Self { - let min = Self::min_value(); !min + pub const fn max_value() -> Self { + !Self::min_value() } /// Converts a string slice in a given base to an integer. @@ -891,12 +891,12 @@ macro_rules! uint_impl { /// Returns the smallest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn min_value() -> Self { 0 } + pub const fn min_value() -> Self { 0 } /// Returns the largest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] #[inline] - pub fn max_value() -> Self { !0 } + pub const fn max_value() -> Self { !0 } /// Converts a string slice in a given base to an integer. /// From ca4ab32a1e9659630b319e381e0088f5011e6070 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 12:04:25 -0500 Subject: [PATCH 20/38] Nomicon: mention tuple structs with repr(c) Fixes #29526 --- src/doc/nomicon/other-reprs.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/nomicon/other-reprs.md b/src/doc/nomicon/other-reprs.md index e361fbb7ae868..2639c1d4d6f76 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 From 55ca08969428e185b896bb9b2518372f57522126 Mon Sep 17 00:00:00 2001 From: Andrew Paseltiner Date: Mon, 16 Nov 2015 12:56:18 -0500 Subject: [PATCH 21/38] Correct comment in `Mutex` example --- src/libstd/sync/mutex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index c0cd6d127d285..48631bfc5f9de 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. /// // From a6cbb97d104e439bdfb73ddd57cc6a7e6686c371 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 16 Nov 2015 21:16:44 +0300 Subject: [PATCH 22/38] Do not generate comparefoo.gv and simpleeq.gv during testing --- src/test/run-pass/mir_raw_fat_ptr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/run-pass/mir_raw_fat_ptr.rs b/src/test/run-pass/mir_raw_fat_ptr.rs index 20c3357d7d232..9bbfbb6822463 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 From 5cc0a37123258fd5207a6e67723ea2c83bc89101 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 16 Nov 2015 11:48:18 -0800 Subject: [PATCH 23/38] Minor tweaks to doc index --- src/doc/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/index.md b/src/doc/index.md index 89fa45a3ad6fe..5f2ef6107298c 100644 --- a/src/doc/index.md +++ b/src/doc/index.md @@ -33,14 +33,14 @@ something if you know its name. # The Rustonomicon -[The Rustonomicon] is an entire book dedicated dedicated to explaining +[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](http://doc.crates.io/index.html) 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 From 4a850159cd56805aa0a79ab9cb0ab1f831a97144 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 16 Nov 2015 22:49:47 +0300 Subject: [PATCH 24/38] Remove `TyParen` from HIR --- src/librustc/middle/infer/error_reporting.rs | 1 - src/librustc_front/fold.rs | 1 - src/librustc_front/hir.rs | 2 -- src/librustc_front/lowering.rs | 4 +++- src/librustc_front/print/pprust.rs | 5 ----- src/librustc_front/visit.rs | 2 +- src/librustc_typeck/astconv.rs | 1 - src/librustdoc/clean/mod.rs | 1 - 8 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index a16ef808bb6d3..835a96c640854 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -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 } diff --git a/src/librustc_front/fold.rs b/src/librustc_front/fold.rs index 955de44b43f6e..b38aae240f53b 100644 --- a/src/librustc_front/fold.rs +++ b/src/librustc_front/fold.rs @@ -382,7 +382,6 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { })) } 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 { diff --git a/src/librustc_front/hir.rs b/src/librustc_front/hir.rs index b017a07dde0a1..aa21c3ea0423e 100644 --- a/src/librustc_front/hir.rs +++ b/src/librustc_front/hir.rs @@ -848,8 +848,6 @@ pub enum Ty_ { TyObjectSum(P, TyParamBounds), /// A type like `for<'a> Foo<&'a Bar>` TyPolyTraitRef(TyParamBounds), - /// No-op; kept solely so that we can pretty-print faithfully - TyParen(P), /// Unused for now TyTypeof(P), /// 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 d13b92c04f82a..0a59191982258 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 { })) } 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 { diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index 2fd374f756050..002181c357b33 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(), diff --git a/src/librustc_front/visit.rs b/src/librustc_front/visit.rs index 94986ceced60a..8307543958f91 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) => { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 34378445c6087..7de262dfa5b95 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/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 34ddd5726d385..dbf71e431d4d1 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1606,7 +1606,6 @@ impl Clean for hir::Ty { } } TyBareFn(ref barefn) => BareFunction(box barefn.clean(cx)), - TyParen(ref ty) => ty.clean(cx), TyPolyTraitRef(ref bounds) => { PolyTraitRef(bounds.clean(cx)) }, From 9e25a1ccd32b3dd3e02ba841174fd620651bfb67 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 16:51:58 -0500 Subject: [PATCH 25/38] Improve UFCS example Fixes #29493 --- src/doc/trpl/ufcs.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/doc/trpl/ufcs.md b/src/doc/trpl/ufcs.md index 2353c63a606af..7725970564be0 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 + } +} - ::clone(self); +impl Foo for Bar { + fn foo() -> i32 { + 10 } } + +fn main() { + assert_eq!(10, ::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. From 646128d79a0f6c096470422f7748ba1566135b84 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 16:58:52 -0500 Subject: [PATCH 26/38] Remove nomicon reference to copy_lifetime Fixes #29784 --- src/doc/nomicon/unbounded-lifetimes.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/doc/nomicon/unbounded-lifetimes.md b/src/doc/nomicon/unbounded-lifetimes.md index 2c5ba79a5078f..1f2961b586136 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. From 19bd051c86f04952d107a780e25b64c38b3388b6 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Mon, 16 Nov 2015 17:01:58 -0600 Subject: [PATCH 27/38] mk/platform: support i486 and i586 target CHOST On distros that use i486 or i586 in their CHOST, Rust will fail to build because it is not handling i486 or i586 like i686 is handled. This changes the match to do work for all instances of i?86 instead of just i686. The Yocto Project still uses i586 as a target. Signed-off-by: Doug Goldstein --- mk/platform.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/platform.mk b/mk/platform.mk index b8058882f9d94..5faa3b15e2ef6 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)))) From 87243bcce8b56aa118d677c3af22d645a2ac1ab8 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Sun, 25 Oct 2015 12:05:34 +0000 Subject: [PATCH 28/38] Ignore malformed environment strings like glibc does Otherwise, the iterator and the functions for getting specific environment variables might disagree, for environments like FOOBAR Variable names starting with equals sign are OK: glibc only interprets equals signs not in the first position as separators between variable name and variable value. Instead of skipping them entirely, a leading equals sign is interpreted to be part of the variable name. --- src/libstd/sys/unix/os.rs | 25 +++++++++++----- src/test/run-pass/env-funky-keys.rs | 45 +++++++++++++++++++++++++++++ src/test/run-pass/env-vars.rs | 5 +--- 3 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 src/test/run-pass/env-funky-keys.rs diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 3c53db53f85f1..5bc5567df2f84 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -386,24 +386,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/test/run-pass/env-funky-keys.rs b/src/test/run-pass/env-funky-keys.rs new file mode 100644 index 0000000000000..3ee20980747ee --- /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 or the MIT license +// , 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 d86f63c9cb91d..933d9a728dbe7 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); } } From e4a0b48027d3d800617f05b228f0f6dfa24f6627 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 16 Nov 2015 16:57:37 -0500 Subject: [PATCH 29/38] Make note about traits that can be derived in their API docs Fixes #29711 --- src/libcore/clone.rs | 2 ++ src/libcore/cmp.rs | 8 ++++++++ src/libcore/fmt/mod.rs | 2 ++ src/libcore/hash/mod.rs | 2 ++ src/libcore/marker.rs | 4 ++++ 5 files changed, 18 insertions(+) diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index 979ddd454121d..769faedf46e8e 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 5458a7b9c38b0..3ac4ffb22364f 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 { @@ -69,6 +71,8 @@ pub trait PartialEq { /// /// 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 { // 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 { /// 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: PartialEq { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 8fe65e27c0308..dfcc5781f0873 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 0899dc2884819..ea3a2f78d564a 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/marker.rs b/src/libcore/marker.rs index 6e6ae61852787..84a6196cc87ae 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -165,6 +165,10 @@ pub trait Unsize { /// 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 { From 8600fefd9c71bf30ad3e23ffc1ef2b7cabe990b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Kr=C3=BCger?= Date: Tue, 17 Nov 2015 01:53:06 +0100 Subject: [PATCH 30/38] Fix libc module name for FreeBSD --- src/libstd/sys/unix/os.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 3c53db53f85f1..c0754ed3b940e 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 { 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 = 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 From 4ff4d3220677796f651dcd26bcaf048b61f79683 Mon Sep 17 00:00:00 2001 From: Jean Maillard Date: Tue, 17 Nov 2015 02:39:09 +0000 Subject: [PATCH 31/38] Fix grammar Change conditional perfect to past perfect. --- src/doc/trpl/ownership.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/ownership.md b/src/doc/trpl/ownership.md index d8ef44b782a1d..17b263ef00ab7 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 From 7f63c7cf4c2938c31de3d63fc769706f0d87cb54 Mon Sep 17 00:00:00 2001 From: Ravi Shankar Date: Sun, 15 Nov 2015 02:37:49 +0530 Subject: [PATCH 32/38] Detect confusing unicode characters and show the alternative --- src/libsyntax/diagnostic.rs | 4 + src/libsyntax/parse/lexer/mod.rs | 4 +- src/libsyntax/parse/lexer/unicode_chars.rs | 186 +++++++++++++++++++++ src/test/parse-fail/unicode-chars.rs | 18 ++ 4 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 src/libsyntax/parse/lexer/unicode_chars.rs create mode 100644 src/test/parse-fail/unicode-chars.rs diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index f1fd8be472830..870dea02212d1 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/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index e1d8a4d8c5423..cb2181a083177 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 0000000000000..dbec1a8851cfe --- /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 or the MIT license +// , 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/test/parse-fail/unicode-chars.rs b/src/test/parse-fail/unicode-chars.rs new file mode 100644 index 0000000000000..adfaf62b5d3cc --- /dev/null +++ b/src/test/parse-fail/unicode-chars.rs @@ -0,0 +1,18 @@ +// Copyright 2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only +// ignore-tidy-linelength + +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 +} From 95f6ea920d56d9f3db52f5fa0a81f0ec4dffde5f Mon Sep 17 00:00:00 2001 From: Seo Sanghyeon Date: Tue, 17 Nov 2015 23:24:49 +0900 Subject: [PATCH 33/38] Fix match_ref_pats flagged by Clippy --- src/libsyntax/ast.rs | 6 ++-- src/libsyntax/ext/deriving/generic/ty.rs | 4 +-- src/libsyntax/ext/quote.rs | 6 ++-- src/libsyntax/ext/tt/macro_parser.rs | 34 +++++++++++----------- src/libsyntax/print/pprust.rs | 36 ++++++++++++------------ src/libsyntax/test.rs | 4 +-- src/libsyntax/visit.rs | 24 ++++++++-------- 7 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1f34af617d588..bc8d733389613 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1687,9 +1687,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/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index 9e8e68c0b8cce..67826c9c6cdff 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/quote.rs b/src/libsyntax/ext/quote.rs index d743a601bbb4b..5e5b815818161 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -63,9 +63,9 @@ pub mod rt { impl ToTokens for Option { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { - 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 dded634882dc1..675482fd644cd 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]) -> HashMap> { fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc], ret_val: &mut HashMap>, 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]) } } } - &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/print/pprust.rs b/src/libsyntax/print/pprust.rs index 5b8f5c0aef6f7..d9c9fdd9c90d9 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 } } @@ -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 7cd44e5fb4eff..3e02476443a99 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 a35a1c1cffd28..d4b95cbed177f 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); } From 0f5ba5459b8cf75be84ab9951de379a3f9d1f9d5 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 17 Nov 2015 11:12:57 -0500 Subject: [PATCH 34/38] Mention libc from crates.io in TRPL: FFI Fixes #29762 --- src/doc/trpl/ffi.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/doc/trpl/ffi.md b/src/doc/trpl/ffi.md index 7a58a327b9f95..d949bf33b6eea 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: From dcf7e4da692661a12113144bebda99f84d76db47 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 17 Nov 2015 11:42:17 -0500 Subject: [PATCH 35/38] Clarify comment about structs and lifetimes FIxes #29742 --- src/doc/trpl/lifetimes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/trpl/lifetimes.md b/src/doc/trpl/lifetimes.md index 13265ab1eba12..68bbd0c98993d 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> { From 9ca257a5b612faa1fd0abd83608bab63393dcf5a Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 17 Nov 2015 11:54:20 -0500 Subject: [PATCH 36/38] Fix up escapes in the reference Fixes #29470 --- src/doc/reference.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index de9352a42753c..e8ad1afa9af7c 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 | From cf384c21eae3f9bd7e8d1f76ced8ad7199cd02f4 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 17 Nov 2015 11:31:13 -0500 Subject: [PATCH 37/38] Clear up the reference around let First, re-word the section on if let/while let to be more clear. Second, actually call them let statements in the statement section Fixes #29801 --- src/doc/reference.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index de9352a42753c..b057b846be7d4 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2415,9 +2415,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 +3190,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 +3212,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 From 60c84eed42c03ac6cfed92c256ce2b3be3199140 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 5 Nov 2015 14:33:30 +0100 Subject: [PATCH 38/38] Remove claims of dependency-free libcore libcore does have a few deps, like noted in https://github.com/rust-lang/rust/issues/29390 Fixes #29502 --- src/libcore/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index df7b7c437c3cc..263d01a5d2637 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.