Skip to content

Commit f5160d3

Browse files
authored
Merge pull request #38716 from alexcrichton/beta-next
Backporting PRs to beta
2 parents dd582c0 + b8ea9fa commit f5160d3

File tree

28 files changed

+276
-125
lines changed

28 files changed

+276
-125
lines changed

src/bootstrap/bootstrap.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def verify(path, sha_path, verbose):
8181
with open(path, "rb") as f:
8282
found = hashlib.sha256(f.read()).hexdigest()
8383
with open(sha_path, "r") as f:
84-
expected, _ = f.readline().split()
84+
expected = f.readline().split()[0]
8585
verified = found == expected
8686
if not verified:
8787
print("invalid checksum:\n"
@@ -146,7 +146,7 @@ class RustBuild(object):
146146
def download_stage0(self):
147147
cache_dst = os.path.join(self.build_dir, "cache")
148148
rustc_cache = os.path.join(cache_dst, self.stage0_rustc_date())
149-
cargo_cache = os.path.join(cache_dst, self.stage0_cargo_date())
149+
cargo_cache = os.path.join(cache_dst, self.stage0_cargo_rev())
150150
if not os.path.exists(rustc_cache):
151151
os.makedirs(rustc_cache)
152152
if not os.path.exists(cargo_cache):
@@ -179,21 +179,17 @@ def download_stage0(self):
179179
if self.cargo().startswith(self.bin_root()) and \
180180
(not os.path.exists(self.cargo()) or self.cargo_out_of_date()):
181181
self.print_what_it_means_to_bootstrap()
182-
channel = self.stage0_cargo_channel()
183-
filename = "cargo-{}-{}.tar.gz".format(channel, self.build)
184-
url = "https://static.rust-lang.org/cargo-dist/" + self.stage0_cargo_date()
182+
filename = "cargo-nightly-{}.tar.gz".format(self.build)
183+
url = "https://s3.amazonaws.com/rust-lang-ci/cargo-builds/" + self.stage0_cargo_rev()
185184
tarball = os.path.join(cargo_cache, filename)
186185
if not os.path.exists(tarball):
187186
get("{}/{}".format(url, filename), tarball, verbose=self.verbose)
188187
unpack(tarball, self.bin_root(), match="cargo", verbose=self.verbose)
189188
with open(self.cargo_stamp(), 'w') as f:
190-
f.write(self.stage0_cargo_date())
189+
f.write(self.stage0_cargo_rev())
191190

192-
def stage0_cargo_date(self):
193-
return self._cargo_date
194-
195-
def stage0_cargo_channel(self):
196-
return self._cargo_channel
191+
def stage0_cargo_rev(self):
192+
return self._cargo_rev
197193

198194
def stage0_rustc_date(self):
199195
return self._rustc_date
@@ -217,7 +213,7 @@ def cargo_out_of_date(self):
217213
if not os.path.exists(self.cargo_stamp()) or self.clean:
218214
return True
219215
with open(self.cargo_stamp(), 'r') as f:
220-
return self.stage0_cargo_date() != f.read()
216+
return self.stage0_cargo_rev() != f.read()
221217

222218
def bin_root(self):
223219
return os.path.join(self.build_dir, self.build, "stage0")
@@ -467,7 +463,7 @@ def main():
467463

468464
data = stage0_data(rb.rust_root)
469465
rb._rustc_channel, rb._rustc_date = data['rustc'].split('-', 1)
470-
rb._cargo_channel, rb._cargo_date = data['cargo'].split('-', 1)
466+
rb._cargo_rev = data['cargo']
471467

472468
start_time = time()
473469

src/bootstrap/doc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ pub fn std(build: &Build, stage: u32, target: &str) {
146146
let mut cargo = build.cargo(&compiler, Mode::Libstd, target, "doc");
147147
cargo.arg("--manifest-path")
148148
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
149-
.arg("--features").arg(build.std_features());
149+
.arg("--features").arg(build.std_features())
150+
.arg("-p").arg("std");
150151
build.run(&mut cargo);
151152
cp_r(&out_dir, &out)
152153
}

src/bootstrap/step.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ pub fn build_rules(build: &Build) -> Rules {
458458
for (krate, path, default) in krates("test_shim") {
459459
rules.doc(&krate.doc_step, path)
460460
.dep(|s| s.name("libtest"))
461-
.default(default && build.config.docs)
461+
.default(default && build.config.compiler_docs)
462462
.run(move |s| doc::test(build, s.stage, s.target));
463463
}
464464
for (krate, path, default) in krates("rustc-main") {

src/liballoc_jemalloc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ links = "jemalloc"
99
name = "alloc_jemalloc"
1010
path = "lib.rs"
1111
test = false
12+
doc = false
1213

1314
[dependencies]
1415
core = { path = "../libcore" }

src/liballoc_system/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.0.0"
77
name = "alloc_system"
88
path = "lib.rs"
99
test = false
10+
doc = false
1011

1112
[dependencies]
1213
core = { path = "../libcore" }

src/libcompiler_builtins/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name = "compiler_builtins"
99
path = "lib.rs"
1010
test = false
1111
bench = false
12+
doc = false
1213

1314
[dependencies]
1415
core = { path = "../libcore" }

src/libpanic_abort/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.0.0"
77
path = "lib.rs"
88
test = false
99
bench = false
10+
doc = false
1011

1112
[dependencies]
1213
core = { path = "../libcore" }

src/libpanic_unwind/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.0.0"
77
path = "lib.rs"
88
test = false
99
bench = false
10+
doc = false
1011

1112
[dependencies]
1213
alloc = { path = "../liballoc" }

src/librand/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ version = "0.0.0"
66
[lib]
77
name = "rand"
88
path = "lib.rs"
9+
doc = false
910

1011
[dependencies]
1112
core = { path = "../libcore" }

src/librustc/lint/builtin.rs

+7
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ declare_lint! {
211211
not named `mod.rs`"
212212
}
213213

214+
declare_lint! {
215+
pub LEGACY_IMPORTS,
216+
Warn,
217+
"detects names that resolve to ambiguous glob imports with RFC 1560"
218+
}
219+
214220
declare_lint! {
215221
pub DEPRECATED,
216222
Warn,
@@ -257,6 +263,7 @@ impl LintPass for HardwiredLints {
257263
PATTERNS_IN_FNS_WITHOUT_BODY,
258264
EXTRA_REQUIREMENT_IN_IMPL,
259265
LEGACY_DIRECTORY_OWNERSHIP,
266+
LEGACY_IMPORTS,
260267
DEPRECATED
261268
)
262269
}

src/librustc/ty/layout.rs

+4
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,10 @@ impl<'a, 'gcx, 'tcx> Struct {
575575
});
576576
}
577577

578+
// Disable field reordering until we can decide what to do.
579+
// The odd pattern here avoids a warning about the value never being read.
580+
if can_optimize { can_optimize = false }
581+
578582
let (optimize, sort_ascending) = match kind {
579583
StructKind::AlwaysSizedUnivariant => (can_optimize, false),
580584
StructKind::MaybeUnsizedUnivariant => (can_optimize, false),

src/librustc_borrowck/borrowck/mir/elaborate_drops.rs

+39-38
Original file line numberDiff line numberDiff line change
@@ -481,54 +481,55 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
481481
is_cleanup: bool)
482482
-> Vec<BasicBlock>
483483
{
484-
let mut succ = succ;
485484
let mut unwind_succ = if is_cleanup {
486485
None
487486
} else {
488487
c.unwind
489488
};
490-
let mut update_drop_flag = true;
489+
490+
let mut succ = self.new_block(
491+
c, c.is_cleanup, TerminatorKind::Goto { target: succ }
492+
);
493+
494+
// Always clear the "master" drop flag at the bottom of the
495+
// ladder. This is needed because the "master" drop flag
496+
// protects the ADT's discriminant, which is invalidated
497+
// after the ADT is dropped.
498+
self.set_drop_flag(
499+
Location { block: succ, statement_index: 0 },
500+
c.path,
501+
DropFlagState::Absent
502+
);
491503

492504
fields.iter().rev().enumerate().map(|(i, &(ref lv, path))| {
493-
let drop_block = match path {
494-
Some(path) => {
495-
debug!("drop_ladder: for std field {} ({:?})", i, lv);
496-
497-
self.elaborated_drop_block(&DropCtxt {
498-
source_info: c.source_info,
499-
is_cleanup: is_cleanup,
500-
init_data: c.init_data,
501-
lvalue: lv,
502-
path: path,
503-
succ: succ,
504-
unwind: unwind_succ,
505-
})
506-
}
507-
None => {
508-
debug!("drop_ladder: for rest field {} ({:?})", i, lv);
509-
510-
let blk = self.complete_drop(&DropCtxt {
511-
source_info: c.source_info,
512-
is_cleanup: is_cleanup,
513-
init_data: c.init_data,
514-
lvalue: lv,
515-
path: c.path,
516-
succ: succ,
517-
unwind: unwind_succ,
518-
}, update_drop_flag);
519-
520-
// the drop flag has been updated - updating
521-
// it again would clobber it.
522-
update_drop_flag = false;
523-
524-
blk
525-
}
505+
succ = if let Some(path) = path {
506+
debug!("drop_ladder: for std field {} ({:?})", i, lv);
507+
508+
self.elaborated_drop_block(&DropCtxt {
509+
source_info: c.source_info,
510+
is_cleanup: is_cleanup,
511+
init_data: c.init_data,
512+
lvalue: lv,
513+
path: path,
514+
succ: succ,
515+
unwind: unwind_succ,
516+
})
517+
} else {
518+
debug!("drop_ladder: for rest field {} ({:?})", i, lv);
519+
520+
self.complete_drop(&DropCtxt {
521+
source_info: c.source_info,
522+
is_cleanup: is_cleanup,
523+
init_data: c.init_data,
524+
lvalue: lv,
525+
path: c.path,
526+
succ: succ,
527+
unwind: unwind_succ,
528+
}, false)
526529
};
527530

528-
succ = drop_block;
529531
unwind_succ = unwind_ladder.as_ref().map(|p| p[i]);
530-
531-
drop_block
532+
succ
532533
}).collect()
533534
}
534535

src/librustc_lint/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
234234
id: LintId::of(LEGACY_DIRECTORY_OWNERSHIP),
235235
reference: "issue #37872 <https://github.com/rust-lang/rust/issues/37872>",
236236
},
237+
FutureIncompatibleInfo {
238+
id: LintId::of(LEGACY_IMPORTS),
239+
reference: "issue #38260 <https://github.com/rust-lang/rust/issues/38260>",
240+
},
237241
]);
238242

239243
// Register renamed and removed lints

src/librustc_resolve/lib.rs

+40-19
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind};
6464
use syntax::ast::{Local, Mutability, Pat, PatKind, Path};
6565
use syntax::ast::{PathSegment, PathParameters, QSelf, TraitItemKind, TraitRef, Ty, TyKind};
6666

67-
use syntax_pos::{Span, DUMMY_SP};
67+
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
6868
use errors::DiagnosticBuilder;
6969

7070
use std::cell::{Cell, RefCell};
@@ -896,6 +896,7 @@ enum NameBindingKind<'a> {
896896
Ambiguity {
897897
b1: &'a NameBinding<'a>,
898898
b2: &'a NameBinding<'a>,
899+
legacy: bool,
899900
}
900901
}
901902

@@ -907,13 +908,15 @@ struct AmbiguityError<'a> {
907908
lexical: bool,
908909
b1: &'a NameBinding<'a>,
909910
b2: &'a NameBinding<'a>,
911+
legacy: bool,
910912
}
911913

912914
impl<'a> NameBinding<'a> {
913915
fn module(&self) -> Option<Module<'a>> {
914916
match self.kind {
915917
NameBindingKind::Module(module) => Some(module),
916918
NameBindingKind::Import { binding, .. } => binding.module(),
919+
NameBindingKind::Ambiguity { legacy: true, b1, .. } => b1.module(),
917920
_ => None,
918921
}
919922
}
@@ -923,6 +926,7 @@ impl<'a> NameBinding<'a> {
923926
NameBindingKind::Def(def) => def,
924927
NameBindingKind::Module(module) => module.def().unwrap(),
925928
NameBindingKind::Import { binding, .. } => binding.def(),
929+
NameBindingKind::Ambiguity { legacy: true, b1, .. } => b1.def(),
926930
NameBindingKind::Ambiguity { .. } => Def::Err,
927931
}
928932
}
@@ -1349,11 +1353,14 @@ impl<'a> Resolver<'a> {
13491353
self.record_use(name, ns, binding, span)
13501354
}
13511355
NameBindingKind::Import { .. } => false,
1352-
NameBindingKind::Ambiguity { b1, b2 } => {
1356+
NameBindingKind::Ambiguity { b1, b2, legacy } => {
13531357
self.ambiguity_errors.push(AmbiguityError {
1354-
span: span, name: name, lexical: false, b1: b1, b2: b2,
1358+
span: span, name: name, lexical: false, b1: b1, b2: b2, legacy: legacy,
13551359
});
1356-
true
1360+
if legacy {
1361+
self.record_use(name, ns, b1, span);
1362+
}
1363+
!legacy
13571364
}
13581365
_ => false
13591366
}
@@ -2946,6 +2953,7 @@ impl<'a> Resolver<'a> {
29462953

29472954
let mut lookup_results = Vec::new();
29482955
let mut worklist = Vec::new();
2956+
let mut seen_modules = FxHashSet();
29492957
worklist.push((self.graph_root, Vec::new(), false));
29502958

29512959
while let Some((in_module,
@@ -3001,7 +3009,7 @@ impl<'a> Resolver<'a> {
30013009
if !in_module_is_extern || name_binding.vis == ty::Visibility::Public {
30023010
// add the module to the lookup
30033011
let is_extern = in_module_is_extern || name_binding.is_extern_crate();
3004-
if !worklist.iter().any(|&(m, ..)| m.def() == module.def()) {
3012+
if seen_modules.insert(module.def_id().unwrap()) {
30053013
worklist.push((module, path_segments, is_extern));
30063014
}
30073015
}
@@ -3065,26 +3073,39 @@ impl<'a> Resolver<'a> {
30653073
self.report_shadowing_errors();
30663074
let mut reported_spans = FxHashSet();
30673075

3068-
for &AmbiguityError { span, name, b1, b2, lexical } in &self.ambiguity_errors {
3076+
for &AmbiguityError { span, name, b1, b2, lexical, legacy } in &self.ambiguity_errors {
30693077
if !reported_spans.insert(span) { continue }
30703078
let participle = |binding: &NameBinding| {
30713079
if binding.is_import() { "imported" } else { "defined" }
30723080
};
30733081
let msg1 = format!("`{}` could resolve to the name {} here", name, participle(b1));
30743082
let msg2 = format!("`{}` could also resolve to the name {} here", name, participle(b2));
3075-
self.session.struct_span_err(span, &format!("`{}` is ambiguous", name))
3076-
.span_note(b1.span, &msg1)
3077-
.span_note(b2.span, &msg2)
3078-
.note(&if !lexical && b1.is_glob_import() {
3079-
format!("consider adding an explicit import of `{}` to disambiguate", name)
3080-
} else if let Def::Macro(..) = b1.def() {
3081-
format!("macro-expanded {} do not shadow",
3082-
if b1.is_import() { "macro imports" } else { "macros" })
3083-
} else {
3084-
format!("macro-expanded {} do not shadow when used in a macro invocation path",
3085-
if b1.is_import() { "imports" } else { "items" })
3086-
})
3087-
.emit();
3083+
let note = if !lexical && b1.is_glob_import() {
3084+
format!("consider adding an explicit import of `{}` to disambiguate", name)
3085+
} else if let Def::Macro(..) = b1.def() {
3086+
format!("macro-expanded {} do not shadow",
3087+
if b1.is_import() { "macro imports" } else { "macros" })
3088+
} else {
3089+
format!("macro-expanded {} do not shadow when used in a macro invocation path",
3090+
if b1.is_import() { "imports" } else { "items" })
3091+
};
3092+
if legacy {
3093+
let id = match b2.kind {
3094+
NameBindingKind::Import { directive, .. } => directive.id,
3095+
_ => unreachable!(),
3096+
};
3097+
let mut span = MultiSpan::from_span(span);
3098+
span.push_span_label(b1.span, msg1);
3099+
span.push_span_label(b2.span, msg2);
3100+
let msg = format!("`{}` is ambiguous", name);
3101+
self.session.add_lint(lint::builtin::LEGACY_IMPORTS, id, span, msg);
3102+
} else {
3103+
self.session.struct_span_err(span, &format!("`{}` is ambiguous", name))
3104+
.span_note(b1.span, &msg1)
3105+
.span_note(b2.span, &msg2)
3106+
.note(&note)
3107+
.emit();
3108+
}
30883109
}
30893110

30903111
for &PrivacyError(span, name, binding) in &self.privacy_errors {

0 commit comments

Comments
 (0)