Skip to content

Commit c11f689

Browse files
committedAug 29, 2017
Auto merge of #44169 - arielb1:rollup, r=arielb1
Rollup of 12 pull requests - Successful merges: #43705, #43778, #43918, #44076, #44117, #44121, #44126, #44134, #44135, #44141, #44144, #44158 - Failed merges:
2 parents 630e02f + be0ac01 commit c11f689

File tree

15 files changed

+207
-92
lines changed

15 files changed

+207
-92
lines changed
 

‎src/bootstrap/dist.rs

+6
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,9 @@ impl Step for Src {
724724
let dst_src = dst.join("rust");
725725
t!(fs::create_dir_all(&dst_src));
726726

727+
let src_files = [
728+
"src/Cargo.lock",
729+
];
727730
// This is the reduced set of paths which will become the rust-src component
728731
// (essentially libstd and all of its path dependencies)
729732
let std_src_dirs = [
@@ -759,6 +762,9 @@ impl Step for Src {
759762
];
760763

761764
copy_src_dirs(build, &std_src_dirs[..], &std_src_dirs_exclude[..], &dst_src);
765+
for file in src_files.iter() {
766+
copy(&build.src.join(file), &dst_src.join(file));
767+
}
762768

763769
// Create source tarball in rust-installer format
764770
let mut cmd = rust_installer(builder);

‎src/bootstrap/flags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
136136
None => {
137137
// No subcommand -- show the general usage and subcommand help
138138
println!("{}\n", subcommand_help);
139-
process::exit(0);
139+
process::exit(1);
140140
}
141141
};
142142

‎src/bootstrap/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ extern crate build_helper;
123123
extern crate serde_derive;
124124
#[macro_use]
125125
extern crate lazy_static;
126-
extern crate serde;
127126
extern crate serde_json;
128127
extern crate cmake;
129128
extern crate filetime;

‎src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ tool!(
198198
Linkchecker, "src/tools/linkchecker", "linkchecker", Mode::Libstd;
199199
CargoTest, "src/tools/cargotest", "cargotest", Mode::Libstd;
200200
Compiletest, "src/tools/compiletest", "compiletest", Mode::Libtest;
201-
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Librustc;
201+
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd;
202202
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd;
203203
RustInstaller, "src/tools/rust-installer", "rust-installer", Mode::Libstd;
204204
);

‎src/libcore/fmt/num.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ macro_rules! impl_Display {
242242
// decode last 1 or 2 chars
243243
if n < 10 {
244244
curr -= 1;
245-
*buf_ptr.offset(curr) = (n as u8) + 48;
245+
*buf_ptr.offset(curr) = (n as u8) + b'0';
246246
} else {
247247
let d1 = n << 1;
248248
curr -= 2;

‎src/libcore/option.rs

+20
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,26 @@ impl<'a, T: Clone> Option<&'a T> {
774774
}
775775
}
776776

777+
impl<'a, T: Clone> Option<&'a mut T> {
778+
/// Maps an `Option<&mut T>` to an `Option<T>` by cloning the contents of the
779+
/// option.
780+
///
781+
/// # Examples
782+
///
783+
/// ```
784+
/// #![feature(option_ref_mut_cloned)]
785+
/// let mut x = 12;
786+
/// let opt_x = Some(&mut x);
787+
/// assert_eq!(opt_x, Some(&mut 12));
788+
/// let cloned = opt_x.cloned();
789+
/// assert_eq!(cloned, Some(12));
790+
/// ```
791+
#[unstable(feature = "option_ref_mut_cloned", issue = "43738")]
792+
pub fn cloned(self) -> Option<T> {
793+
self.map(|t| t.clone())
794+
}
795+
}
796+
777797
impl<T: Default> Option<T> {
778798
/// Returns the contained value or a default
779799
///

‎src/librustc_errors/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ impl Handler {
306306
self.continue_after_error.set(continue_after_error);
307307
}
308308

309+
// NOTE: DO NOT call this function from rustc, as it relies on `err_count` being non-zero
310+
// if an error happened to avoid ICEs. This function should only be called from tools.
311+
pub fn reset_err_count(&self) {
312+
self.err_count.set(0);
313+
}
314+
309315
pub fn struct_dummy<'a>(&'a self) -> DiagnosticBuilder<'a> {
310316
DiagnosticBuilder::new(self, Level::Cancelled, "")
311317
}

‎src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl<'a> fmt::Display for WhereClause<'a> {
228228
}
229229

230230
if end_newline {
231-
//add a space so stripping <br> tags and breaking spaces still renders properly
231+
// add a space so stripping <br> tags and breaking spaces still renders properly
232232
if f.alternate() {
233233
clause.push(' ');
234234
} else {

‎src/librustdoc/html/highlight.rs

+43-15
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,21 @@ impl<'a> Classifier<'a> {
172172
}
173173
}
174174

175+
/// Gets the next token out of the lexer, emitting fatal errors if lexing fails.
176+
fn try_next_token(&mut self) -> io::Result<TokenAndSpan> {
177+
match self.lexer.try_next_token() {
178+
Ok(tas) => Ok(tas),
179+
Err(_) => {
180+
self.lexer.emit_fatal_errors();
181+
self.lexer.sess.span_diagnostic
182+
.struct_warn("Backing out of syntax highlighting")
183+
.note("You probably did not intend to render this as a rust code-block")
184+
.emit();
185+
Err(io::Error::new(io::ErrorKind::Other, ""))
186+
}
187+
}
188+
}
189+
175190
/// Exhausts the `lexer` writing the output into `out`.
176191
///
177192
/// The general structure for this method is to iterate over each token,
@@ -183,18 +198,7 @@ impl<'a> Classifier<'a> {
183198
out: &mut W)
184199
-> io::Result<()> {
185200
loop {
186-
let next = match self.lexer.try_next_token() {
187-
Ok(tas) => tas,
188-
Err(_) => {
189-
self.lexer.emit_fatal_errors();
190-
self.lexer.sess.span_diagnostic
191-
.struct_warn("Backing out of syntax highlighting")
192-
.note("You probably did not intend to render this as a rust code-block")
193-
.emit();
194-
return Err(io::Error::new(io::ErrorKind::Other, ""));
195-
}
196-
};
197-
201+
let next = self.try_next_token()?;
198202
if next.tok == token::Eof {
199203
break;
200204
}
@@ -255,13 +259,37 @@ impl<'a> Classifier<'a> {
255259
}
256260
}
257261

258-
// This is the start of an attribute. We're going to want to
262+
// This might be the start of an attribute. We're going to want to
259263
// continue highlighting it as an attribute until the ending ']' is
260264
// seen, so skip out early. Down below we terminate the attribute
261265
// span when we see the ']'.
262266
token::Pound => {
263-
self.in_attribute = true;
264-
out.enter_span(Class::Attribute)?;
267+
// We can't be sure that our # begins an attribute (it could
268+
// just be appearing in a macro) until we read either `#![` or
269+
// `#[` from the input stream.
270+
//
271+
// We don't want to start highlighting as an attribute until
272+
// we're confident there is going to be a ] coming up, as
273+
// otherwise # tokens in macros highlight the rest of the input
274+
// as an attribute.
275+
276+
// Case 1: #![inner_attribute]
277+
if self.lexer.peek().tok == token::Not {
278+
self.try_next_token()?; // NOTE: consumes `!` token!
279+
if self.lexer.peek().tok == token::OpenDelim(token::Bracket) {
280+
self.in_attribute = true;
281+
out.enter_span(Class::Attribute)?;
282+
}
283+
out.string("#", Class::None, None)?;
284+
out.string("!", Class::None, None)?;
285+
return Ok(());
286+
}
287+
288+
// Case 2: #[outer_attribute]
289+
if self.lexer.peek().tok == token::OpenDelim(token::Bracket) {
290+
self.in_attribute = true;
291+
out.enter_span(Class::Attribute)?;
292+
}
265293
out.string("#", Class::None, None)?;
266294
return Ok(());
267295
}

‎src/librustdoc/html/render.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1523,17 +1523,15 @@ impl<'a> fmt::Display for Item<'a> {
15231523
} else {
15241524
write!(fmt, "Module ")?;
15251525
},
1526-
clean::FunctionItem(..) | clean::ForeignFunctionItem(..) =>
1527-
write!(fmt, "Function ")?,
1526+
clean::FunctionItem(..) | clean::ForeignFunctionItem(..) => write!(fmt, "Function ")?,
15281527
clean::TraitItem(..) => write!(fmt, "Trait ")?,
15291528
clean::StructItem(..) => write!(fmt, "Struct ")?,
15301529
clean::UnionItem(..) => write!(fmt, "Union ")?,
15311530
clean::EnumItem(..) => write!(fmt, "Enum ")?,
15321531
clean::TypedefItem(..) => write!(fmt, "Type Definition ")?,
15331532
clean::MacroItem(..) => write!(fmt, "Macro ")?,
15341533
clean::PrimitiveItem(..) => write!(fmt, "Primitive Type ")?,
1535-
clean::StaticItem(..) | clean::ForeignStaticItem(..) =>
1536-
write!(fmt, "Static ")?,
1534+
clean::StaticItem(..) | clean::ForeignStaticItem(..) => write!(fmt, "Static ")?,
15371535
clean::ConstantItem(..) => write!(fmt, "Constant ")?,
15381536
_ => {
15391537
// We don't generate pages for any other type.

‎src/librustdoc/html/static/rustdoc.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ h4 > code, h3 > code, .invisible > code {
329329
display: inline-block;
330330
}
331331

332+
.in-band > code {
333+
display: inline-block;
334+
}
335+
332336
#main { position: relative; }
333337
#main > .since {
334338
top: inherit;
@@ -447,7 +451,8 @@ a {
447451
}
448452

449453
.in-band:hover > .anchor {
450-
display: initial;
454+
display: inline-block;
455+
position: absolute;
451456
}
452457
.anchor {
453458
display: none;

‎src/libstd/net/addr.rs

+66-22
Original file line numberDiff line numberDiff line change
@@ -705,30 +705,74 @@ impl hash::Hash for SocketAddrV6 {
705705
///
706706
/// # Examples
707707
///
708+
/// Creating a [`SocketAddr`] iterator that yields one item:
709+
///
710+
/// ```
711+
/// use std::net::{ToSocketAddrs, SocketAddr};
712+
///
713+
/// let addr = SocketAddr::from(([127, 0, 0, 1], 443));
714+
/// let mut addrs_iter = addr.to_socket_addrs().unwrap();
715+
///
716+
/// assert_eq!(Some(addr), addrs_iter.next());
717+
/// assert!(addrs_iter.next().is_none());
718+
/// ```
719+
///
720+
/// Creating a [`SocketAddr`] iterator from a hostname:
721+
///
708722
/// ```no_run
709-
/// use std::net::{SocketAddrV4, TcpStream, UdpSocket, TcpListener, Ipv4Addr};
710-
///
711-
/// fn main() {
712-
/// let ip = Ipv4Addr::new(127, 0, 0, 1);
713-
/// let port = 12345;
714-
///
715-
/// // The following lines are equivalent modulo possible "localhost" name
716-
/// // resolution differences
717-
/// let tcp_s = TcpStream::connect(SocketAddrV4::new(ip, port));
718-
/// let tcp_s = TcpStream::connect((ip, port));
719-
/// let tcp_s = TcpStream::connect(("127.0.0.1", port));
720-
/// let tcp_s = TcpStream::connect(("localhost", port));
721-
/// let tcp_s = TcpStream::connect("127.0.0.1:12345");
722-
/// let tcp_s = TcpStream::connect("localhost:12345");
723-
///
724-
/// // TcpListener::bind(), UdpSocket::bind() and UdpSocket::send_to()
725-
/// // behave similarly
726-
/// let tcp_l = TcpListener::bind("localhost:12345");
727-
///
728-
/// let mut udp_s = UdpSocket::bind(("127.0.0.1", port)).unwrap();
729-
/// udp_s.send_to(&[7], (ip, 23451)).unwrap();
730-
/// }
723+
/// use std::net::{SocketAddr, ToSocketAddrs};
724+
///
725+
/// // assuming 'localhost' resolves to 127.0.0.1
726+
/// let mut addrs_iter = "localhost:443".to_socket_addrs().unwrap();
727+
/// assert_eq!(addrs_iter.next(), Some(SocketAddr::from(([127, 0, 0, 1], 443))));
728+
/// assert!(addrs_iter.next().is_none());
729+
///
730+
/// // assuming 'foo' does not resolve
731+
/// assert!("foo:443".to_socket_addrs().is_err());
731732
/// ```
733+
///
734+
/// Creating a [`SocketAddr`] iterator that yields multiple items:
735+
///
736+
/// ```
737+
/// use std::net::{SocketAddr, ToSocketAddrs};
738+
///
739+
/// let addr1 = SocketAddr::from(([0, 0, 0, 0], 80));
740+
/// let addr2 = SocketAddr::from(([127, 0, 0, 1], 443));
741+
/// let addrs = vec![addr1, addr2];
742+
///
743+
/// let mut addrs_iter = (&addrs[..]).to_socket_addrs().unwrap();
744+
///
745+
/// assert_eq!(Some(addr1), addrs_iter.next());
746+
/// assert_eq!(Some(addr2), addrs_iter.next());
747+
/// assert!(addrs_iter.next().is_none());
748+
/// ```
749+
///
750+
/// Attempting to create a [`SocketAddr`] iterator from an improperly formatted
751+
/// socket address `&str` (missing the port):
752+
///
753+
/// ```
754+
/// use std::io;
755+
/// use std::net::ToSocketAddrs;
756+
///
757+
/// let err = "127.0.0.1".to_socket_addrs().unwrap_err();
758+
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
759+
/// ```
760+
///
761+
/// [`TcpStream::connect`] is an example of an function that utilizes
762+
/// `ToSocketsAddr` as a trait bound on its parameter in order to accept
763+
/// different types:
764+
///
765+
/// ```no_run
766+
/// use std::net::{TcpStream, Ipv4Addr};
767+
///
768+
/// let stream = TcpStream::connect(("127.0.0.1", 443));
769+
/// // or
770+
/// let stream = TcpStream::connect("127.0.0.1.443");
771+
/// // or
772+
/// let stream = TcpStream::connect((Ipv4Addr::new(127, 0, 0, 1), 443));
773+
/// ```
774+
///
775+
/// [`TcpStream::connect`]: ../../std/net/struct.TcpStream.html#method.connect
732776
#[stable(feature = "rust1", since = "1.0.0")]
733777
pub trait ToSocketAddrs {
734778
/// Returned iterator over socket addresses which this type may correspond

‎src/test/rustdoc/issue-41783.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212
// @!has - 'space'
1313
// @!has - 'comment'
1414
// @has - '# <span class="ident">single'
15-
// @has - '#<span class="attribute"># <span class="ident">double</span>'
16-
// @has - '#<span class="attribute">#<span class="attribute"># <span class="ident">triple</span>'
15+
// @has - '## <span class="ident">double</span>'
16+
// @has - '### <span class="ident">triple</span>'
17+
// @has - '<span class="attribute">#[<span class="ident">outer</span>]</span>'
18+
// @has - '<span class="attribute">#![<span class="ident">inner</span>]</span>'
1719

1820
/// ```no_run
1921
/// # # space
2022
/// # comment
2123
/// ## single
2224
/// ### double
2325
/// #### triple
26+
/// ##[outer]
27+
/// ##![inner]
2428
/// ```
2529
pub struct Foo;

‎src/tools/build-manifest/src/main.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ impl Builder {
239239
self.package("rust-std", &mut manifest.pkg, TARGETS);
240240
self.package("rust-docs", &mut manifest.pkg, TARGETS);
241241
self.package("rust-src", &mut manifest.pkg, &["*"]);
242-
self.package("rls", &mut manifest.pkg, HOSTS);
242+
let rls_package_name = if self.rust_release == "nightly" {
243+
"rls"
244+
} else {
245+
"rls-preview"
246+
};
247+
self.package(rls_package_name, &mut manifest.pkg, HOSTS);
243248
self.package("rust-analysis", &mut manifest.pkg, TARGETS);
244249

245250
let mut pkg = Package {
@@ -276,7 +281,7 @@ impl Builder {
276281
}
277282

278283
extensions.push(Component {
279-
pkg: "rls".to_string(),
284+
pkg: rls_package_name.to_string(),
280285
target: host.to_string(),
281286
});
282287
extensions.push(Component {
@@ -353,7 +358,7 @@ impl Builder {
353358
format!("rust-src-{}.tar.gz", self.rust_release)
354359
} else if component == "cargo" {
355360
format!("cargo-{}-{}.tar.gz", self.cargo_release, target)
356-
} else if component == "rls" {
361+
} else if component == "rls" || component == "rls-preview" {
357362
format!("rls-{}-{}.tar.gz", self.rls_release, target)
358363
} else {
359364
format!("{}-{}-{}.tar.gz", component, self.rust_release, target)
@@ -363,7 +368,7 @@ impl Builder {
363368
fn cached_version(&self, component: &str) -> &str {
364369
if component == "cargo" {
365370
&self.cargo_version
366-
} else if component == "rls" {
371+
} else if component == "rls" || component == "rls-preview" {
367372
&self.rls_version
368373
} else {
369374
&self.rust_version

‎src/tools/compiletest/src/common.rs

+39-39
Original file line numberDiff line numberDiff line change
@@ -83,117 +83,117 @@ impl fmt::Display for Mode {
8383

8484
#[derive(Clone)]
8585
pub struct Config {
86-
// The library paths required for running the compiler
86+
/// The library paths required for running the compiler
8787
pub compile_lib_path: PathBuf,
8888

89-
// The library paths required for running compiled programs
89+
/// The library paths required for running compiled programs
9090
pub run_lib_path: PathBuf,
9191

92-
// The rustc executable
92+
/// The rustc executable
9393
pub rustc_path: PathBuf,
9494

95-
// The rustdoc executable
95+
/// The rustdoc executable
9696
pub rustdoc_path: Option<PathBuf>,
9797

98-
// The python executable to use for LLDB
98+
/// The python executable to use for LLDB
9999
pub lldb_python: String,
100100

101-
// The python executable to use for htmldocck
101+
/// The python executable to use for htmldocck
102102
pub docck_python: String,
103103

104-
// The llvm FileCheck binary path
104+
/// The llvm FileCheck binary path
105105
pub llvm_filecheck: Option<PathBuf>,
106106

107-
// The valgrind path
107+
/// The valgrind path
108108
pub valgrind_path: Option<String>,
109109

110-
// Whether to fail if we can't run run-pass-valgrind tests under valgrind
111-
// (or, alternatively, to silently run them like regular run-pass tests).
110+
/// Whether to fail if we can't run run-pass-valgrind tests under valgrind
111+
/// (or, alternatively, to silently run them like regular run-pass tests).
112112
pub force_valgrind: bool,
113113

114-
// The directory containing the tests to run
114+
/// The directory containing the tests to run
115115
pub src_base: PathBuf,
116116

117-
// The directory where programs should be built
117+
/// The directory where programs should be built
118118
pub build_base: PathBuf,
119119

120-
// The name of the stage being built (stage1, etc)
120+
/// The name of the stage being built (stage1, etc)
121121
pub stage_id: String,
122122

123-
// The test mode, compile-fail, run-fail, run-pass
123+
/// The test mode, compile-fail, run-fail, run-pass
124124
pub mode: Mode,
125125

126-
// Run ignored tests
126+
/// Run ignored tests
127127
pub run_ignored: bool,
128128

129-
// Only run tests that match this filter
129+
/// Only run tests that match this filter
130130
pub filter: Option<String>,
131131

132-
// Exactly match the filter, rather than a substring
132+
/// Exactly match the filter, rather than a substring
133133
pub filter_exact: bool,
134134

135-
// Write out a parseable log of tests that were run
135+
/// Write out a parseable log of tests that were run
136136
pub logfile: Option<PathBuf>,
137137

138-
// A command line to prefix program execution with,
139-
// for running under valgrind
138+
/// A command line to prefix program execution with,
139+
/// for running under valgrind
140140
pub runtool: Option<String>,
141141

142-
// Flags to pass to the compiler when building for the host
142+
/// Flags to pass to the compiler when building for the host
143143
pub host_rustcflags: Option<String>,
144144

145-
// Flags to pass to the compiler when building for the target
145+
/// Flags to pass to the compiler when building for the target
146146
pub target_rustcflags: Option<String>,
147147

148-
// Target system to be tested
148+
/// Target system to be tested
149149
pub target: String,
150150

151-
// Host triple for the compiler being invoked
151+
/// Host triple for the compiler being invoked
152152
pub host: String,
153153

154-
// Path to / name of the GDB executable
154+
/// Path to / name of the GDB executable
155155
pub gdb: Option<String>,
156156

157-
// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
157+
/// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
158158
pub gdb_version: Option<u32>,
159159

160-
// Whether GDB has native rust support
160+
/// Whether GDB has native rust support
161161
pub gdb_native_rust: bool,
162162

163-
// Version of LLDB
163+
/// Version of LLDB
164164
pub lldb_version: Option<String>,
165165

166-
// Version of LLVM
166+
/// Version of LLVM
167167
pub llvm_version: Option<String>,
168168

169-
// Is LLVM a system LLVM
169+
/// Is LLVM a system LLVM
170170
pub system_llvm: bool,
171171

172-
// Path to the android tools
172+
/// Path to the android tools
173173
pub android_cross_path: PathBuf,
174174

175-
// Extra parameter to run adb on arm-linux-androideabi
175+
/// Extra parameter to run adb on arm-linux-androideabi
176176
pub adb_path: String,
177177

178-
// Extra parameter to run test suite on arm-linux-androideabi
178+
/// Extra parameter to run test suite on arm-linux-androideabi
179179
pub adb_test_dir: String,
180180

181-
// status whether android device available or not
181+
/// status whether android device available or not
182182
pub adb_device_status: bool,
183183

184-
// the path containing LLDB's Python module
184+
/// the path containing LLDB's Python module
185185
pub lldb_python_dir: Option<String>,
186186

187-
// Explain what's going on
187+
/// Explain what's going on
188188
pub verbose: bool,
189189

190-
// Print one character per test instead of one line
190+
/// Print one character per test instead of one line
191191
pub quiet: bool,
192192

193-
// Whether to use colors in test.
193+
/// Whether to use colors in test.
194194
pub color: ColorConfig,
195195

196-
// where to find the remote test client process, if we're using it
196+
/// where to find the remote test client process, if we're using it
197197
pub remote_test_client: Option<PathBuf>,
198198

199199
// Configuration for various run-make tests frobbing things like C compilers

0 commit comments

Comments
 (0)
Please sign in to comment.