From ba53f956769362329a83d73561c6790c91ae7c4d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 11 Jul 2017 17:44:48 -0700 Subject: [PATCH 01/30] E0122: clarify wording --- src/librustc_typeck/diagnostics.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 87e59683fd2a8..050d896781652 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1611,8 +1611,8 @@ static BAR: _ = "test"; // error, explicitly write out the type instead "##, E0122: r##" -An attempt was made to add a generic constraint to a type alias. While Rust will -allow this with a warning, it will not currently enforce the constraint. +An attempt was made to add a generic constraint to a type alias. This constraint is +entirely ignored. For backwards compatibility, Rust still allows this with a warning. Consider the example below: ``` From 5067ef224f1dd2b14a0907e9b058b25f48a82abd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 11 Jul 2017 21:10:57 -0700 Subject: [PATCH 02/30] fix line lengths --- src/librustc_typeck/diagnostics.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 050d896781652..2b2ff66e3b375 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -1611,9 +1611,9 @@ static BAR: _ = "test"; // error, explicitly write out the type instead "##, E0122: r##" -An attempt was made to add a generic constraint to a type alias. This constraint is -entirely ignored. For backwards compatibility, Rust still allows this with a warning. -Consider the example below: +An attempt was made to add a generic constraint to a type alias. This constraint +is entirely ignored. For backwards compatibility, Rust still allows this with a +warning. Consider the example below: ``` trait Foo{} From 5b30cc178a5f890a9b5b1930a7062e8b05544f49 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Thu, 3 Aug 2017 21:13:27 +0200 Subject: [PATCH 03/30] Detect relative urls in tidy check --- src/tools/tidy/src/style.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index b42beb37821ce..d0483e64b4030 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -79,11 +79,11 @@ fn line_is_url(line: &str) -> bool { => state = EXP_URL, (EXP_LINK_LABEL_OR_URL, w) - if w.starts_with("http://") || w.starts_with("https://") + if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../") => state = EXP_END, (EXP_URL, w) - if w.starts_with("http://") || w.starts_with("https://") + if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../") => state = EXP_END, (_, _) => return false, From 0f924b86c496bf4224fc5f84b7ce40c93bb2c7a9 Mon Sep 17 00:00:00 2001 From: arshiamufti Date: Fri, 4 Aug 2017 00:53:09 -0700 Subject: [PATCH 04/30] add test --- src/test/run-pass/weird-exprs.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index 20f58301d4524..64fd9e0a7721b 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -107,6 +107,10 @@ fn fishy() { String::<>::from::<>("><>").chars::<>().rev::<>().collect::()); } +fn union() { + union union<'union> { union: &'union union<'union>, } +} + pub fn main() { strange(); funny(); @@ -119,4 +123,5 @@ pub fn main() { dots(); you_eight(); fishy(); + union(); } From 608863d81770c804f6e527ec16b2cc843ee0c050 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Fri, 4 Aug 2017 13:24:00 +0200 Subject: [PATCH 05/30] Only allow long relative urls after a link label Yellow is indeed a nice color for a bikeshed. --- src/tools/tidy/src/style.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index d0483e64b4030..a689d8a8be411 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -79,7 +79,7 @@ fn line_is_url(line: &str) -> bool { => state = EXP_URL, (EXP_LINK_LABEL_OR_URL, w) - if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../") + if w.starts_with("http://") || w.starts_with("https://") => state = EXP_END, (EXP_URL, w) From b298a58c782f1434b09d4aaea6bffd4f99d3e7f6 Mon Sep 17 00:00:00 2001 From: Natalie Boehm Date: Fri, 4 Aug 2017 12:25:05 -0400 Subject: [PATCH 06/30] Update String Deref to explain why using &String does not always work --- src/liballoc/string.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 622cc68964bf7..110699c1e03bd 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -144,7 +144,7 @@ use boxed::Box; /// # Deref /// /// `String`s implement [`Deref`]``, and so inherit all of [`str`]'s -/// methods. In addition, this means that you can pass a `String` to any +/// methods. In addition, this means that you can pass a `String` to a /// function which takes a [`&str`] by using an ampersand (`&`): /// /// ``` @@ -160,8 +160,31 @@ use boxed::Box; /// /// This will create a [`&str`] from the `String` and pass it in. This /// conversion is very inexpensive, and so generally, functions will accept -/// [`&str`]s as arguments unless they need a `String` for some specific reason. +/// [`&str`]s as arguments unless they need a `String` for some specific +/// reason. /// +/// In certain cases Rust doesn't have enough information to make this conversion, +/// known as deref coercion. For example, in this case a string slice implements +/// a trait and the function takes anything that implements the trait, Rust would +/// need to make two implicit conversions which Rust doesn't know how to do. The +/// following example will not compile for that reason. +/// +/// ```compile_fail,E0277 +/// trait TraitExample {} +/// +/// impl<'a> TraitExample for &'a str {} +/// +/// fn example_func(example_arg: A) {} +/// +/// fn main() { +/// let example_string = String::from("example_string"); +/// example_func(&example_string); +/// } +/// ``` +/// +/// What would work in this case is changing the line `example_func(&example_string);` +/// to `example_func(example_string.to_str());`. This works because we're doing the +/// conversion explicitly, rather than relying on the implicit conversion. /// /// # Representation /// From 94f7511ac242dbdc171be2acefa089e5a9b32562 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 4 Aug 2017 17:00:21 -0700 Subject: [PATCH 07/30] test MIR validation statements in closures --- src/test/mir-opt/validate_1.rs | 28 +++++++++++++++++++++++----- src/test/mir-opt/validate_4.rs | 25 ++++++++++++++++++++++++- src/test/mir-opt/validate_5.rs | 26 +++++++++++++++++++++----- 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/src/test/mir-opt/validate_1.rs b/src/test/mir-opt/validate_1.rs index 9ac76a5f4ea61..677c92ea71b7a 100644 --- a/src/test/mir-opt/validate_1.rs +++ b/src/test/mir-opt/validate_1.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-tidy-linelength -// compile-flags: -Z verbose -Z mir-emit-validate=1 +// compile-flags: -Z verbose -Z mir-emit-validate=1 -Z span_free_formats struct Test(i32); @@ -20,16 +20,13 @@ impl Test { fn main() { let mut x = 0; - Test(0).foo(&mut x); + Test(0).foo(&mut x); // just making sure we do not panic when there is a tuple struct ctor // Also test closures let c = |x: &mut i32| { let y = &*x; *y }; c(&mut x); } -// FIXME: Also test code generated inside the closure, make sure it has validation. Unfortunately, -// the interesting lines of code also contain name of the source file, so we cannot test for it. - // END RUST SOURCE // START rustc.node12.EraseRegions.after.mir // bb0: { @@ -57,3 +54,24 @@ fn main() { // } // } // END rustc.node23.EraseRegions.after.mir +// START rustc.node50.EraseRegions.after.mir +// fn main::{{closure}}(_1: &ReErased [closure@NodeId(50)], _2: &ReErased mut i32) -> i32 { +// bb0: { +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_1/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(50)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_1/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// StorageLive(_3); +// _3 = _2; +// StorageLive(_4); +// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 }))), [(*_3): i32]); +// _4 = &ReErased (*_3); +// Validate(Acquire, [(*_4): i32/ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 })) (imm)]); +// StorageLive(_5); +// _5 = (*_4); +// _0 = _5; +// StorageDead(_5); +// StorageDead(_4); +// EndRegion(ReScope(Remainder(BlockRemainder { block: NodeId(41), first_statement_index: 0 }))); +// StorageDead(_3); +// return; +// } +// } +// END rustc.node50.EraseRegions.after.mir diff --git a/src/test/mir-opt/validate_4.rs b/src/test/mir-opt/validate_4.rs index 591de975740f9..2ee459d6809c5 100644 --- a/src/test/mir-opt/validate_4.rs +++ b/src/test/mir-opt/validate_4.rs @@ -9,7 +9,7 @@ // except according to those terms. // ignore-tidy-linelength -// compile-flags: -Z verbose -Z mir-emit-validate=1 +// compile-flags: -Z verbose -Z mir-emit-validate=1 -Z span_free_formats // Make sure unsafe fns and fns with an unsafe block only get restricted validation. @@ -45,6 +45,19 @@ fn main() { // } // } // END rustc.node4.EraseRegions.after.mir +// START rustc.node22.EraseRegions.after.mir +// fn write_42::{{closure}}(_1: &ReErased [closure@NodeId(22)], _2: *mut i32) -> () { +// bb0: { +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483659) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483659) => validate_4/8cd878b::write_42[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(22)], _2: *mut i32]); +// StorageLive(_3); +// _3 = _2; +// (*_3) = const 23i32; +// StorageDead(_3); +// return; +// } +// } +// END rustc.node22.EraseRegions.after.mir // START rustc.node31.EraseRegions.after.mir // fn test(_1: &ReErased mut i32) -> () { // bb0: { @@ -58,3 +71,13 @@ fn main() { // } // } // END rustc.node31.EraseRegions.after.mir +// START rustc.node60.EraseRegions.after.mir +// fn main::{{closure}}(_1: &ReErased [closure@NodeId(60)], _2: &ReErased mut i32) -> bool { +// bb0: { +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// Validate(Release, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(60)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483663) => validate_4/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// StorageLive(_3); +// _0 = const write_42(_4) -> bb1; +// } +// } +// END rustc.node60.EraseRegions.after.mir diff --git a/src/test/mir-opt/validate_5.rs b/src/test/mir-opt/validate_5.rs index e9919af9fd3a6..150aa2baf2d31 100644 --- a/src/test/mir-opt/validate_5.rs +++ b/src/test/mir-opt/validate_5.rs @@ -9,9 +9,9 @@ // except according to those terms. // ignore-tidy-linelength -// compile-flags: -Z verbose -Z mir-emit-validate=2 +// compile-flags: -Z verbose -Z mir-emit-validate=2 -Z span_free_formats -// Make sure unsafe fns and fns with an unsafe block only get full validation. +// Make sure unsafe fns and fns with an unsafe block still get full validation. unsafe fn write_42(x: *mut i32) -> bool { *x = 42; @@ -29,9 +29,6 @@ fn main() { test_closure(&mut 0); } -// FIXME: Also test code generated inside the closure, make sure it has validation. Unfortunately, -// the interesting lines of code also contain name of the source file, so we cannot test for it. - // END RUST SOURCE // START rustc.node17.EraseRegions.after.mir // fn test(_1: &ReErased mut i32) -> () { @@ -42,3 +39,22 @@ fn main() { // } // } // END rustc.node17.EraseRegions.after.mir +// START rustc.node46.EraseRegions.after.mir +// fn main::{{closure}}(_1: &ReErased [closure@NodeId(46)], _2: &ReErased mut i32) -> bool { +// bb0: { +// Validate(Acquire, [_1: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, "BrEnv") [closure@NodeId(46)], _2: &ReFree(DefId { krate: CrateNum(0), node: DefIndex(2147483660) => validate_5/8cd878b::main[0]::{{closure}}[0] }, BrAnon(1)) mut i32]); +// StorageLive(_3); +// _3 = _2; +// StorageLive(_4); +// StorageLive(_5); +// Validate(Suspend(ReScope(Misc(NodeId(44)))), [(*_3): i32]); +// _5 = &ReErased mut (*_3); +// Validate(Acquire, [(*_5): i32/ReScope(Misc(NodeId(44)))]); +// _4 = _5 as *mut i32 (Misc); +// StorageDead(_5); +// EndRegion(ReScope(Misc(NodeId(44)))); +// Validate(Release, [_0: bool, _4: *mut i32]); +// _0 = const write_42(_4) -> bb1; +// } +// } +// END rustc.node46.EraseRegions.after.mir From 970c78094f4c9e7182c110027d90bd630191cd23 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 7 Aug 2017 10:22:28 +0200 Subject: [PATCH 08/30] Reexport all SyntaxExtension variants --- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/expand.rs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 7eeafa72c6829..194d30e25d410 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub use self::SyntaxExtension::{MultiDecorator, MultiModifier, NormalTT, IdentTT}; +pub use self::SyntaxExtension::*; use ast::{self, Attribute, Name, PatKind, MetaItem}; use attr::HasAttrs; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 16c264e0f9410..4843a66a750fa 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -294,7 +294,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let item = match self.cx.resolver.resolve_macro( Mark::root(), path, MacroKind::Derive, false) { Ok(ext) => match *ext { - SyntaxExtension::BuiltinDerive(..) => item_with_markers.clone(), + BuiltinDerive(..) => item_with_markers.clone(), _ => item.clone(), }, _ => item.clone(), @@ -427,7 +427,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { items.push(item); kind.expect_from_annotatables(items) } - SyntaxExtension::AttrProcMacro(ref mac) => { + AttrProcMacro(ref mac) => { let item_tok = TokenTree::Token(DUMMY_SP, Token::interpolated(match item { Annotatable::Item(item) => token::NtItem(item), Annotatable::TraitItem(item) => token::NtTraitItem(item.unwrap()), @@ -436,7 +436,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let tok_result = mac.expand(self.cx, attr.span, attr.tokens, item_tok); self.parse_expansion(tok_result, kind, &attr.path, attr.span) } - SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => { + ProcMacroDerive(..) | BuiltinDerive(..) => { self.cx.span_err(attr.span, &format!("`{}` is a derive mode", attr.path)); kind.dummy(attr.span) } @@ -474,7 +474,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }; let opt_expanded = match *ext { - SyntaxExtension::DeclMacro(ref expand, def_span) => { + DeclMacro(ref expand, def_span) => { if let Err(msg) = validate_and_set_expn_info(def_span.map(|(_, s)| s), false) { self.cx.span_err(path.span, &msg); @@ -512,18 +512,18 @@ impl<'a, 'b> MacroExpander<'a, 'b> { kind.make_from(expander.expand(self.cx, span, ident, input)) } - MultiDecorator(..) | MultiModifier(..) | SyntaxExtension::AttrProcMacro(..) => { + MultiDecorator(..) | MultiModifier(..) | AttrProcMacro(..) => { self.cx.span_err(path.span, &format!("`{}` can only be used in attributes", path)); return kind.dummy(span); } - SyntaxExtension::ProcMacroDerive(..) | SyntaxExtension::BuiltinDerive(..) => { + ProcMacroDerive(..) | BuiltinDerive(..) => { self.cx.span_err(path.span, &format!("`{}` is a derive mode", path)); return kind.dummy(span); } - SyntaxExtension::ProcMacro(ref expandfun) => { + ProcMacro(ref expandfun) => { if ident.name != keywords::Invalid.name() { let msg = format!("macro {}! expects no ident argument, given '{}'", path, ident); @@ -582,7 +582,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }; match *ext { - SyntaxExtension::ProcMacroDerive(ref ext, _) => { + ProcMacroDerive(ref ext, _) => { invoc.expansion_data.mark.set_expn_info(expn_info); let span = Span { ctxt: self.cx.backtrace(), ..span }; let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this @@ -592,7 +592,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { }; kind.expect_from_annotatables(ext.expand(self.cx, span, &dummy, item)) } - SyntaxExtension::BuiltinDerive(func) => { + BuiltinDerive(func) => { expn_info.callee.allow_internal_unstable = true; invoc.expansion_data.mark.set_expn_info(expn_info); let span = Span { ctxt: self.cx.backtrace(), ..span }; From 49310a9d4dfea8b5b23e9a69c2d78c0dfa6d2851 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Mon, 7 Aug 2017 16:30:56 +0100 Subject: [PATCH 09/30] Stop using URL shortener in docs tidy will no longer complain about long lines containing links so there is no reason to use a URL shortener here. --- src/libstd/net/ip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 1e5368896af91..0abf8179cc971 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -466,7 +466,7 @@ impl Ipv4Addr { /// - test addresses used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24) /// - the unspecified address (0.0.0.0) /// - /// [ipv4-sr]: http://goo.gl/RaZ7lg + /// [ipv4-sr]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml /// [`true`]: ../../std/primitive.bool.html /// /// # Examples From 2a62b91343b4de94b6cfe401e8ad9bc0414f245f Mon Sep 17 00:00:00 2001 From: Natalie Boehm Date: Mon, 7 Aug 2017 13:56:20 -0400 Subject: [PATCH 10/30] Update explanation of deref coercion --- src/liballoc/string.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 110699c1e03bd..89f3ddcd18a79 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -163,11 +163,12 @@ use boxed::Box; /// [`&str`]s as arguments unless they need a `String` for some specific /// reason. /// -/// In certain cases Rust doesn't have enough information to make this conversion, -/// known as deref coercion. For example, in this case a string slice implements -/// a trait and the function takes anything that implements the trait, Rust would -/// need to make two implicit conversions which Rust doesn't know how to do. The -/// following example will not compile for that reason. +/// In certain cases Rust doesn't have enough information to make this +/// conversion, known as deref coercion. In the following example a string +/// slice `&'a str` implements the trait `TraitExample`, and the function +/// `example_func` takes anything that implements the trait. In this case Rust +/// would need to make two implicit conversions, which Rust doesn't have the +/// means to do. For that reason, the following example will not compile. /// /// ```compile_fail,E0277 /// trait TraitExample {} @@ -182,9 +183,10 @@ use boxed::Box; /// } /// ``` /// -/// What would work in this case is changing the line `example_func(&example_string);` -/// to `example_func(example_string.to_str());`. This works because we're doing the -/// conversion explicitly, rather than relying on the implicit conversion. +/// What would work in this case is changing the line +/// `example_func(&example_string);` to +/// `example_func(example_string.to_str());`. This works because we're doing +/// the conversion explicitly, rather than relying on the implicit conversion. /// /// # Representation /// From 43760a4f9b901ba16239909f32542e685a2b9279 Mon Sep 17 00:00:00 2001 From: Inokentiy Babushkin Date: Tue, 8 Aug 2017 15:12:39 +0200 Subject: [PATCH 11/30] Encode proper spans in crate metadata. The spans previously encoded only span the first token after the opening brace, up to the closing brace of inline `mod` declarations. Thus, when examining exports from an external crate, the spans don't include the header of inline `mod` declarations. --- src/librustc_metadata/encoder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index c35d8407c9d3c..8a753a0ae4b57 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -563,7 +563,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> { Entry { kind: EntryKind::Mod(self.lazy(&data)), visibility: self.lazy(&ty::Visibility::from_hir(vis, id, tcx)), - span: self.lazy(&md.inner), + span: self.lazy(&tcx.def_span(def_id)), attributes: self.encode_attributes(attrs), children: self.lazy_seq(md.item_ids.iter().map(|item_id| { tcx.hir.local_def_id(item_id.id).index From 6c0f2aa279113810cfc1076cf3cf09b1e140bb12 Mon Sep 17 00:00:00 2001 From: Alexis Beingessner Date: Tue, 8 Aug 2017 10:08:08 -0400 Subject: [PATCH 12/30] fix assertion - trait object pointers don't have infinite fields --- src/librustc/ty/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index e770f1d55dcfd..4ee9b2e65a782 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2197,8 +2197,8 @@ impl<'a, 'tcx> TyLayout<'tcx> { let tcx = cx.tcx(); let ptr_field_type = |pointee: Ty<'tcx>| { + assert!(i < 2); let slice = |element: Ty<'tcx>| { - assert!(i < 2); if i == 0 { tcx.mk_mut_ptr(element) } else { From cf7f3055e5e2eacffde33fbc06ec0187ff828b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20Jaffr=C3=A9?= Date: Tue, 8 Aug 2017 16:53:49 +0200 Subject: [PATCH 13/30] Ignore tests that fail on stage1 That makes ./x.py test --stage 1 work on x86_64-unknown-linux-gnu. --- .../proc-macro/attribute-with-error.rs | 1 + .../proc-macro/attributes-included.rs | 1 + src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs | 1 + .../proc-macro/expand-to-unstable-2.rs | 1 + .../compile-fail-fulldeps/proc-macro/expand-to-unstable.rs | 1 + src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs | 1 + src/test/compile-fail-fulldeps/proc-macro/item-error.rs | 1 + .../proc-macro/lints_in_proc_macros.rs | 1 + .../proc-macro/proc-macro-attributes.rs | 1 + src/test/run-make/issue-37839/Makefile | 6 ++++++ src/test/run-make/issue-37893/Makefile | 6 ++++++ src/test/run-make/issue-38237/Makefile | 6 ++++++ src/test/run-make/llvm-pass/Makefile | 7 +++++++ src/test/run-make/rustc-macro-dep-files/Makefile | 6 ++++++ src/test/run-pass-fulldeps/issue-40663.rs | 1 + src/test/run-pass-fulldeps/proc-macro/add-impl.rs | 1 + src/test/run-pass-fulldeps/proc-macro/append-impl.rs | 1 + src/test/run-pass-fulldeps/proc-macro/attr-args.rs | 1 + src/test/run-pass-fulldeps/proc-macro/bang-macro.rs | 1 + .../run-pass-fulldeps/proc-macro/count_compound_ops.rs | 1 + src/test/run-pass-fulldeps/proc-macro/crate-var.rs | 1 + .../run-pass-fulldeps/proc-macro/derive-same-struct.rs | 1 + src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs | 1 + src/test/run-pass-fulldeps/proc-macro/issue-39889.rs | 1 + src/test/run-pass-fulldeps/proc-macro/issue-40001.rs | 1 + src/test/run-pass-fulldeps/proc-macro/load-two.rs | 1 + src/test/run-pass-fulldeps/proc-macro/use-reexport.rs | 1 + 27 files changed, 53 insertions(+) diff --git a/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs b/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs index 65f4b6350c4ee..00a27818327f6 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:attribute-with-error.rs +// ignore-stage1 #![feature(proc_macro)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs b/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs index 508f8dac57119..0cb4135d953f1 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:attributes-included.rs +// ignore-stage1 #![feature(proc_macro, rustc_attrs)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs index 42fad803bfa68..b03409c9c285e 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:derive-bad.rs +// ignore-stage1 #[macro_use] extern crate derive_bad; diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs index e4fcbb117a505..6f254dcbdb11a 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:derive-unstable-2.rs +// ignore-stage1 #![allow(warnings)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs index 836e336fc22f0..ca0f0e382ed0c 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:derive-unstable.rs +// ignore-stage1 #![allow(warnings)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs b/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs index 42475e6de90c9..1d645a7ec510f 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:issue_38586.rs +// ignore-stage1 #![feature(proc_macro)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/item-error.rs b/src/test/compile-fail-fulldeps/proc-macro/item-error.rs index 4133e75e3a62d..c0d4d71a6ec8b 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/item-error.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/item-error.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:derive-b.rs +// ignore-stage1 #![allow(warnings)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs b/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs index 93dead1a15685..b1fb7d42d8683 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:bang_proc_macro2.rs +// ignore-stage1 #![feature(proc_macro)] #![allow(unused_macros)] diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs index df881bedec1bb..153e4dd05717a 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:derive-b.rs +// ignore-stage1 #![allow(warnings)] diff --git a/src/test/run-make/issue-37839/Makefile b/src/test/run-make/issue-37839/Makefile index f17ce537fb813..8b3355b96226a 100644 --- a/src/test/run-make/issue-37839/Makefile +++ b/src/test/run-make/issue-37839/Makefile @@ -1,6 +1,12 @@ -include ../tools.mk +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else all: $(RUSTC) a.rs && $(RUSTC) b.rs $(BARE_RUSTC) c.rs -L dependency=$(TMPDIR) --extern b=$(TMPDIR)/libb.rlib \ --out-dir=$(TMPDIR) +endif diff --git a/src/test/run-make/issue-37893/Makefile b/src/test/run-make/issue-37893/Makefile index 27b69baf97787..c7732cc2682b1 100644 --- a/src/test/run-make/issue-37893/Makefile +++ b/src/test/run-make/issue-37893/Makefile @@ -1,4 +1,10 @@ -include ../tools.mk +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else all: $(RUSTC) a.rs && $(RUSTC) b.rs && $(RUSTC) c.rs +endif diff --git a/src/test/run-make/issue-38237/Makefile b/src/test/run-make/issue-38237/Makefile index 0a681401b1afb..855d958b344a9 100644 --- a/src/test/run-make/issue-38237/Makefile +++ b/src/test/run-make/issue-38237/Makefile @@ -1,5 +1,11 @@ -include ../tools.mk +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else all: $(RUSTC) foo.rs; $(RUSTC) bar.rs $(RUSTDOC) baz.rs -L $(TMPDIR) -o $(TMPDIR) +endif diff --git a/src/test/run-make/llvm-pass/Makefile b/src/test/run-make/llvm-pass/Makefile index aab6e895f2260..0d31d2c823500 100644 --- a/src/test/run-make/llvm-pass/Makefile +++ b/src/test/run-make/llvm-pass/Makefile @@ -1,5 +1,10 @@ -include ../tools.mk +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else # Windows doesn't correctly handle include statements with escaping paths, # so this test will not get run on Windows. ifdef IS_WINDOWS @@ -15,3 +20,5 @@ $(TMPDIR)/libllvm-function-pass.o: $(TMPDIR)/libllvm-module-pass.o: $(CXX) $(CFLAGS) $(LLVM_CXXFLAGS) -c llvm-module-pass.so.cc -o $(TMPDIR)/libllvm-module-pass.o endif + +endif diff --git a/src/test/run-make/rustc-macro-dep-files/Makefile b/src/test/run-make/rustc-macro-dep-files/Makefile index e3a6776c8080b..1ab27397e3146 100644 --- a/src/test/run-make/rustc-macro-dep-files/Makefile +++ b/src/test/run-make/rustc-macro-dep-files/Makefile @@ -1,6 +1,12 @@ -include ../tools.mk +ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) +# ignore stage1 +all: + +else all: $(RUSTC) foo.rs $(RUSTC) bar.rs --emit dep-info grep "proc-macro source" $(TMPDIR)/bar.d && exit 1 || exit 0 +endif diff --git a/src/test/run-pass-fulldeps/issue-40663.rs b/src/test/run-pass-fulldeps/issue-40663.rs index d030eab64e564..8cb9dc4a1b6ec 100644 --- a/src/test/run-pass-fulldeps/issue-40663.rs +++ b/src/test/run-pass-fulldeps/issue-40663.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:custom_derive_plugin.rs +// ignore-stage1 #![feature(plugin, custom_derive)] #![plugin(custom_derive_plugin)] diff --git a/src/test/run-pass-fulldeps/proc-macro/add-impl.rs b/src/test/run-pass-fulldeps/proc-macro/add-impl.rs index 7ea7ceafc2876..5175fe174a9e7 100644 --- a/src/test/run-pass-fulldeps/proc-macro/add-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/add-impl.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:add-impl.rs +// ignore-stage1 #[macro_use] extern crate add_impl; diff --git a/src/test/run-pass-fulldeps/proc-macro/append-impl.rs b/src/test/run-pass-fulldeps/proc-macro/append-impl.rs index 591f3331d28c0..37aef7ef1318c 100644 --- a/src/test/run-pass-fulldeps/proc-macro/append-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/append-impl.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:append-impl.rs +// ignore-stage1 #![allow(warnings)] diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs b/src/test/run-pass-fulldeps/proc-macro/attr-args.rs index 8a9fdd7536770..2968cc7871d7e 100644 --- a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs +++ b/src/test/run-pass-fulldeps/proc-macro/attr-args.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:attr-args.rs +// ignore-stage1 #![allow(warnings)] #![feature(proc_macro)] diff --git a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs b/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs index 531bd0dd3569d..ffa4731f1e637 100644 --- a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs +++ b/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:bang-macro.rs +// ignore-stage1 #![feature(proc_macro)] diff --git a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs b/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs index 1a2b144e4717b..00ad0e76ed014 100644 --- a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs +++ b/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:count_compound_ops.rs +// ignore-stage1 #![feature(proc_macro)] diff --git a/src/test/run-pass-fulldeps/proc-macro/crate-var.rs b/src/test/run-pass-fulldeps/proc-macro/crate-var.rs index ba1417ecb56e4..b6acb0faab2a5 100644 --- a/src/test/run-pass-fulldeps/proc-macro/crate-var.rs +++ b/src/test/run-pass-fulldeps/proc-macro/crate-var.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:double.rs +// ignore-stage1 #![allow(unused)] diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs index ce3ba60b0ecf4..ba5a639a759cb 100644 --- a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs +++ b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:derive-same-struct.rs +// ignore-stage1 #[macro_use] extern crate derive_same_struct; diff --git a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs b/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs index 51198db5aa76d..4cac7d19b4de8 100644 --- a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs +++ b/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs @@ -10,6 +10,7 @@ // aux-build:hygiene_example_codegen.rs // aux-build:hygiene_example.rs +// ignore-stage1 #![feature(proc_macro)] diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs b/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs index 05610116ad6bf..87130242c0f04 100644 --- a/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs +++ b/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:issue-39889.rs +// ignore-stage1 #![feature(proc_macro)] #![allow(unused)] diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs b/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs index 54e84b7f6189f..b7826edd8b4e5 100644 --- a/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs +++ b/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs @@ -9,6 +9,7 @@ // except according to those terms. // aux-build:issue-40001-plugin.rs +// ignore-stage1 #![feature(proc_macro, plugin)] #![plugin(issue_40001_plugin)] diff --git a/src/test/run-pass-fulldeps/proc-macro/load-two.rs b/src/test/run-pass-fulldeps/proc-macro/load-two.rs index d15a83a2cbe43..67c1237781470 100644 --- a/src/test/run-pass-fulldeps/proc-macro/load-two.rs +++ b/src/test/run-pass-fulldeps/proc-macro/load-two.rs @@ -10,6 +10,7 @@ // aux-build:derive-atob.rs // aux-build:derive-ctod.rs +// ignore-stage1 #[macro_use] extern crate derive_atob; diff --git a/src/test/run-pass-fulldeps/proc-macro/use-reexport.rs b/src/test/run-pass-fulldeps/proc-macro/use-reexport.rs index f0a1bfe652857..03dfeb1f5c9a5 100644 --- a/src/test/run-pass-fulldeps/proc-macro/use-reexport.rs +++ b/src/test/run-pass-fulldeps/proc-macro/use-reexport.rs @@ -10,6 +10,7 @@ // aux-build:derive-a.rs // aux-build:derive-reexport.rs +// ignore-stage1 #[macro_use] extern crate derive_reexport; From 40f5b308bcf8024cd17b982d543695873bc9dd53 Mon Sep 17 00:00:00 2001 From: Natalie Boehm Date: Tue, 8 Aug 2017 14:57:34 -0400 Subject: [PATCH 14/30] Update solution to add using `&*` as well as `as_str()` --- src/liballoc/string.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 89f3ddcd18a79..a1f0b4f0de19d 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -183,10 +183,15 @@ use boxed::Box; /// } /// ``` /// -/// What would work in this case is changing the line -/// `example_func(&example_string);` to -/// `example_func(example_string.to_str());`. This works because we're doing -/// the conversion explicitly, rather than relying on the implicit conversion. +/// There are two options that would work instead. The first would be to +/// change the line `example_func(&example_string);` to +/// `example_func(example_string.as_str());`, using the method `as_str()` +/// to explicitly extract the string slice containing the string. The second +/// way changes `example_func(&example_string);` to +/// `example_func(&*example_string);`. In this case we are dereferencing a +/// `String` to a `str`, then referencing the `str` back to `&str`. The +/// second way is more idiomatic, however both work to do the conversion +/// explicitly rather than relying on the implicit conversion. /// /// # Representation /// From 8ac43366929e2ea66abbf0fc8fe535ecfbea0262 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 8 Aug 2017 22:16:08 +0200 Subject: [PATCH 15/30] Improve headers linking --- src/librustdoc/html/render.rs | 44 +++++++++++++------------- src/librustdoc/html/static/rustdoc.css | 10 ++++++ 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index fc0adef70baa1..563c5618759b7 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -2141,8 +2141,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, if !types.is_empty() { write!(w, " -

- Associated Types +

+ Associated Types

")?; @@ -2154,8 +2154,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, if !consts.is_empty() { write!(w, " -

- Associated Constants +

+ Associated Constants

")?; @@ -2168,8 +2168,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, // Output the documentation for each function individually if !required.is_empty() { write!(w, " -

- Required Methods +

+ Required Methods

")?; @@ -2180,8 +2180,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, } if !provided.is_empty() { write!(w, " -

- Provided Methods +

+ Provided Methods

")?; @@ -2196,8 +2196,8 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, let cache = cache(); write!(w, " -

- Implementors +

+ Implementors