Skip to content

Commit 1ad5635

Browse files
committedAug 4, 2022
Auto merge of rust-lang#100123 - matthiaskrgr:rollup-aylwvyc, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#98877 (Set llvm configs when building lld) - rust-lang#100068 (Fix backwards-compatibility check for tests with `+whole-archive`) - rust-lang#100083 (rustdoc: use a more compact encoding for source-files.js) - rust-lang#100102 (Fix typo) - rust-lang#100104 (Remove more Clean trait implementations) - rust-lang#100105 (Add regression test for rust-lang#90871) - rust-lang#100107 (fix trailing whitespace in error message) - rust-lang#100111 (Provide suggestion on missing `let` in binding statement) - rust-lang#100119 (FilesTimes support does not build for ESP-IDF) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 59d99f5 + a44532c commit 1ad5635

File tree

19 files changed

+208
-94
lines changed

19 files changed

+208
-94
lines changed
 

‎compiler/rustc_ast_passes/src/feature_gate.rs

+27-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_ast as ast;
22
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
33
use rustc_ast::{AssocConstraint, AssocConstraintKind, NodeId};
44
use rustc_ast::{PatKind, RangeEnd, VariantData};
5-
use rustc_errors::struct_span_err;
5+
use rustc_errors::{struct_span_err, Applicability};
66
use rustc_feature::{AttributeGate, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
77
use rustc_feature::{Features, GateIssue};
88
use rustc_session::parse::{feature_err, feature_err_issue};
@@ -577,6 +577,32 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
577577
}
578578
}
579579

580+
fn visit_stmt(&mut self, stmt: &'a ast::Stmt) {
581+
if let ast::StmtKind::Semi(expr) = &stmt.kind
582+
&& let ast::ExprKind::Assign(lhs, _, _) = &expr.kind
583+
&& let ast::ExprKind::Type(..) = lhs.kind
584+
&& self.sess.parse_sess.span_diagnostic.err_count() == 0
585+
&& !self.features.type_ascription
586+
&& !lhs.span.allows_unstable(sym::type_ascription)
587+
{
588+
// When we encounter a statement of the form `foo: Ty = val;`, this will emit a type
589+
// ascription error, but the likely intention was to write a `let` statement. (#78907).
590+
feature_err_issue(
591+
&self.sess.parse_sess,
592+
sym::type_ascription,
593+
lhs.span,
594+
GateIssue::Language,
595+
"type ascription is experimental",
596+
).span_suggestion_verbose(
597+
lhs.span.shrink_to_lo(),
598+
"you might have meant to introduce a new binding",
599+
"let ".to_string(),
600+
Applicability::MachineApplicable,
601+
).emit();
602+
}
603+
visit::walk_stmt(self, stmt);
604+
}
605+
580606
fn visit_expr(&mut self, e: &'a ast::Expr) {
581607
match e.kind {
582608
ast::ExprKind::Box(_) => {
@@ -795,8 +821,6 @@ fn maybe_stage_features(sess: &Session, krate: &ast::Crate) {
795821
// checks if `#![feature]` has been used to enable any lang feature
796822
// does not check the same for lib features unless there's at least one
797823
// declared lang feature
798-
use rustc_errors::Applicability;
799-
800824
if !sess.opts.unstable_features.is_nightly_build() {
801825
let lang_features = &sess.features_untracked().declared_lang_features;
802826
if lang_features.len() == 0 {

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2736,7 +2736,7 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
27362736
self.errors.push((
27372737
e.span,
27382738
format!(
2739-
"if the `for` loop runs 0 times, {} is not initialized ",
2739+
"if the `for` loop runs 0 times, {} is not initialized",
27402740
self.name
27412741
),
27422742
));

‎compiler/rustc_codegen_ssa/src/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ fn add_local_native_libraries(
22672267
// be added explicitly if necessary, see the error in `fn link_rlib`) compiled
22682268
// as an executable due to `--test`. Use whole-archive implicitly, like before
22692269
// the introduction of native lib modifiers.
2270-
|| (bundle != Some(false) && sess.opts.test)
2270+
|| (whole_archive == None && bundle != Some(false) && sess.opts.test)
22712271
{
22722272
cmd.link_whole_staticlib(
22732273
name,

‎compiler/rustc_infer/src/infer/higher_ranked/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
1717
///
1818
/// This is implemented by first entering a new universe.
1919
/// We then replace all bound variables in `sup` with placeholders,
20-
/// and all bound variables in `sup` with inference vars.
20+
/// and all bound variables in `sub` with inference vars.
2121
/// We can then just relate the two resulting types as normal.
2222
///
2323
/// Note: this is a subtle algorithm. For a full explanation, please see

‎library/std/src/sys/unix/fs.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,11 @@ impl Default for FileTimes {
544544
fn default() -> Self {
545545
// Redox doesn't appear to support `UTIME_OMIT`, so we stub it out here, and always return
546546
// an error in `set_times`.
547-
#[cfg(target_os = "redox")]
547+
// ESP-IDF does not support `futimens` at all and the behavior for that OS is therefore
548+
// the same as for Redox.
549+
#[cfg(any(target_os = "redox", target_os = "espidf"))]
548550
let omit = libc::timespec { tv_sec: 0, tv_nsec: 0 };
549-
#[cfg(not(target_os = "redox"))]
551+
#[cfg(not(any(target_os = "redox", target_os = "espidf")))]
550552
let omit = libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ };
551553
Self([omit; 2])
552554
}
@@ -1077,8 +1079,10 @@ impl File {
10771079

10781080
pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
10791081
cfg_if::cfg_if! {
1080-
if #[cfg(target_os = "redox")] {
1082+
if #[cfg(any(target_os = "redox", target_os = "espidf"))] {
10811083
// Redox doesn't appear to support `UTIME_OMIT`.
1084+
// ESP-IDF does not support `futimens` at all and the behavior for that OS is therefore
1085+
// the same as for Redox.
10821086
drop(times);
10831087
Err(io::const_io_error!(
10841088
io::ErrorKind::Unsupported,

‎src/bootstrap/native.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,6 @@ impl Step for Llvm {
345345
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
346346
}
347347

348-
if builder.config.llvm_thin_lto {
349-
cfg.define("LLVM_ENABLE_LTO", "Thin");
350-
if !target.contains("apple") {
351-
cfg.define("LLVM_ENABLE_LLD", "ON");
352-
}
353-
}
354-
355348
// This setting makes the LLVM tools link to the dynamic LLVM library,
356349
// which saves both memory during parallel links and overall disk space
357350
// for the tools. We don't do this on every platform as it doesn't work
@@ -463,15 +456,8 @@ impl Step for Llvm {
463456
cfg.define("LLVM_VERSION_SUFFIX", suffix);
464457
}
465458

466-
if let Some(ref linker) = builder.config.llvm_use_linker {
467-
cfg.define("LLVM_USE_LINKER", linker);
468-
}
469-
470-
if builder.config.llvm_allow_old_toolchain {
471-
cfg.define("LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN", "YES");
472-
}
473-
474459
configure_cmake(builder, target, &mut cfg, true, ldflags);
460+
configure_llvm(builder, target, &mut cfg);
475461

476462
for (key, val) in &builder.config.llvm_build_config {
477463
cfg.define(key, val);
@@ -731,6 +717,25 @@ fn configure_cmake(
731717
}
732718
}
733719

720+
fn configure_llvm(builder: &Builder<'_>, target: TargetSelection, cfg: &mut cmake::Config) {
721+
// ThinLTO is only available when building with LLVM, enabling LLD is required.
722+
// Apple's linker ld64 supports ThinLTO out of the box though, so don't use LLD on Darwin.
723+
if builder.config.llvm_thin_lto {
724+
cfg.define("LLVM_ENABLE_LTO", "Thin");
725+
if !target.contains("apple") {
726+
cfg.define("LLVM_ENABLE_LLD", "ON");
727+
}
728+
}
729+
730+
if let Some(ref linker) = builder.config.llvm_use_linker {
731+
cfg.define("LLVM_USE_LINKER", linker);
732+
}
733+
734+
if builder.config.llvm_allow_old_toolchain {
735+
cfg.define("LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN", "YES");
736+
}
737+
}
738+
734739
// Adapted from https://github.com/alexcrichton/cc-rs/blob/fba7feded71ee4f63cfe885673ead6d7b4f2f454/src/lib.rs#L2347-L2365
735740
fn get_var(var_base: &str, host: &str, target: &str) -> Option<OsString> {
736741
let kind = if host == target { "HOST" } else { "TARGET" };
@@ -794,6 +799,7 @@ impl Step for Lld {
794799
}
795800

796801
configure_cmake(builder, target, &mut cfg, true, ldflags);
802+
configure_llvm(builder, target, &mut cfg);
797803

798804
// This is an awful, awful hack. Discovered when we migrated to using
799805
// clang-cl to compile LLVM/LLD it turns out that LLD, when built out of
@@ -825,10 +831,6 @@ impl Step for Lld {
825831
.define("LLVM_CONFIG_PATH", llvm_config_shim)
826832
.define("LLVM_INCLUDE_TESTS", "OFF");
827833

828-
if builder.config.llvm_allow_old_toolchain {
829-
cfg.define("LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN", "YES");
830-
}
831-
832834
// While we're using this horrible workaround to shim the execution of
833835
// llvm-config, let's just pile on more. I can't seem to figure out how
834836
// to build LLD as a standalone project and also cross-compile it at the

‎src/librustdoc/clean/mod.rs

+30-38
Original file line numberDiff line numberDiff line change
@@ -247,30 +247,28 @@ pub(crate) fn clean_middle_const<'tcx>(
247247
}
248248
}
249249

250-
impl<'tcx> Clean<'tcx, Option<Lifetime>> for ty::Region<'tcx> {
251-
fn clean(&self, _cx: &mut DocContext<'_>) -> Option<Lifetime> {
252-
match **self {
253-
ty::ReStatic => Some(Lifetime::statik()),
254-
ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => {
255-
if name != kw::UnderscoreLifetime { Some(Lifetime(name)) } else { None }
256-
}
257-
ty::ReEarlyBound(ref data) => {
258-
if data.name != kw::UnderscoreLifetime {
259-
Some(Lifetime(data.name))
260-
} else {
261-
None
262-
}
263-
}
264-
ty::ReLateBound(..)
265-
| ty::ReFree(..)
266-
| ty::ReVar(..)
267-
| ty::RePlaceholder(..)
268-
| ty::ReEmpty(_)
269-
| ty::ReErased => {
270-
debug!("cannot clean region {:?}", self);
250+
pub(crate) fn clean_middle_region<'tcx>(region: ty::Region<'tcx>) -> Option<Lifetime> {
251+
match *region {
252+
ty::ReStatic => Some(Lifetime::statik()),
253+
ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => {
254+
if name != kw::UnderscoreLifetime { Some(Lifetime(name)) } else { None }
255+
}
256+
ty::ReEarlyBound(ref data) => {
257+
if data.name != kw::UnderscoreLifetime {
258+
Some(Lifetime(data.name))
259+
} else {
271260
None
272261
}
273262
}
263+
ty::ReLateBound(..)
264+
| ty::ReFree(..)
265+
| ty::ReVar(..)
266+
| ty::RePlaceholder(..)
267+
| ty::ReEmpty(_)
268+
| ty::ReErased => {
269+
debug!("cannot clean region {:?}", region);
270+
None
271+
}
274272
}
275273
}
276274

@@ -321,7 +319,7 @@ impl<'tcx> Clean<'tcx, Option<WherePredicate>> for ty::Predicate<'tcx> {
321319
ty::PredicateKind::Trait(pred) => {
322320
clean_poly_trait_predicate(bound_predicate.rebind(pred), cx)
323321
}
324-
ty::PredicateKind::RegionOutlives(pred) => clean_region_outlives_predicate(pred, cx),
322+
ty::PredicateKind::RegionOutlives(pred) => clean_region_outlives_predicate(pred),
325323
ty::PredicateKind::TypeOutlives(pred) => clean_type_outlives_predicate(pred, cx),
326324
ty::PredicateKind::Projection(pred) => Some(clean_projection_predicate(pred, cx)),
327325
ty::PredicateKind::ConstEvaluatable(..) => None,
@@ -358,7 +356,6 @@ fn clean_poly_trait_predicate<'tcx>(
358356

359357
fn clean_region_outlives_predicate<'tcx>(
360358
pred: ty::OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>,
361-
cx: &mut DocContext<'tcx>,
362359
) -> Option<WherePredicate> {
363360
let ty::OutlivesPredicate(a, b) = pred;
364361

@@ -367,8 +364,10 @@ fn clean_region_outlives_predicate<'tcx>(
367364
}
368365

369366
Some(WherePredicate::RegionPredicate {
370-
lifetime: a.clean(cx).expect("failed to clean lifetime"),
371-
bounds: vec![GenericBound::Outlives(b.clean(cx).expect("failed to clean bounds"))],
367+
lifetime: clean_middle_region(a).expect("failed to clean lifetime"),
368+
bounds: vec![GenericBound::Outlives(
369+
clean_middle_region(b).expect("failed to clean bounds"),
370+
)],
372371
})
373372
}
374373

@@ -384,7 +383,9 @@ fn clean_type_outlives_predicate<'tcx>(
384383

385384
Some(WherePredicate::BoundPredicate {
386385
ty: clean_middle_ty(ty, cx, None),
387-
bounds: vec![GenericBound::Outlives(lt.clean(cx).expect("failed to clean lifetimes"))],
386+
bounds: vec![GenericBound::Outlives(
387+
clean_middle_region(lt).expect("failed to clean lifetimes"),
388+
)],
388389
bound_params: Vec::new(),
389390
})
390391
}
@@ -999,15 +1000,6 @@ impl<'tcx> Clean<'tcx, FnRetTy> for hir::FnRetTy<'tcx> {
9991000
}
10001001
}
10011002

1002-
impl<'tcx> Clean<'tcx, bool> for hir::IsAuto {
1003-
fn clean(&self, _: &mut DocContext<'tcx>) -> bool {
1004-
match *self {
1005-
hir::IsAuto::Yes => true,
1006-
hir::IsAuto::No => false,
1007-
}
1008-
}
1009-
}
1010-
10111003
impl<'tcx> Clean<'tcx, Path> for hir::TraitRef<'tcx> {
10121004
fn clean(&self, cx: &mut DocContext<'tcx>) -> Path {
10131005
let path = clean_path(self.path, cx);
@@ -1597,7 +1589,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
15971589
}
15981590
ty::RawPtr(mt) => RawPointer(mt.mutbl, Box::new(clean_middle_ty(mt.ty, cx, None))),
15991591
ty::Ref(r, ty, mutbl) => BorrowedRef {
1600-
lifetime: r.clean(cx),
1592+
lifetime: clean_middle_region(r),
16011593
mutability: mutbl,
16021594
type_: Box::new(clean_middle_ty(ty, cx, None)),
16031595
},
@@ -1644,7 +1636,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
16441636

16451637
inline::record_extern_fqn(cx, did, ItemType::Trait);
16461638

1647-
let lifetime = reg.clean(cx);
1639+
let lifetime = clean_middle_region(*reg);
16481640
let mut bounds = vec![];
16491641

16501642
for did in dids {
@@ -1710,7 +1702,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
17101702
let trait_ref = match bound_predicate.skip_binder() {
17111703
ty::PredicateKind::Trait(tr) => bound_predicate.rebind(tr.trait_ref),
17121704
ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(_ty, reg)) => {
1713-
if let Some(r) = reg.clean(cx) {
1705+
if let Some(r) = clean_middle_region(reg) {
17141706
regions.push(GenericBound::Outlives(r));
17151707
}
17161708
return None;

‎src/librustdoc/clean/utils.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use crate::clean::auto_trait::AutoTraitFinder;
22
use crate::clean::blanket_impl::BlanketImplFinder;
33
use crate::clean::render_macro_matchers::render_macro_matcher;
44
use crate::clean::{
5-
clean_middle_const, clean_middle_ty, inline, Clean, Crate, ExternalCrate, Generic, GenericArg,
6-
GenericArgs, ImportSource, Item, ItemKind, Lifetime, Path, PathSegment, Primitive,
7-
PrimitiveType, Type, TypeBinding, Visibility,
5+
clean_middle_const, clean_middle_region, clean_middle_ty, inline, Clean, Crate, ExternalCrate,
6+
Generic, GenericArg, GenericArgs, ImportSource, Item, ItemKind, Lifetime, Path, PathSegment,
7+
Primitive, PrimitiveType, Type, TypeBinding, Visibility,
88
};
99
use crate::core::DocContext;
1010
use crate::formats::item_type::ItemType;
@@ -86,7 +86,7 @@ pub(crate) fn substs_to_args<'tcx>(
8686
Vec::with_capacity(substs.len().saturating_sub(if skip_first { 1 } else { 0 }));
8787
ret_val.extend(substs.iter().filter_map(|kind| match kind.unpack() {
8888
GenericArgKind::Lifetime(lt) => {
89-
Some(GenericArg::Lifetime(lt.clean(cx).unwrap_or(Lifetime::elided())))
89+
Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided())))
9090
}
9191
GenericArgKind::Type(_) if skip_first => {
9292
skip_first = false;

‎src/librustdoc/html/render/write_shared.rs

+20-13
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,15 @@ pub(super) fn write_shared(
366366
.collect::<Vec<_>>();
367367
files.sort_unstable();
368368
let subs = subs.iter().map(|s| s.to_json_string()).collect::<Vec<_>>().join(",");
369-
let dirs =
370-
if subs.is_empty() { String::new() } else { format!(",\"dirs\":[{}]", subs) };
369+
let dirs = if subs.is_empty() && files.is_empty() {
370+
String::new()
371+
} else {
372+
format!(",[{}]", subs)
373+
};
371374
let files = files.join(",");
372-
let files =
373-
if files.is_empty() { String::new() } else { format!(",\"files\":[{}]", files) };
375+
let files = if files.is_empty() { String::new() } else { format!(",[{}]", files) };
374376
format!(
375-
"{{\"name\":\"{name}\"{dirs}{files}}}",
377+
"[\"{name}\"{dirs}{files}]",
376378
name = self.elem.to_str().expect("invalid osstring conversion"),
377379
dirs = dirs,
378380
files = files
@@ -411,18 +413,23 @@ pub(super) fn write_shared(
411413
let dst = cx.dst.join(&format!("source-files{}.js", cx.shared.resource_suffix));
412414
let make_sources = || {
413415
let (mut all_sources, _krates) =
414-
try_err!(collect(&dst, krate.name(cx.tcx()).as_str(), "sourcesIndex"), &dst);
416+
try_err!(collect_json(&dst, krate.name(cx.tcx()).as_str()), &dst);
415417
all_sources.push(format!(
416-
"sourcesIndex[\"{}\"] = {};",
418+
r#""{}":{}"#,
417419
&krate.name(cx.tcx()),
418-
hierarchy.to_json_string()
420+
hierarchy
421+
.to_json_string()
422+
// All these `replace` calls are because we have to go through JS string for JSON content.
423+
.replace('\\', r"\\")
424+
.replace('\'', r"\'")
425+
// We need to escape double quotes for the JSON.
426+
.replace("\\\"", "\\\\\"")
419427
));
420428
all_sources.sort();
421-
Ok(format!(
422-
"var sourcesIndex = {{}};\n{}\ncreateSourceSidebar();\n",
423-
all_sources.join("\n")
424-
)
425-
.into_bytes())
429+
let mut v = String::from("var sourcesIndex = JSON.parse('{\\\n");
430+
v.push_str(&all_sources.join(",\\\n"));
431+
v.push_str("\\\n}');\ncreateSourceSidebar();\n");
432+
Ok(v.into_bytes())
426433
};
427434
write_crate("source-files.js", &make_sources)?;
428435
}

‎src/librustdoc/html/static/js/source-script.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-path"].value;
1313
let oldScrollPosition = 0;
1414

15+
const NAME_OFFSET = 0;
16+
const DIRS_OFFSET = 1;
17+
const FILES_OFFSET = 2;
18+
1519
function closeSidebarIfMobile() {
1620
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
1721
updateLocalStorage("source-sidebar-show", "false");
@@ -24,15 +28,15 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
2428

2529
dirEntry.className = "dir-entry";
2630

27-
fullPath += elem["name"] + "/";
31+
fullPath += elem[NAME_OFFSET] + "/";
2832

29-
summary.innerText = elem["name"];
33+
summary.innerText = elem[NAME_OFFSET];
3034
dirEntry.appendChild(summary);
3135

3236
const folders = document.createElement("div");
3337
folders.className = "folders";
34-
if (elem.dirs) {
35-
for (const dir of elem.dirs) {
38+
if (elem[DIRS_OFFSET]) {
39+
for (const dir of elem[DIRS_OFFSET]) {
3640
if (createDirEntry(dir, folders, fullPath, false)) {
3741
dirEntry.open = true;
3842
hasFoundFile = true;
@@ -43,8 +47,8 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
4347

4448
const files = document.createElement("div");
4549
files.className = "files";
46-
if (elem.files) {
47-
for (const file_text of elem.files) {
50+
if (elem[FILES_OFFSET]) {
51+
for (const file_text of elem[FILES_OFFSET]) {
4852
const file = document.createElement("a");
4953
file.innerText = file_text;
5054
file.href = rootPath + "src/" + fullPath + file_text + ".html";
@@ -125,7 +129,7 @@ function createSourceSidebar() {
125129
title.innerText = "Files";
126130
sidebar.appendChild(title);
127131
Object.keys(sourcesIndex).forEach(key => {
128-
sourcesIndex[key].name = key;
132+
sourcesIndex[key][NAME_OFFSET] = key;
129133
hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "",
130134
hasFoundFile);
131135
});

‎src/test/run-make/native-link-modifier-whole-archive/Makefile

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ignore-cross-compile -- compiling C++ code does not work well when cross-compiling
22

3-
# This test case makes sure that native libraries are linked with --whole-archive semantics
4-
# when the `-bundle,+whole-archive` modifiers are applied to them.
3+
# This test case makes sure that native libraries are linked with appropriate semantics
4+
# when the `[+-]bundle,[+-]whole-archive` modifiers are applied to them.
55
#
66
# The test works by checking that the resulting executables produce the expected output,
77
# part of which is emitted by otherwise unreferenced C code. If +whole-archive didn't work
@@ -10,15 +10,28 @@
1010

1111
-include ../../run-make-fulldeps/tools.mk
1212

13-
all: $(TMPDIR)/$(call BIN,directly_linked) $(TMPDIR)/$(call BIN,indirectly_linked) $(TMPDIR)/$(call BIN,indirectly_linked_via_attr)
13+
all: $(TMPDIR)/$(call BIN,directly_linked) \
14+
$(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive) \
15+
$(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive) \
16+
$(TMPDIR)/$(call BIN,indirectly_linked) \
17+
$(TMPDIR)/$(call BIN,indirectly_linked_via_attr)
1418
$(call RUN,directly_linked) | $(CGREP) 'static-initializer.directly_linked.'
19+
$(call RUN,directly_linked_test_plus_whole_archive) --nocapture | $(CGREP) 'static-initializer.'
20+
$(call RUN,directly_linked_test_minus_whole_archive) --nocapture | $(CGREP) -v 'static-initializer.'
1521
$(call RUN,indirectly_linked) | $(CGREP) 'static-initializer.indirectly_linked.'
1622
$(call RUN,indirectly_linked_via_attr) | $(CGREP) 'static-initializer.native_lib_in_src.'
1723

1824
# Native lib linked directly into executable
1925
$(TMPDIR)/$(call BIN,directly_linked): $(call NATIVE_STATICLIB,c_static_lib_with_constructor)
2026
$(RUSTC) directly_linked.rs -l static:+whole-archive=c_static_lib_with_constructor
2127

28+
# Native lib linked into test executable, +whole-archive
29+
$(TMPDIR)/$(call BIN,directly_linked_test_plus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor)
30+
$(RUSTC) directly_linked_test_plus_whole_archive.rs --test -l static:+whole-archive=c_static_lib_with_constructor
31+
# Native lib linked into test executable, -whole-archive
32+
$(TMPDIR)/$(call BIN,directly_linked_test_minus_whole_archive): $(call NATIVE_STATICLIB,c_static_lib_with_constructor)
33+
$(RUSTC) directly_linked_test_minus_whole_archive.rs --test -l static:-whole-archive=c_static_lib_with_constructor
34+
2235
# Native lib linked into RLIB via `-l static:-bundle,+whole-archive`, RLIB linked into executable
2336
$(TMPDIR)/$(call BIN,indirectly_linked): $(TMPDIR)/librlib_with_cmdline_native_lib.rlib
2437
$(RUSTC) indirectly_linked.rs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::io::Write;
2+
3+
#[test]
4+
fn test_thing() {
5+
print!("ran the test");
6+
std::io::stdout().flush().unwrap();
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::io::Write;
2+
3+
#[test]
4+
fn test_thing() {
5+
print!("ran the test");
6+
std::io::stdout().flush().unwrap();
7+
}

‎src/test/ui/borrowck/borrowck-for-loop-uninitialized-binding.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0381]: used binding `x` is possibly-uninitialized
44
LL | let mut x: isize;
55
| ----- binding declared here but left uninitialized
66
LL | for _ in 0..0 { x = 10; }
7-
| ---- if the `for` loop runs 0 times, `x` is not initialized
7+
| ---- if the `for` loop runs 0 times, `x` is not initialized
88
LL | return x;
99
| ^ `x` used here but it is possibly-uninitialized
1010

‎src/test/ui/closures/issue-90871.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn main() {
2+
2: n([u8; || 1])
3+
//~^ ERROR cannot find type `n` in this scope
4+
//~| ERROR mismatched types
5+
}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0412]: cannot find type `n` in this scope
2+
--> $DIR/issue-90871.rs:2:8
3+
|
4+
LL | 2: n([u8; || 1])
5+
| ^ expecting a type here because of type ascription
6+
7+
error[E0308]: mismatched types
8+
--> $DIR/issue-90871.rs:2:15
9+
|
10+
LL | 2: n([u8; || 1])
11+
| ^^^^ expected `usize`, found closure
12+
|
13+
= note: expected type `usize`
14+
found closure `[closure@$DIR/issue-90871.rs:2:15: 2:17]`
15+
help: use parentheses to call this closure
16+
|
17+
LL | 2: n([u8; (|| 1)()])
18+
| + +++
19+
20+
error: aborting due to 2 previous errors
21+
22+
Some errors have detailed explanations: E0308, E0412.
23+
For more information about an error, try `rustc --explain E0308`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// run-rustfix
2+
fn main() {
3+
let mut _foo: i32 = 1;
4+
let _foo: i32 = 4; //~ ERROR type ascription is experimental
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// run-rustfix
2+
fn main() {
3+
let mut _foo: i32 = 1;
4+
_foo: i32 = 4; //~ ERROR type ascription is experimental
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0658]: type ascription is experimental
2+
--> $DIR/missing-let-in-binding.rs:4:5
3+
|
4+
LL | _foo: i32 = 4;
5+
| ^^^^^^^^^
6+
|
7+
= note: see issue #23416 <https://github.com/rust-lang/rust/issues/23416> for more information
8+
= help: add `#![feature(type_ascription)]` to the crate attributes to enable
9+
help: you might have meant to introduce a new binding
10+
|
11+
LL | let _foo: i32 = 4;
12+
| +++
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)
Please sign in to comment.