Skip to content

Commit c11f689

Browse files
committed
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 20 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 43 additions & 15 deletions
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

Lines changed: 2 additions & 4 deletions
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.

0 commit comments

Comments
 (0)