Skip to content

Commit fdd4856

Browse files
committed
Auto merge of #64438 - cuviper:beta-rollup, r=Mark-Simulacrum
[beta] Rollup backports Cherry-picked: - Permit unwinding through FFI by default #62603 - pprust: Do not print spaces before some tokens #63897 - Account for doc comments coming from proc macros without spans #63930 - Support "soft" feature-gating using a lint #64066 - Update xLTO compatibility table in rustc book. #64092 - Include compiler-rt in the source tarball #64240 - Update LLVM submodule #64317 r? @Mark-Simulacrum
2 parents d097af1 + e086278 commit fdd4856

32 files changed

+151
-60
lines changed

src/bootstrap/dist.rs

+1
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,7 @@ fn copy_src_dirs(builder: &Builder<'_>, src_dirs: &[&str], exclude_dirs: &[&str]
808808
"llvm-project/lld", "llvm-project\\lld",
809809
"llvm-project/lldb", "llvm-project\\lldb",
810810
"llvm-project/llvm", "llvm-project\\llvm",
811+
"llvm-project/compiler-rt", "llvm-project\\compiler-rt",
811812
];
812813
if spath.contains("llvm-project") && !spath.ends_with("llvm-project")
813814
&& !LLVM_PROJECTS.iter().any(|path| spath.contains(path))

src/doc/rustc/src/linker-plugin-lto.md

+1
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,6 @@ The following table shows known good combinations of toolchain versions.
105105
| Rust 1.34 |||
106106
| Rust 1.35 |||
107107
| Rust 1.36 |||
108+
| Rust 1.37 |||
108109

109110
Note that the compatibility policy for this feature might change in the future.

src/libcore/macros.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1281,8 +1281,10 @@ pub(crate) mod builtin {
12811281
pub macro test($item:item) { /* compiler built-in */ }
12821282

12831283
/// Attribute macro applied to a function to turn it into a benchmark test.
1284-
#[unstable(feature = "test", issue = "50297",
1285-
reason = "`bench` is a part of custom test frameworks which are unstable")]
1284+
#[cfg_attr(not(boostrap_stdarch_ignore_this), unstable(soft, feature = "test", issue = "50297",
1285+
reason = "`bench` is a part of custom test frameworks which are unstable"))]
1286+
#[cfg_attr(boostrap_stdarch_ignore_this, unstable(feature = "test", issue = "50297",
1287+
reason = "`bench` is a part of custom test frameworks which are unstable"))]
12861288
#[allow_internal_unstable(test, rustc_attrs)]
12871289
#[rustc_builtin_macro]
12881290
#[rustc_macro_transparency = "semitransparent"]

src/librustc/ich/impls_syntax.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ for ::syntax::attr::StabilityLevel {
136136
hasher: &mut StableHasher<W>) {
137137
mem::discriminant(self).hash_stable(hcx, hasher);
138138
match *self {
139-
::syntax::attr::StabilityLevel::Unstable { ref reason, ref issue } => {
139+
::syntax::attr::StabilityLevel::Unstable { ref reason, ref issue, ref is_soft } => {
140140
reason.hash_stable(hcx, hasher);
141141
issue.hash_stable(hcx, hasher);
142+
is_soft.hash_stable(hcx, hasher);
142143
}
143144
::syntax::attr::StabilityLevel::Stable { ref since } => {
144145
since.hash_stable(hcx, hasher);

src/librustc/lint/builtin.rs

+7
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ declare_lint! {
395395
"reservation of a two-phased borrow conflicts with other shared borrows"
396396
}
397397

398+
declare_lint! {
399+
pub SOFT_UNSTABLE,
400+
Deny,
401+
"a feature gate that doesn't break dependent crates"
402+
}
403+
398404
declare_lint_pass! {
399405
/// Does nothing as a lint pass, but registers some `Lint`s
400406
/// that are used by other parts of the compiler.
@@ -460,6 +466,7 @@ declare_lint_pass! {
460466
NESTED_IMPL_TRAIT,
461467
MUTABLE_BORROW_RESERVATION_CONFLICT,
462468
INDIRECT_STRUCTURAL_MATCH,
469+
SOFT_UNSTABLE,
463470
]
464471
}
465472

src/librustc/middle/stability.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ impl<'tcx> Index<'tcx> {
438438
level: attr::StabilityLevel::Unstable {
439439
reason: Some(Symbol::intern(reason)),
440440
issue: 27812,
441+
is_soft: false,
441442
},
442443
feature: sym::rustc_private,
443444
rustc_depr: None,
@@ -480,7 +481,7 @@ pub fn provide(providers: &mut Providers<'_>) {
480481
}
481482

482483
pub fn report_unstable(
483-
sess: &Session, feature: Symbol, reason: Option<Symbol>, issue: u32, span: Span
484+
sess: &Session, feature: Symbol, reason: Option<Symbol>, issue: u32, is_soft: bool, span: Span
484485
) {
485486
let msg = match reason {
486487
Some(r) => format!("use of unstable library feature '{}': {}", feature, r),
@@ -505,7 +506,13 @@ pub fn report_unstable(
505506
let error_id = (DiagnosticMessageId::StabilityId(issue), span_key, msg.clone());
506507
let fresh = sess.one_time_diagnostics.borrow_mut().insert(error_id);
507508
if fresh {
508-
emit_feature_err(&sess.parse_sess, feature, span, GateIssue::Library(Some(issue)), &msg);
509+
if is_soft {
510+
sess.buffer_lint(lint::builtin::SOFT_UNSTABLE, CRATE_NODE_ID, span, &msg);
511+
} else {
512+
emit_feature_err(
513+
&sess.parse_sess, feature, span, GateIssue::Library(Some(issue)), &msg
514+
);
515+
}
509516
}
510517
}
511518

@@ -621,6 +628,7 @@ pub enum EvalResult {
621628
feature: Symbol,
622629
reason: Option<Symbol>,
623630
issue: u32,
631+
is_soft: bool,
624632
},
625633
/// The item does not have the `#[stable]` or `#[unstable]` marker assigned.
626634
Unmarked,
@@ -720,7 +728,9 @@ impl<'tcx> TyCtxt<'tcx> {
720728
}
721729

722730
match stability {
723-
Some(&Stability { level: attr::Unstable { reason, issue }, feature, .. }) => {
731+
Some(&Stability {
732+
level: attr::Unstable { reason, issue, is_soft }, feature, ..
733+
}) => {
724734
if span.allows_unstable(feature) {
725735
debug!("stability: skipping span={:?} since it is internal", span);
726736
return EvalResult::Allow;
@@ -744,7 +754,7 @@ impl<'tcx> TyCtxt<'tcx> {
744754
}
745755
}
746756

747-
EvalResult::Deny { feature, reason, issue }
757+
EvalResult::Deny { feature, reason, issue, is_soft }
748758
}
749759
Some(_) => {
750760
// Stable APIs are always ok to call and deprecated APIs are
@@ -767,8 +777,8 @@ impl<'tcx> TyCtxt<'tcx> {
767777
pub fn check_stability(self, def_id: DefId, id: Option<HirId>, span: Span) {
768778
match self.eval_stability(def_id, id, span) {
769779
EvalResult::Allow => {}
770-
EvalResult::Deny { feature, reason, issue } =>
771-
report_unstable(self.sess, feature, reason, issue, span),
780+
EvalResult::Deny { feature, reason, issue, is_soft } =>
781+
report_unstable(self.sess, feature, reason, issue, is_soft, span),
772782
EvalResult::Unmarked => {
773783
// The API could be uncallable for other reasons, for example when a private module
774784
// was referenced.

src/librustc_lint/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,12 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
433433
id: LintId::of(INDIRECT_STRUCTURAL_MATCH),
434434
reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
435435
edition: None,
436-
}
436+
},
437+
FutureIncompatibleInfo {
438+
id: LintId::of(SOFT_UNSTABLE),
439+
reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
440+
edition: None,
441+
},
437442
]);
438443

439444
// Register renamed and removed lints.

src/librustc_mir/build/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, abi: Abi) -> bool {
502502
// This is a special case: some functions have a C abi but are meant to
503503
// unwind anyway. Don't stop them.
504504
match unwind_attr {
505-
None => true,
505+
None => false, // FIXME(#58794)
506506
Some(UnwindAttr::Allowed) => false,
507507
Some(UnwindAttr::Aborts) => true,
508508
}

src/librustc_resolve/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,10 @@ impl<'a> Resolver<'a> {
797797
fn check_stability_and_deprecation(&self, ext: &SyntaxExtension, path: &ast::Path) {
798798
let span = path.span;
799799
if let Some(stability) = &ext.stability {
800-
if let StabilityLevel::Unstable { reason, issue } = stability.level {
800+
if let StabilityLevel::Unstable { reason, issue, is_soft } = stability.level {
801801
let feature = stability.feature;
802802
if !self.active_features.contains(&feature) && !span.allows_unstable(feature) {
803-
stability::report_unstable(self.session, feature, reason, issue, span);
803+
stability::report_unstable(self.session, feature, reason, issue, is_soft, span);
804804
}
805805
}
806806
if let Some(depr) = &stability.rustc_depr {

src/librustdoc/passes/check_code_block_syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'a, 'tcx> SyntaxChecker<'a, 'tcx> {
6969
// We couldn't calculate the span of the markdown block that had the error, so our
7070
// diagnostics are going to be a bit lacking.
7171
let mut diag = self.cx.sess().struct_span_warn(
72-
super::span_of_attrs(&item.attrs),
72+
super::span_of_attrs(&item.attrs).unwrap_or(item.source.span()),
7373
"doc comment contains an invalid Rust code block",
7474
);
7575

src/librustdoc/passes/collect_intra_doc_links.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ fn resolution_failure(
464464
}
465465
};
466466
let attrs = &item.attrs;
467-
let sp = span_of_attrs(attrs);
467+
let sp = span_of_attrs(attrs).unwrap_or(item.source.span());
468468

469469
let mut diag = cx.tcx.struct_span_lint_hir(
470470
lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE,
@@ -516,7 +516,7 @@ fn ambiguity_error(
516516
}
517517
};
518518
let attrs = &item.attrs;
519-
let sp = span_of_attrs(attrs);
519+
let sp = span_of_attrs(attrs).unwrap_or(item.source.span());
520520

521521
let mut msg = format!("`{}` is ", path_str);
522522

src/librustdoc/passes/mod.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ pub fn look_for_tests<'tcx>(
339339
find_testable_code(&dox, &mut tests, ErrorCodes::No);
340340

341341
if check_missing_code == true && tests.found_tests == 0 {
342-
let sp = span_of_attrs(&item.attrs).substitute_dummy(item.source.span());
342+
let sp = span_of_attrs(&item.attrs).unwrap_or(item.source.span());
343343
let mut diag = cx.tcx.struct_span_lint_hir(
344344
lint::builtin::MISSING_DOC_CODE_EXAMPLES,
345345
hir_id,
@@ -352,20 +352,23 @@ pub fn look_for_tests<'tcx>(
352352
let mut diag = cx.tcx.struct_span_lint_hir(
353353
lint::builtin::PRIVATE_DOC_TESTS,
354354
hir_id,
355-
span_of_attrs(&item.attrs),
355+
span_of_attrs(&item.attrs).unwrap_or(item.source.span()),
356356
"Documentation test in private item");
357357
diag.emit();
358358
}
359359
}
360360

361361
/// Returns a span encompassing all the given attributes.
362-
crate fn span_of_attrs(attrs: &clean::Attributes) -> Span {
362+
crate fn span_of_attrs(attrs: &clean::Attributes) -> Option<Span> {
363363
if attrs.doc_strings.is_empty() {
364-
return DUMMY_SP;
364+
return None;
365365
}
366366
let start = attrs.doc_strings[0].span();
367+
if start == DUMMY_SP {
368+
return None;
369+
}
367370
let end = attrs.doc_strings.last().expect("No doc strings provided").span();
368-
start.to(end)
371+
Some(start.to(end))
369372
}
370373

371374
/// Attempts to match a range of bytes from parsed markdown to a `Span` in the source code.
@@ -391,7 +394,7 @@ crate fn source_span_for_markdown_range(
391394
let snippet = cx
392395
.sess()
393396
.source_map()
394-
.span_to_snippet(span_of_attrs(attrs))
397+
.span_to_snippet(span_of_attrs(attrs)?)
395398
.ok()?;
396399

397400
let starting_line = markdown[..md_range.start].matches('\n').count();
@@ -441,10 +444,8 @@ crate fn source_span_for_markdown_range(
441444
}
442445
}
443446

444-
let sp = span_of_attrs(attrs).from_inner(InnerSpan::new(
447+
Some(span_of_attrs(attrs)?.from_inner(InnerSpan::new(
445448
md_range.start + start_bytes,
446449
md_range.end + start_bytes + end_bytes,
447-
));
448-
449-
Some(sp)
450+
)))
450451
}

src/libsyntax/attr/builtin.rs

+12-16
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,10 @@ pub struct Stability {
154154
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Copy, Clone, Debug, Eq, Hash)]
155155
pub enum StabilityLevel {
156156
// Reason for the current stability level and the relevant rust-lang issue
157-
Unstable { reason: Option<Symbol>, issue: u32 },
157+
Unstable { reason: Option<Symbol>, issue: u32, is_soft: bool },
158158
Stable { since: Symbol },
159159
}
160160

161-
impl Stability {
162-
pub fn unstable(feature: Symbol, reason: Option<Symbol>, issue: u32) -> Stability {
163-
Stability {
164-
level: StabilityLevel::Unstable { reason, issue },
165-
feature,
166-
rustc_depr: None,
167-
const_stability: None,
168-
promotable: false,
169-
allow_const_fn_ptr: false,
170-
}
171-
}
172-
}
173-
174161
impl StabilityLevel {
175162
pub fn is_unstable(&self) -> bool {
176163
if let StabilityLevel::Unstable {..} = *self {
@@ -356,19 +343,27 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
356343
let mut feature = None;
357344
let mut reason = None;
358345
let mut issue = None;
346+
let mut is_soft = false;
359347
for meta in metas {
360348
if let Some(mi) = meta.meta_item() {
361349
match mi.name_or_empty() {
362350
sym::feature => if !get(mi, &mut feature) { continue 'outer },
363351
sym::reason => if !get(mi, &mut reason) { continue 'outer },
364352
sym::issue => if !get(mi, &mut issue) { continue 'outer },
353+
sym::soft => {
354+
if !mi.is_word() {
355+
let msg = "`soft` should not have any arguments";
356+
sess.span_diagnostic.span_err(mi.span, msg);
357+
}
358+
is_soft = true;
359+
}
365360
_ => {
366361
handle_errors(
367362
sess,
368363
meta.span(),
369364
AttrError::UnknownMetaItem(
370365
mi.path.to_string(),
371-
&["feature", "reason", "issue"]
366+
&["feature", "reason", "issue", "soft"]
372367
),
373368
);
374369
continue 'outer
@@ -400,7 +395,8 @@ fn find_stability_generic<'a, I>(sess: &ParseSess,
400395
"incorrect 'issue'");
401396
continue
402397
}
403-
}
398+
},
399+
is_soft,
404400
},
405401
feature,
406402
rustc_depr: None,

src/libsyntax/print/pprust.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ pub fn to_string<F>(f: F) -> String where
152152
printer.s.eof()
153153
}
154154

155+
// This makes comma-separated lists look slightly nicer,
156+
// and also addresses a specific regression described in issue #63896.
157+
fn tt_prepend_space(tt: &TokenTree) -> bool {
158+
match tt {
159+
TokenTree::Token(token) => match token.kind {
160+
token::Comma => false,
161+
_ => true,
162+
}
163+
_ => true,
164+
}
165+
}
166+
155167
fn binop_to_string(op: BinOpToken) -> &'static str {
156168
match op {
157169
token::Plus => "+",
@@ -684,7 +696,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target=pp::Printer> + std::ops::DerefM
684696

685697
fn print_tts(&mut self, tts: tokenstream::TokenStream, convert_dollar_crate: bool) {
686698
for (i, tt) in tts.into_trees().enumerate() {
687-
if i != 0 {
699+
if i != 0 && tt_prepend_space(&tt) {
688700
self.space();
689701
}
690702
self.print_tt(tt, convert_dollar_crate);

src/libsyntax_pos/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ symbols! {
623623
size,
624624
slice_patterns,
625625
slicing_syntax,
626+
soft,
626627
Some,
627628
specialization,
628629
speed,

src/llvm-project

Submodule llvm-project updated 229 files

src/test/codegen/c-variadic.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#![crate_type = "lib"]
44
#![feature(c_variadic)]
5+
#![feature(unwind_attributes)]
56
#![no_std]
67
use core::ffi::VaList;
78

@@ -10,6 +11,7 @@ extern "C" {
1011
fn foreign_c_variadic_1(_: VaList, ...);
1112
}
1213

14+
#[unwind(aborts)] // FIXME(#58794)
1315
pub unsafe extern "C" fn use_foreign_c_variadic_0() {
1416
// Ensure that we correctly call foreign C-variadic functions.
1517
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0)
@@ -24,20 +26,24 @@ pub unsafe extern "C" fn use_foreign_c_variadic_0() {
2426

2527
// Ensure that we do not remove the `va_list` passed to the foreign function when
2628
// removing the "spoofed" `VaListImpl` that is used by Rust defined C-variadics.
29+
#[unwind(aborts)] // FIXME(#58794)
2730
pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) {
2831
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap)
2932
foreign_c_variadic_1(ap);
3033
}
3134

35+
#[unwind(aborts)] // FIXME(#58794)
3236
pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) {
3337
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 42)
3438
foreign_c_variadic_1(ap, 42i32);
3539
}
40+
#[unwind(aborts)] // FIXME(#58794)
3641
pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) {
3742
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42)
3843
foreign_c_variadic_1(ap, 2i32, 42i32);
3944
}
4045

46+
#[unwind(aborts)] // FIXME(#58794)
4147
pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) {
4248
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42, i32 0)
4349
foreign_c_variadic_1(ap, 2i32, 42i32, 0i32);

0 commit comments

Comments
 (0)