Skip to content

Commit cf91e9b

Browse files
committed
Auto merge of #51448 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 13 pull requests Successful merges: - #50143 (Add deprecation lint for duplicated `macro_export`s) - #51099 (Fix Issue 38777) - #51276 (Dedup auto traits in trait objects.) - #51298 (Stabilize unit tests with non-`()` return type) - #51360 (Suggest parentheses when a struct literal needs them) - #51391 (Use spans pointing at the inside of a rustdoc attribute) - #51394 (Use scope tree depths to speed up `nearest_common_ancestor`.) - #51396 (Make the size of Option<NonZero*> a documented guarantee.) - #51401 (Warn on `repr` without hints) - #51412 (Avoid useless Vec clones in pending_obligations().) - #51427 (compiletest: autoremove duplicate .nll.* files (#51204)) - #51436 (Do not require stage 2 compiler for rustdoc) - #51437 (rustbuild: generate full list of dependencies for metadata) Failed merges:
2 parents 8afb894 + 8c5002d commit cf91e9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1086
-435
lines changed

Diff for: src/bootstrap/builder.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,7 @@ impl<'a> Builder<'a> {
800800
cargo.env("RUSTC_ERROR_FORMAT", error_format);
801801
}
802802
if cmd != "build" && cmd != "check" && want_rustdoc {
803-
cargo.env(
804-
"RUSTDOC_LIBDIR",
805-
self.rustc_libdir(self.compiler(2, self.config.build)),
806-
);
803+
cargo.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build));
807804
}
808805

809806
if mode.is_tool() {

Diff for: src/bootstrap/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ pub struct Build {
280280
struct Crate {
281281
name: Interned<String>,
282282
version: String,
283-
deps: Vec<Interned<String>>,
283+
deps: HashSet<Interned<String>>,
284+
id: String,
284285
path: PathBuf,
285286
doc_step: String,
286287
build_step: String,

Diff for: src/bootstrap/metadata.rs

+31-23
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use std::collections::HashMap;
1212
use std::process::Command;
1313
use std::path::PathBuf;
14+
use std::collections::HashSet;
1415

1516
use build_helper::output;
1617
use serde_json;
@@ -45,12 +46,34 @@ struct ResolveNode {
4546
}
4647

4748
pub fn build(build: &mut Build) {
48-
build_krate(build, "src/libstd");
49-
build_krate(build, "src/libtest");
50-
build_krate(build, "src/rustc");
49+
let mut resolves = Vec::new();
50+
build_krate(&build.std_features(), build, &mut resolves, "src/libstd");
51+
build_krate("", build, &mut resolves, "src/libtest");
52+
build_krate(&build.rustc_features(), build, &mut resolves, "src/rustc");
53+
54+
let mut id2name = HashMap::new();
55+
for (name, krate) in build.crates.iter() {
56+
id2name.insert(krate.id.clone(), name.clone());
57+
}
58+
59+
for node in resolves {
60+
let name = match id2name.get(&node.id) {
61+
Some(name) => name,
62+
None => continue,
63+
};
64+
65+
let krate = build.crates.get_mut(name).unwrap();
66+
for dep in node.dependencies.iter() {
67+
let dep = match id2name.get(dep) {
68+
Some(dep) => dep,
69+
None => continue,
70+
};
71+
krate.deps.insert(*dep);
72+
}
73+
}
5174
}
5275

53-
fn build_krate(build: &mut Build, krate: &str) {
76+
fn build_krate(features: &str, build: &mut Build, resolves: &mut Vec<ResolveNode>, krate: &str) {
5477
// Run `cargo metadata` to figure out what crates we're testing.
5578
//
5679
// Down below we're going to call `cargo test`, but to test the right set
@@ -60,14 +83,13 @@ fn build_krate(build: &mut Build, krate: &str) {
6083
let mut cargo = Command::new(&build.initial_cargo);
6184
cargo.arg("metadata")
6285
.arg("--format-version").arg("1")
86+
.arg("--features").arg(features)
6387
.arg("--manifest-path").arg(build.src.join(krate).join("Cargo.toml"));
6488
let output = output(&mut cargo);
6589
let output: Output = serde_json::from_str(&output).unwrap();
66-
let mut id2name = HashMap::new();
6790
for package in output.packages {
6891
if package.source.is_none() {
6992
let name = INTERNER.intern_string(package.name);
70-
id2name.insert(package.id, name);
7193
let mut path = PathBuf::from(package.manifest_path);
7294
path.pop();
7395
build.crates.insert(name, Crate {
@@ -77,25 +99,11 @@ fn build_krate(build: &mut Build, krate: &str) {
7799
bench_step: format!("bench-crate-{}", name),
78100
name,
79101
version: package.version,
80-
deps: Vec::new(),
102+
id: package.id,
103+
deps: HashSet::new(),
81104
path,
82105
});
83106
}
84107
}
85-
86-
for node in output.resolve.nodes {
87-
let name = match id2name.get(&node.id) {
88-
Some(name) => name,
89-
None => continue,
90-
};
91-
92-
let krate = build.crates.get_mut(name).unwrap();
93-
for dep in node.dependencies.iter() {
94-
let dep = match id2name.get(dep) {
95-
Some(dep) => dep,
96-
None => continue,
97-
};
98-
krate.deps.push(*dep);
99-
}
100-
}
108+
resolves.extend(output.resolve.nodes);
101109
}

Diff for: src/libcore/num/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ macro_rules! nonzero_integers {
3939
$(
4040
/// An integer that is known not to equal zero.
4141
///
42-
/// This may enable some memory layout optimization such as:
42+
/// This enables some memory layout optimization.
43+
/// For example, `Option<NonZeroU32>` is the same size as `u32`:
4344
///
4445
/// ```rust
45-
/// # #![feature(nonzero)]
4646
/// use std::mem::size_of;
4747
/// assert_eq!(size_of::<Option<std::num::NonZeroU32>>(), size_of::<u32>());
4848
/// ```

Diff for: src/librustc/lint/builtin.rs

+19
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use errors::{Applicability, DiagnosticBuilder};
1818
use lint::{LintPass, LateLintPass, LintArray};
1919
use session::Session;
20+
use syntax::ast;
2021
use syntax::codemap::Span;
2122

2223
declare_lint! {
@@ -206,6 +207,12 @@ declare_lint! {
206207
"potentially-conflicting impls were erroneously allowed"
207208
}
208209

210+
declare_lint! {
211+
pub BAD_REPR,
212+
Warn,
213+
"detects incorrect use of `repr` attribute"
214+
}
215+
209216
declare_lint! {
210217
pub DEPRECATED,
211218
Warn,
@@ -285,6 +292,12 @@ declare_lint! {
285292
"warns about duplicate associated type bindings in generics"
286293
}
287294

295+
declare_lint! {
296+
pub DUPLICATE_MACRO_EXPORTS,
297+
Deny,
298+
"detects duplicate macro exports"
299+
}
300+
288301
/// Does nothing as a lint pass, but registers some `Lint`s
289302
/// which are used by other parts of the compiler.
290303
#[derive(Copy, Clone)]
@@ -337,6 +350,7 @@ impl LintPass for HardwiredLints {
337350
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
338351
UNSTABLE_NAME_COLLISIONS,
339352
DUPLICATE_ASSOCIATED_TYPE_BINDINGS,
353+
DUPLICATE_MACRO_EXPORTS,
340354
)
341355
}
342356
}
@@ -348,6 +362,7 @@ pub enum BuiltinLintDiagnostics {
348362
Normal,
349363
BareTraitObject(Span, /* is_global */ bool),
350364
AbsPathWithModule(Span),
365+
DuplicatedMacroExports(ast::Ident, Span, Span),
351366
}
352367

353368
impl BuiltinLintDiagnostics {
@@ -380,6 +395,10 @@ impl BuiltinLintDiagnostics {
380395
};
381396
db.span_suggestion_with_applicability(span, "use `crate`", sugg, app);
382397
}
398+
BuiltinLintDiagnostics::DuplicatedMacroExports(ident, earlier_span, later_span) => {
399+
db.span_label(later_span, format!("`{}` already exported", ident));
400+
db.span_note(earlier_span, "previous macro export is now shadowed");
401+
}
383402
}
384403
}
385404
}

0 commit comments

Comments
 (0)