Skip to content

Commit 9f8012e

Browse files
committed
Auto merge of rust-lang#85458 - jackh726:rollup-zvvybmt, r=jackh726
Rollup of 8 pull requests Successful merges: - rust-lang#83366 (Stabilize extended_key_value_attributes) - rust-lang#83767 (Fix v0 symbol mangling bug) - rust-lang#84883 (compiletest: "fix" FileCheck with --allow-unused-prefixes) - rust-lang#85274 (Only pass --[no-]gc-sections if linker is GNU ld.) - rust-lang#85297 (bootstrap: build cargo only if requested in tools) - rust-lang#85396 (rustdoc: restore header sizes) - rust-lang#85425 (Fix must_use on `Option::is_none`) - rust-lang#85438 (Fix escape handling) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3d31363 + 6cfcbf7 commit 9f8012e

File tree

29 files changed

+226
-100
lines changed

29 files changed

+226
-100
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
712712
gate_all!(const_trait_impl, "const trait impls are experimental");
713713
gate_all!(half_open_range_patterns, "half-open range patterns are unstable");
714714
gate_all!(inline_const, "inline-const is experimental");
715-
gate_all!(
716-
extended_key_value_attributes,
717-
"arbitrary expressions in key-value attributes are unstable"
718-
);
719715
gate_all!(
720716
const_generics_defaults,
721717
"default values for const generic parameters are experimental"

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![feature(bool_to_option)]
99
#![feature(const_cstr_unchecked)]
1010
#![feature(crate_visibility_modifier)]
11-
#![feature(extended_key_value_attributes)]
11+
#![cfg_attr(bootstrap, feature(extended_key_value_attributes))]
1212
#![feature(extern_types)]
1313
#![feature(in_band_lifetimes)]
1414
#![feature(iter_zip)]

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,11 @@ impl<'a> Linker for GccLinker<'a> {
281281
}
282282
}
283283
LinkOutputKind::DynamicPicExe => {
284-
// `-pie` works for both gcc wrapper and ld.
285-
self.cmd.arg("-pie");
284+
// noop on windows w/ gcc & ld, error w/ lld
285+
if !self.sess.target.is_like_windows {
286+
// `-pie` works for both gcc wrapper and ld.
287+
self.cmd.arg("-pie");
288+
}
286289
}
287290
LinkOutputKind::StaticNoPicExe => {
288291
// `-static` works for both gcc wrapper and ld.
@@ -347,7 +350,7 @@ impl<'a> Linker for GccLinker<'a> {
347350
// has -needed-l{} / -needed_library {}
348351
// but we have no way to detect that here.
349352
self.sess.warn("`as-needed` modifier not implemented yet for ld64");
350-
} else if self.sess.target.linker_is_gnu {
353+
} else if self.sess.target.linker_is_gnu && !self.sess.target.is_like_windows {
351354
self.linker_arg("--no-as-needed");
352355
} else {
353356
self.sess.warn("`as-needed` modifier not supported for current linker");
@@ -358,7 +361,7 @@ impl<'a> Linker for GccLinker<'a> {
358361
if !as_needed {
359362
if self.sess.target.is_like_osx {
360363
// See above FIXME comment
361-
} else if self.sess.target.linker_is_gnu {
364+
} else if self.sess.target.linker_is_gnu && !self.sess.target.is_like_windows {
362365
self.linker_arg("--as-needed");
363366
}
364367
}
@@ -469,17 +472,15 @@ impl<'a> Linker for GccLinker<'a> {
469472
// eliminate the metadata. If we're building an executable, however,
470473
// --gc-sections drops the size of hello world from 1.8MB to 597K, a 67%
471474
// reduction.
472-
} else if !keep_metadata {
475+
} else if self.sess.target.linker_is_gnu && !keep_metadata {
473476
self.linker_arg("--gc-sections");
474477
}
475478
}
476479

477480
fn no_gc_sections(&mut self) {
478481
if self.sess.target.is_like_osx {
479482
self.linker_arg("-no_dead_strip");
480-
} else if self.sess.target.is_like_solaris {
481-
self.linker_arg("-zrecord");
482-
} else {
483+
} else if self.sess.target.linker_is_gnu {
483484
self.linker_arg("--no-gc-sections");
484485
}
485486
}
@@ -692,7 +693,7 @@ impl<'a> Linker for GccLinker<'a> {
692693
}
693694

694695
fn add_as_needed(&mut self) {
695-
if self.sess.target.linker_is_gnu {
696+
if self.sess.target.linker_is_gnu && !self.sess.target.is_like_windows {
696697
self.linker_arg("--as-needed");
697698
} else if self.sess.target.is_like_solaris {
698699
// -z ignore is the Solaris equivalent to the GNU ld --as-needed option

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
66
#![feature(crate_visibility_modifier)]
77
#![feature(backtrace)]
8-
#![feature(extended_key_value_attributes)]
8+
#![cfg_attr(bootstrap, feature(extended_key_value_attributes))]
99
#![feature(format_args_capture)]
1010
#![feature(iter_zip)]
1111
#![feature(nll)]

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ declare_features! (
281281
(accepted, or_patterns, "1.53.0", Some(54883), None),
282282
/// Allows defining identifiers beyond ASCII.
283283
(accepted, non_ascii_idents, "1.53.0", Some(55467), None),
284+
/// Allows arbitrary expressions in key-value attributes at parse time.
285+
(accepted, extended_key_value_attributes, "1.54.0", Some(78835), None),
284286

285287
// -------------------------------------------------------------------------
286288
// feature-group-end: accepted features

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,6 @@ declare_features! (
601601
/// Allows capturing disjoint fields in a closure/generator (RFC 2229).
602602
(active, capture_disjoint_fields, "1.49.0", Some(53488), None),
603603

604-
/// Allows arbitrary expressions in key-value attributes at parse time.
605-
(active, extended_key_value_attributes, "1.50.0", Some(78835), None),
606-
607604
/// Allows const generics to have default values (e.g. `struct Foo<const N: usize = 3>(...);`).
608605
(active, const_generics_defaults, "1.51.0", Some(44580), None),
609606

compiler/rustc_hir/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
#![feature(crate_visibility_modifier)]
66
#![feature(const_panic)]
7-
#![feature(extended_key_value_attributes)]
7+
#![cfg_attr(bootstrap, feature(extended_key_value_attributes))]
88
#![feature(in_band_lifetimes)]
99
#![feature(once_cell)]
1010
#![cfg_attr(bootstrap, feature(or_patterns))]

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,24 +1065,11 @@ impl<'a> Parser<'a> {
10651065
} else if !delimited_only {
10661066
if self.eat(&token::Eq) {
10671067
let eq_span = self.prev_token.span;
1068-
let mut is_interpolated_expr = false;
1069-
if let token::Interpolated(nt) = &self.token.kind {
1070-
if let token::NtExpr(..) = **nt {
1071-
is_interpolated_expr = true;
1072-
}
1073-
}
10741068

10751069
// Collect tokens because they are used during lowering to HIR.
10761070
let expr = self.parse_expr_force_collect()?;
10771071
let span = expr.span;
10781072

1079-
match &expr.kind {
1080-
// Not gated to support things like `doc = $expr` that work on stable.
1081-
_ if is_interpolated_expr => {}
1082-
ExprKind::Lit(lit) if lit.kind.is_unsuffixed() => {}
1083-
_ => self.sess.gated_spans.gate(sym::extended_key_value_attributes, span),
1084-
}
1085-
10861073
let token_kind = token::Interpolated(Lrc::new(token::NtExpr(expr)));
10871074
MacArgs::Eq(eq_span, Token::new(token_kind, span))
10881075
} else {

compiler/rustc_symbol_mangling/src/v0.rs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,39 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
485485
mut self,
486486
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
487487
) -> Result<Self::DynExistential, Self::Error> {
488-
for predicate in predicates {
489-
self = self.in_binder(&predicate, |mut cx, predicate| {
490-
match predicate {
488+
// Okay, so this is a bit tricky. Imagine we have a trait object like
489+
// `dyn for<'a> Foo<'a, Bar = &'a ()>`. When we mangle this, the
490+
// output looks really close to the syntax, where the `Bar = &'a ()` bit
491+
// is under the same binders (`['a]`) as the `Foo<'a>` bit. However, we
492+
// actually desugar these into two separate `ExistentialPredicate`s. We
493+
// can't enter/exit the "binder scope" twice though, because then we
494+
// would mangle the binders twice. (Also, side note, we merging these
495+
// two is kind of difficult, because of potential HRTBs in the Projection
496+
// predicate.)
497+
//
498+
// Also worth mentioning: imagine that we instead had
499+
// `dyn for<'a> Foo<'a, Bar = &'a ()> + Send`. In this case, `Send` is
500+
// under the same binders as `Foo`. Currently, this doesn't matter,
501+
// because only *auto traits* are allowed other than the principal trait
502+
// and all auto traits don't have any generics. Two things could
503+
// make this not an "okay" mangling:
504+
// 1) Instead of mangling only *used*
505+
// bound vars, we want to mangle *all* bound vars (`for<'b> Send` is a
506+
// valid trait predicate);
507+
// 2) We allow multiple "principal" traits in the future, or at least
508+
// allow in any form another trait predicate that can take generics.
509+
//
510+
// Here we assume that predicates have the following structure:
511+
// [<Trait> [{<Projection>}]] [{<Auto>}]
512+
// Since any predicates after the first one shouldn't change the binders,
513+
// just put them all in the binders of the first.
514+
self = self.in_binder(&predicates[0], |mut cx, _| {
515+
for predicate in predicates.iter() {
516+
// It would be nice to be able to validate bound vars here, but
517+
// projections can actually include bound vars from super traits
518+
// because of HRTBs (only in the `Self` type). Also, auto traits
519+
// could have different bound vars *anyways*.
520+
match predicate.as_ref().skip_binder() {
491521
ty::ExistentialPredicate::Trait(trait_ref) => {
492522
// Use a type that can't appear in defaults of type parameters.
493523
let dummy_self = cx.tcx.mk_ty_infer(ty::FreshTy(0));
@@ -504,9 +534,10 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
504534
cx = cx.print_def_path(*def_id, &[])?;
505535
}
506536
}
507-
Ok(cx)
508-
})?;
509-
}
537+
}
538+
Ok(cx)
539+
})?;
540+
510541
self.push("E");
511542
Ok(self)
512543
}

compiler/rustc_target/src/spec/windows_gnu_base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub fn opts() -> TargetOptions {
6666
// FIXME(#13846) this should be enabled for windows
6767
function_sections: false,
6868
linker: Some("gcc".to_string()),
69+
linker_is_gnu: true,
6970
dynamic_linking: true,
7071
executables: true,
7172
dll_prefix: String::new(),

0 commit comments

Comments
 (0)