From 09ed80fc9cb61cb9e38f0fdd9a91effb933b77b2 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 11 Aug 2015 20:12:11 -0400 Subject: [PATCH 01/10] mk/docs: remove Pandoc and LaTeX elements. --- mk/docs.mk | 91 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 89 deletions(-) diff --git a/mk/docs.mk b/mk/docs.mk index a8ab6d55d7f87..ff7f1921da30b 100644 --- a/mk/docs.mk +++ b/mk/docs.mk @@ -13,9 +13,6 @@ # # The DOCS variable is their names (with no file extension). # -# PDF_DOCS lists the targets for which PDF documentation should be -# build. -# # RUSTDOC_FLAGS_xyz variables are extra arguments to pass to the # rustdoc invocation for xyz. # @@ -35,8 +32,6 @@ DOCS += guide-crates guide-error-handling guide-ffi guide-macros guide \ guide-testing -PDF_DOCS := reference - RUSTDOC_DEPS_reference := doc/full-toc.inc RUSTDOC_FLAGS_reference := --html-in-header=doc/full-toc.inc @@ -52,13 +47,6 @@ RUSTDOC_HTML_OPTS_NO_CSS = --html-before-content=doc/version_info.html \ RUSTDOC_HTML_OPTS = $(RUSTDOC_HTML_OPTS_NO_CSS) --markdown-css rust.css -PANDOC_BASE_OPTS := --standalone --toc --number-sections -PANDOC_TEX_OPTS = $(PANDOC_BASE_OPTS) --from=markdown --to=latex \ - --include-before-body=doc/version.tex \ - --include-before-body=doc/footer.tex \ - --include-in-header=doc/uptack.tex -PANDOC_EPUB_OPTS = $(PANDOC_BASE_OPTS) --to=epub - # The rustdoc executable... RUSTDOC_EXE = $(HBIN2_H_$(CFG_BUILD))/rustdoc$(X_$(CFG_BUILD)) # ...with rpath included in case --disable-rpath was provided to @@ -89,30 +77,10 @@ else HTML_DEPS := endif -# Check for xelatex - -ifneq ($(CFG_XELATEX),) - CFG_LATEX := $(CFG_XELATEX) - XELATEX = 1 - else - $(info cfg: no xelatex found, disabling LaTeX docs) - NO_PDF_DOCS = 1 -endif - -ifeq ($(CFG_PANDOC),) -$(info cfg: no pandoc found, omitting PDF and EPUB docs) -ONLY_HTML_DOCS = 1 -endif - - ###################################################################### # Rust version ###################################################################### -doc/version.tex: $(MKFILE_DEPS) $(wildcard $(D)/*.*) | doc/ - @$(call E, version-stamp: $@) - $(Q)echo "$(CFG_VERSION)" >$@ - HTML_DEPS += doc/version_info.html doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \ $(wildcard $(D)/*.*) | doc/ @@ -121,10 +89,10 @@ doc/version_info.html: $(D)/version_info.html.template $(MKFILE_DEPS) \ s/SHORT_HASH/$(CFG_SHORT_VER_HASH)/; \ s/STAMP/$(CFG_VER_HASH)/;" $< >$@ -GENERATED += doc/version.tex doc/version_info.html +GENERATED += doc/version_info.html ###################################################################### -# Docs, from rustdoc and sometimes pandoc +# Docs from rustdoc ###################################################################### doc/: @@ -150,20 +118,6 @@ doc/footer.inc: $(D)/footer.inc | doc/ $(Q)cp -PRp $< $@ 2> /dev/null # The (english) documentation for each doc item. - -define DEF_SHOULD_BUILD_PDF_DOC -SHOULD_BUILD_PDF_DOC_$(1) = 1 -endef -$(foreach docname,$(PDF_DOCS),$(eval $(call DEF_SHOULD_BUILD_PDF_DOC,$(docname)))) - -doc/footer.tex: $(D)/footer.inc | doc/ - @$(call E, pandoc: $@) - $(CFG_PANDOC) --from=html --to=latex $< --output=$@ - -doc/uptack.tex: $(D)/uptack.tex | doc/ - $(Q)cp $< $@ - -# HTML (rustdoc) DOC_TARGETS += doc/not_found.html doc/not_found.html: $(D)/not_found.md $(HTML_DEPS) | doc/ @$(call E, rustdoc: $@) @@ -179,47 +133,6 @@ doc/$(1).html: $$(D)/$(1).md $$(HTML_DEPS) $$(RUSTDOC_DEPS_$(1)) | doc/ @$$(call E, rustdoc: $$@) $$(Q)$$(RUSTDOC) $$(RUSTDOC_HTML_OPTS) $$(RUSTDOC_FLAGS_$(1)) $$< -ifneq ($(ONLY_HTML_DOCS),1) - -# EPUB (pandoc directly) -DOC_TARGETS += doc/$(1).epub -doc/$(1).epub: $$(D)/$(1).md | doc/ - @$$(call E, pandoc: $$@) - $$(CFG_PANDOC) $$(PANDOC_EPUB_OPTS) $$< --output=$$@ - -# PDF (md =(pandoc)=> tex =(pdflatex)=> pdf) -DOC_TARGETS += doc/$(1).tex -doc/$(1).tex: $$(D)/$(1).md doc/uptack.tex doc/footer.tex doc/version.tex | doc/ - @$$(call E, pandoc: $$@) - $$(CFG_PANDOC) $$(PANDOC_TEX_OPTS) $$< --output=$$@ - -ifneq ($(NO_PDF_DOCS),1) -ifeq ($$(SHOULD_BUILD_PDF_DOC_$(1)),1) -DOC_TARGETS += doc/$(1).pdf -ifneq ($(XELATEX),1) -doc/$(1).pdf: doc/$(1).tex - @$$(call E, latex compiler: $$@) - $$(Q)$$(CFG_LATEX) \ - -interaction=batchmode \ - -output-directory=doc \ - $$< -else -# The version of xelatex on the snap bots seemingly ingores -output-directory -# So we'll output to . and move to the doc directory manually. -# This will leave some intermediate files in the build directory. -doc/$(1).pdf: doc/$(1).tex - @$$(call E, latex compiler: $$@) - $$(Q)$$(CFG_LATEX) \ - -interaction=batchmode \ - -output-directory=. \ - $$< - $$(Q)mv ./$(1).pdf $$@ -endif # XELATEX -endif # SHOULD_BUILD_PDF_DOCS_$(1) -endif # NO_PDF_DOCS - -endif # ONLY_HTML_DOCS - endef $(foreach docname,$(DOCS),$(eval $(call DEF_DOC,$(docname)))) From 31be146ba08805635839ee99db2d05f2748d6dcf Mon Sep 17 00:00:00 2001 From: Vadim Chugunov Date: Tue, 11 Aug 2015 23:19:38 -0700 Subject: [PATCH 02/10] Fix #26803 --- src/etc/make-win-dist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/make-win-dist.py b/src/etc/make-win-dist.py index defda27acc9ec..1c289e7118824 100644 --- a/src/etc/make-win-dist.py +++ b/src/etc/make-win-dist.py @@ -45,7 +45,7 @@ def make_win_dist(rust_root, gcc_root, target_triple): elif key == "libraries": lib_path.extend(val.lstrip(' =').split(';')) - target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", "windres.exe"] + target_tools = ["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe"] rustc_dlls = ["libstdc++-6.dll"] if target_triple.startswith("i686-"): From a016dfb1d110f7dfcd5f8e36ed02c2fd029532d3 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 12 Aug 2015 10:34:14 +0200 Subject: [PATCH 03/10] Fix macro expansion in for loop pattern --- src/libsyntax/ext/expand.rs | 2 +- src/test/run-pass/for-loop-macro.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/for-loop-macro.rs diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index cd60ee0691c13..6c09d6c107e6d 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -400,7 +400,7 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { // `::std::option::Option::Some() => ` let pat_arm = { let body_expr = fld.cx.expr_block(body); - let pat = noop_fold_pat(pat, fld); + let pat = fld.fold_pat(pat); let some_pat = fld.cx.pat_some(pat_span, pat); fld.cx.arm(pat_span, vec![some_pat], body_expr) diff --git a/src/test/run-pass/for-loop-macro.rs b/src/test/run-pass/for-loop-macro.rs new file mode 100644 index 0000000000000..17c5a98246b18 --- /dev/null +++ b/src/test/run-pass/for-loop-macro.rs @@ -0,0 +1,20 @@ +// 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. + +macro_rules! var { + ( $name:ident ) => ( $name ); +} + +pub fn main() { + let x = [ 3, 3, 3 ]; + for var!(i) in &x { + assert_eq!(*i, 3); + } +} From 646eace6ec5db397ba97e86df067792c0cb6be03 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Wed, 12 Aug 2015 15:39:49 +0300 Subject: [PATCH 04/10] Fix ReentrantMutex documentation wrt DerefMut Initial version of PR had an DerefMut implementation, which was later removed because it may cause mutable reference aliasing. Suggest how to implement mutability with reentrant mutex and remove the claim we implement DerefMut. --- src/libstd/sys/common/remutex.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/libstd/sys/common/remutex.rs b/src/libstd/sys/common/remutex.rs index 8f41646417367..0674618396f99 100644 --- a/src/libstd/sys/common/remutex.rs +++ b/src/libstd/sys/common/remutex.rs @@ -36,11 +36,18 @@ unsafe impl Sync for ReentrantMutex {} /// dropped (falls out of scope), the lock will be unlocked. /// /// The data protected by the mutex can be accessed through this guard via its -/// Deref and DerefMut implementations +/// Deref implementation. +/// +/// # Mutability +/// +/// Unlike `MutexGuard`, `ReentrantMutexGuard` does not implement `DerefMut`, +/// because implementation of the trait would violate Rust’s reference aliasing +/// rules. Use interior mutability (usually `RefCell`) in order to mutate the +/// guarded data. #[must_use] pub struct ReentrantMutexGuard<'a, T: 'a> { - // funny underscores due to how Deref/DerefMut currently work (they - // disregard field privacy). + // funny underscores due to how Deref currently works (it disregards field + // privacy). __lock: &'a ReentrantMutex, __poison: poison::Guard, } From e09f83ea4491ae7c1e48d667b9c552641de0ce5b Mon Sep 17 00:00:00 2001 From: Alex Ozdemir Date: Fri, 7 Aug 2015 00:10:31 -0700 Subject: [PATCH 05/10] O(1) count,nth,last for slice::Windows,Chunks(Mut) Implemented count, nth, and last in constant time for Windows, Chunks, and ChunksMut created from a slice. Included checks for overflow in the implementation of nth(). Also added a test for each implemented method to libcoretest. Addresses #24214 --- src/libcore/slice.rs | 95 +++++++++++++++++++++++++++++++ src/libcoretest/slice.rs | 120 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+) diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index f765cdc54d89b..6513c49a06ea7 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -51,6 +51,7 @@ use ptr; use mem; use mem::size_of; use marker::{Send, Sync, self}; +use num::wrapping::OverflowingOps; use raw::Repr; // Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module. use raw::Slice as RawSlice; @@ -1183,6 +1184,34 @@ impl<'a, T> Iterator for Windows<'a, T> { (size, Some(size)) } } + + #[inline] + fn count(self) -> usize { + self.size_hint().0 + } + + #[inline] + fn nth(&mut self, n: usize) -> Option { + let (end, overflow) = self.size.overflowing_add(n); + if end > self.v.len() || overflow { + self.v = &[]; + None + } else { + let nth = &self.v[n..end]; + self.v = &self.v[n+1..]; + Some(nth) + } + } + + #[inline] + fn last(self) -> Option { + if self.size > self.v.len() { + None + } else { + let start = self.v.len() - self.size; + Some(&self.v[start..]) + } + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1269,6 +1298,38 @@ impl<'a, T> Iterator for Chunks<'a, T> { (n, Some(n)) } } + + #[inline] + fn count(self) -> usize { + self.size_hint().0 + } + + #[inline] + fn nth(&mut self, n: usize) -> Option { + let (start, overflow) = n.overflowing_mul(self.size); + if start >= self.v.len() || overflow { + self.v = &[]; + None + } else { + let end = match start.checked_add(self.size) { + Some(sum) => cmp::min(self.v.len(), sum), + None => self.v.len(), + }; + let nth = &self.v[start..end]; + self.v = &self.v[end..]; + Some(nth) + } + } + + #[inline] + fn last(self) -> Option { + if self.v.is_empty() { + None + } else { + let start = (self.v.len() - 1) / self.size * self.size; + Some(&self.v[start..]) + } + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1349,6 +1410,40 @@ impl<'a, T> Iterator for ChunksMut<'a, T> { (n, Some(n)) } } + + #[inline] + fn count(self) -> usize { + self.size_hint().0 + } + + #[inline] + fn nth(&mut self, n: usize) -> Option<&'a mut [T]> { + let (start, overflow) = n.overflowing_mul(self.chunk_size); + if start >= self.v.len() || overflow { + self.v = &mut []; + None + } else { + let end = match start.checked_add(self.chunk_size) { + Some(sum) => cmp::min(self.v.len(), sum), + None => self.v.len(), + }; + let tmp = mem::replace(&mut self.v, &mut []); + let (head, tail) = tmp.split_at_mut(end); + let (_, nth) = head.split_at_mut(start); + self.v = tail; + Some(nth) + } + } + + #[inline] + fn last(self) -> Option { + if self.v.is_empty() { + None + } else { + let start = (self.v.len() - 1) / self.chunk_size * self.chunk_size; + Some(&mut self.v[start..]) + } + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcoretest/slice.rs b/src/libcoretest/slice.rs index 5a1166aeb5085..d60eeb76ccd4a 100644 --- a/src/libcoretest/slice.rs +++ b/src/libcoretest/slice.rs @@ -64,3 +64,123 @@ fn test_iterator_count() { iter2.next(); assert_eq!(iter2.count(), 3); } + +#[test] +fn test_chunks_count() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.chunks(3); + assert_eq!(c.count(), 2); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.chunks(2); + assert_eq!(c2.count(), 3); + + let v3: &[i32] = &[]; + let c3 = v3.chunks(2); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_chunks_nth() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.chunks(2); + assert_eq!(c.nth(1).unwrap()[1], 3); + assert_eq!(c.next().unwrap()[0], 4); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.chunks(3); + assert_eq!(c2.nth(1).unwrap()[1], 4); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_chunks_last() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.chunks(2); + assert_eq!(c.last().unwrap()[1], 5); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.chunks(2); + assert_eq!(c2.last().unwrap()[0], 4); +} + +#[test] +fn test_chunks_mut_count() { + let mut v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let c = v.chunks_mut(3); + assert_eq!(c.count(), 2); + + let mut v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let c2 = v2.chunks_mut(2); + assert_eq!(c2.count(), 3); + + let mut v3: &mut [i32] = &mut []; + let c3 = v3.chunks_mut(2); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_chunks_mut_nth() { + let mut v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let mut c = v.chunks_mut(2); + assert_eq!(c.nth(1).unwrap()[1], 3); + assert_eq!(c.next().unwrap()[0], 4); + + let mut v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let mut c2 = v2.chunks_mut(3); + assert_eq!(c2.nth(1).unwrap()[1], 4); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_chunks_mut_last() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let c = v.chunks_mut(2); + assert_eq!(c.last().unwrap()[1], 5); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let c2 = v2.chunks_mut(2); + assert_eq!(c2.last().unwrap()[0], 4); +} + + + + +#[test] +fn test_windows_count() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.windows(3); + assert_eq!(c.count(), 4); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.windows(6); + assert_eq!(c2.count(), 0); + + let v3: &[i32] = &[]; + let c3 = v3.windows(2); + assert_eq!(c3.count(), 0); +} + +#[test] +fn test_windows_nth() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let mut c = v.windows(2); + assert_eq!(c.nth(2).unwrap()[1], 3); + assert_eq!(c.next().unwrap()[0], 3); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let mut c2 = v2.windows(4); + assert_eq!(c2.nth(1).unwrap()[1], 2); + assert_eq!(c2.next(), None); +} + +#[test] +fn test_windows_last() { + let v: &[i32] = &[0, 1, 2, 3, 4, 5]; + let c = v.windows(2); + assert_eq!(c.last().unwrap()[1], 5); + + let v2: &[i32] = &[0, 1, 2, 3, 4]; + let c2 = v2.windows(2); + assert_eq!(c2.last().unwrap()[0], 3); +} From 1dd0c058cf1a31e2c25d5bedeaa2bab6eaa73dbc Mon Sep 17 00:00:00 2001 From: Ariel Ben-Yehuda Date: Wed, 12 Aug 2015 19:58:32 +0300 Subject: [PATCH 06/10] stop cross-crate associated types from being imported Fixes #22968 Probably fixes #27602 --- src/librustc_resolve/build_reduced_graph.rs | 5 +++++ src/test/auxiliary/use_from_trait_xc.rs | 6 ++++++ src/test/compile-fail/use-from-trait-xc.rs | 9 +++++++++ src/test/compile-fail/use-from-trait.rs | 13 +++++++++++++ 4 files changed, 33 insertions(+) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index c7e7839017930..aa2eaa866ff74 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -785,6 +785,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> { debug!("(building reduced graph for external \ crate) building type {}", final_ident); + let modifiers = match new_parent.kind.get() { + NormalModuleKind => modifiers, + _ => modifiers & !DefModifiers::IMPORTABLE + }; + child_name_bindings.define_type(def, DUMMY_SP, modifiers); } DefStruct(def_id) => { diff --git a/src/test/auxiliary/use_from_trait_xc.rs b/src/test/auxiliary/use_from_trait_xc.rs index 56fb40bc0a469..7024c9dad7c11 100644 --- a/src/test/auxiliary/use_from_trait_xc.rs +++ b/src/test/auxiliary/use_from_trait_xc.rs @@ -8,16 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(associated_consts)] + pub use self::sub::{Bar, Baz}; pub trait Trait { fn foo(&self); + type Assoc; + const CONST: u32; } struct Foo; impl Foo { pub fn new() {} + + pub const C: u32 = 0; } mod sub { diff --git a/src/test/compile-fail/use-from-trait-xc.rs b/src/test/compile-fail/use-from-trait-xc.rs index ff2824135801a..4f7e38bd26b0a 100644 --- a/src/test/compile-fail/use-from-trait-xc.rs +++ b/src/test/compile-fail/use-from-trait-xc.rs @@ -15,9 +15,18 @@ extern crate use_from_trait_xc; use use_from_trait_xc::Trait::foo; //~^ ERROR `foo` is not directly importable +use use_from_trait_xc::Trait::Assoc; +//~^ ERROR `Assoc` is not directly importable + +use use_from_trait_xc::Trait::CONST; +//~^ ERROR `CONST` is not directly importable + use use_from_trait_xc::Foo::new; //~^ ERROR `new` is not directly importable +use use_from_trait_xc::Foo::C; +//~^ ERROR unresolved import `use_from_trait_xc::Foo::C` + use use_from_trait_xc::Bar::new as bnew; //~^ ERROR `bnew` is not directly importable diff --git a/src/test/compile-fail/use-from-trait.rs b/src/test/compile-fail/use-from-trait.rs index 49d8622976bb2..28e933bc7aa0a 100644 --- a/src/test/compile-fail/use-from-trait.rs +++ b/src/test/compile-fail/use-from-trait.rs @@ -8,19 +8,32 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(associated_consts)] + use Trait::foo; //~^ ERROR `foo` is not directly importable +use Trait::Assoc; +//~^ ERROR `Assoc` is not directly importable +use Trait::C; +//~^ ERROR `C` is not directly importable + use Foo::new; //~^ ERROR unresolved import `Foo::new`. Not a module `Foo` +use Foo::C2; +//~^ ERROR unresolved import `Foo::C2`. Not a module `Foo` + pub trait Trait { fn foo(); + type Assoc; + const C: u32; } struct Foo; impl Foo { fn new() {} + const C2: u32 = 0; } fn main() {} From b7e009b386260732755784e93f9a347dca40d912 Mon Sep 17 00:00:00 2001 From: Alisdair Owens Date: Wed, 12 Aug 2015 20:50:49 +0100 Subject: [PATCH 07/10] Add long diagnostics for E0366 and E0367 --- src/librustc_typeck/diagnostics.rs | 73 +++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index bd4e4fc31107c..75adbc9e7853f 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2410,6 +2410,77 @@ fn main() { ``` "##, +E0366: r##" +An attempt was made to implement `Drop` on a concrete specialization of a +generic type. An example is shown below: + +``` +struct Foo { + t: T +} + +impl Drop for Foo { + fn drop(&mut self) {} +} +``` + +This code is not legal: it is not possible to specialize `Drop` to a subset of +implementations of a generic type. One workaround for this is to wrap the +generic type, as shown below: + +``` +struct Foo { + t: T +} + +struct Bar { + t: Foo +} + +impl Drop for Bar { + fn drop(&mut self) {} +} +``` +"##, + +E0367: r##" +An attempt was made to implement `Drop` on a specialization of a generic type. +An example is shown below: + +``` +trait Foo{} + +struct MyStruct { + t: T +} + +impl Drop for MyStruct { + fn drop(&mut self) {} +} +``` + +This code is not legal: it is not possible to specialize `Drop` to a subset of +implementations of a generic type. In order for this code to work, `MyStruct` +must also require that `T` implements `Foo`. Alternatively, another option is +to wrap the generic type in another that specializes appropriately: + +``` +trait Foo{} + +struct MyStruct { + t: T +} + +struct MyStructWrapper { + t: MyStruct +} + +impl Drop for MyStructWrapper { + fn drop(&mut self) {} +} +``` +"##, + E0368: r##" This error indicates that a binary assignment operator like `+=` or `^=` was applied to the wrong types. For example: @@ -2641,8 +2712,6 @@ register_diagnostics! { E0325, // implemented an associated type when another trait item expected E0328, // cannot implement Unsize explicitly E0329, // associated const depends on type parameter or Self. - E0366, // dropck forbid specialization to concrete type or region - E0367, // dropck forbid specialization to predicate not in struct/enum E0369, // binary operation `` cannot be applied to types E0370, // discriminant overflow E0374, // the trait `CoerceUnsized` may only be implemented for a coercion From 872f8c3234ba02b32dd40a5be08f5b1328579197 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 12 Aug 2015 15:32:36 -0700 Subject: [PATCH 08/10] libc: Fix backcompat with crates.io version The corrected signature of `ioctl` broke some crates on crates.io, and it's not currently worth the major version bump of libc, so for now keep the old signature around for crates.io builds only with a comment to remove it at a future date. This should allow libc on crates.io to update to the master version in-tree. I've verified that this was the only breakage of substance between the version libc is currently built with and today's master branch. --- src/liblibc/lib.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index 2718694490c4d..82edce6bdbd11 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -6263,11 +6263,22 @@ pub mod funcs { #[cfg(any(target_os = "linux", target_os = "android"))] pub mod bsd44 { use types::common::c95::{c_void}; - use types::os::arch::c95::{c_uchar, c_int, c_ulong, size_t}; + use types::os::arch::c95::{c_uchar, c_int, size_t}; + #[cfg(not(feature = "cargo-build"))] + use types::os::arch::c95::c_ulong; extern { #[cfg(not(all(target_os = "android", target_arch = "aarch64")))] pub fn getdtablesize() -> c_int; + + // Note that the correct signature of ioctl broke some crates on + // crates.io, so for now we keep the broken signature for crates.io + // but we fix it locally in the main Rust distribution. Once a new + // major version of libc is released on crates.io this #[cfg] should + // go away. + #[cfg(feature = "cargo-build")] + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + #[cfg(not(feature = "cargo-build"))] pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; From 43f6c2fab76fc7cf92876a7de70579e5b781196d Mon Sep 17 00:00:00 2001 From: William Throwe Date: Mon, 10 Aug 2015 19:56:26 -0400 Subject: [PATCH 09/10] Correct debug! documentation When --cfg ndebug changed to -C debug-assertions the documentation was updated to reflect the new name, but not that the meaning was reversed. --- src/liblog/macros.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs index c9a3e39c42351..46b51f50c8583 100644 --- a/src/liblog/macros.rs +++ b/src/liblog/macros.rs @@ -135,9 +135,9 @@ macro_rules! info { ($($arg:tt)*) => (log!(::log::INFO, $($arg)*)) } -/// A convenience macro for logging at the debug log level. This macro can also -/// be omitted at compile time by passing `-C debug-assertions` to the compiler. If -/// this option is not passed, then debug statements will be compiled. +/// A convenience macro for logging at the debug log level. This macro will +/// be omitted at compile time in an optimized build unless `-C debug-assertions` +/// is passed to the compiler. /// /// # Examples /// From 75f7a68ffa2b8ff0a9292d3d751fc4f28c074f72 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 11 Aug 2015 20:12:31 -0400 Subject: [PATCH 10/10] doc/readme: replace references to Pandoc with rustdoc. --- src/doc/README.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/doc/README.md b/src/doc/README.md index 3b12ffe8f11e1..c09f28ae4f62d 100644 --- a/src/doc/README.md +++ b/src/doc/README.md @@ -1,11 +1,5 @@ # Rust documentations -## Dependencies - -[Pandoc](http://johnmacfarlane.net/pandoc/installing.html), a universal -document converter, is required to generate docs as HTML from Rust's -source code. - ## Building To generate all the docs, just run `make docs` from the root of the repository. @@ -26,15 +20,12 @@ To generate an HTML version of a doc from Markdown manually, you can do something like: ~~~~ -pandoc --from=markdown --to=html5 --number-sections -o reference.html reference.md +rustdoc reference.md ~~~~ (`reference.md` being the Rust Reference Manual.) -The syntax for pandoc flavored markdown can be found at: - -- http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown - -A nice quick reference (for non-pandoc markdown) is at: +An overview of how to use the `rustdoc` command is available [in the docs][1]. +Further details are available from the command line by with `rustdoc --help`. -- http://kramdown.gettalong.org/quickref.html +[1]: https://github.com/rust-lang/rust/blob/master/src/doc/trpl/documentation.md