Skip to content

Commit 7b4f489

Browse files
committed
Auto merge of #109056 - matthiaskrgr:rollup-9trny1z, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #108651 (Forbid the use of `#[target_feature]` on `main`) - #109009 (rustdoc: use restricted Damerau-Levenshtein distance for search) - #109026 (Introduce `Rc::into_inner`, as a parallel to `Arc::into_inner`) - #109029 (Gate usages of `dyn*` and const closures in macros) - #109031 (Rename `config.toml.example` to `config.example.toml`) - #109032 (Use `TyCtxt::trait_solver_next` in some places) - #109047 (typo) - #109052 (Add eslint check for rustdoc-gui tester) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 938afba + 5dc0113 commit 7b4f489

File tree

43 files changed

+549
-219
lines changed

Some content is hidden

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

43 files changed

+549
-219
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
src/etc/installer/gfx/* binary
1010
src/vendor/** -text
1111
Cargo.lock linguist-generated=false
12-
config.toml.example linguist-language=TOML
1312

1413
# Older git versions try to fix line endings on images and fonts, this prevents it.
1514
*.png binary

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Files: compiler/*
1616
Cargo.lock
1717
Cargo.toml
1818
CODE_OF_CONDUCT.md
19-
config.toml.example
19+
config.example.toml
2020
configure
2121
CONTRIBUTING.md
2222
COPYRIGHT

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ See [the rustc-dev-guide for more info][sysllvm].
9999
The Rust build system uses a file named `config.toml` in the root of the
100100
source tree to determine various configuration settings for the build.
101101
Set up the defaults intended for distros to get started. You can see a full
102-
list of options in `config.toml.example`.
102+
list of options in `config.example.toml`.
103103

104104
```sh
105105
printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
337337
ast::TyKind::Never => {
338338
gate_feature_post!(&self, never_type, ty.span, "the `!` type is experimental");
339339
}
340-
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::DynStar, ..) => {
341-
gate_feature_post!(&self, dyn_star, ty.span, "dyn* trait objects are unstable");
342-
}
343340
_ => {}
344341
}
345342
visit::walk_ty(self, ty)
@@ -425,14 +422,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
425422
ast::ExprKind::TryBlock(_) => {
426423
gate_feature_post!(&self, try_blocks, e.span, "`try` expression is experimental");
427424
}
428-
ast::ExprKind::Closure(box ast::Closure { constness: ast::Const::Yes(_), .. }) => {
429-
gate_feature_post!(
430-
&self,
431-
const_closures,
432-
e.span,
433-
"const closures are experimental"
434-
);
435-
}
436425
_ => {}
437426
}
438427
visit::walk_expr(self, e)
@@ -594,6 +583,8 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
594583
gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
595584
gate_all!(associated_const_equality, "associated const equality is incomplete");
596585
gate_all!(yeet_expr, "`do yeet` expression is experimental");
586+
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
587+
gate_all!(const_closures, "const closures are experimental");
597588

598589
// All uses of `gate_all!` below this point were added in #65742,
599590
// and subsequently disabled (with the non-early gating readded).

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
242242
// Note that this is also allowed if `actually_rustdoc` so
243243
// if a target is documenting some wasm-specific code then
244244
// it's not spuriously denied.
245+
//
246+
// This exception needs to be kept in sync with allowing
247+
// `#[target_feature]` on `main` and `start`.
245248
} else if !tcx.features().target_feature_11 {
246249
let mut err = feature_err(
247250
&tcx.sess.parse_sess,

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,14 @@ hir_analysis_where_clause_on_main = `main` function is not allowed to have a `wh
128128
hir_analysis_track_caller_on_main = `main` function is not allowed to be `#[track_caller]`
129129
.suggestion = remove this annotation
130130
131+
hir_analysis_target_feature_on_main = `main` function is not allowed to have `#[target_feature]`
132+
131133
hir_analysis_start_not_track_caller = `start` is not allowed to be `#[track_caller]`
132134
.label = `start` is not allowed to be `#[track_caller]`
133135
136+
hir_analysis_start_not_target_feature = `start` is not allowed to have `#[target_feature]`
137+
.label = `start` is not allowed to have `#[target_feature]`
138+
134139
hir_analysis_start_not_async = `start` is not allowed to be `async`
135140
.label = `start` is not allowed to be `async`
136141

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ pub(crate) struct TrackCallerOnMain {
327327
pub annotated: Span,
328328
}
329329

330+
#[derive(Diagnostic)]
331+
#[diag(hir_analysis_target_feature_on_main)]
332+
pub(crate) struct TargetFeatureOnMain {
333+
#[primary_span]
334+
#[label(hir_analysis_target_feature_on_main)]
335+
pub main: Span,
336+
}
337+
330338
#[derive(Diagnostic)]
331339
#[diag(hir_analysis_start_not_track_caller)]
332340
pub(crate) struct StartTrackCaller {
@@ -336,6 +344,15 @@ pub(crate) struct StartTrackCaller {
336344
pub start: Span,
337345
}
338346

347+
#[derive(Diagnostic)]
348+
#[diag(hir_analysis_start_not_target_feature)]
349+
pub(crate) struct StartTargetFeature {
350+
#[primary_span]
351+
pub span: Span,
352+
#[label]
353+
pub start: Span,
354+
}
355+
339356
#[derive(Diagnostic)]
340357
#[diag(hir_analysis_start_not_async, code = "E0752")]
341358
pub(crate) struct StartAsync {

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
283283
error = true;
284284
}
285285

286+
if !tcx.codegen_fn_attrs(main_def_id).target_features.is_empty()
287+
// Calling functions with `#[target_feature]` is not unsafe on WASM, see #84988
288+
&& !tcx.sess.target.is_like_wasm
289+
&& !tcx.sess.opts.actually_rustdoc
290+
{
291+
tcx.sess.emit_err(errors::TargetFeatureOnMain { main: main_span });
292+
error = true;
293+
}
294+
286295
if error {
287296
return;
288297
}
@@ -373,6 +382,18 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
373382
});
374383
error = true;
375384
}
385+
if attr.has_name(sym::target_feature)
386+
// Calling functions with `#[target_feature]` is
387+
// not unsafe on WASM, see #84988
388+
&& !tcx.sess.target.is_like_wasm
389+
&& !tcx.sess.opts.actually_rustdoc
390+
{
391+
tcx.sess.emit_err(errors::StartTargetFeature {
392+
span: attr.span,
393+
start: start_span,
394+
});
395+
error = true;
396+
}
376397
}
377398

378399
if error {

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ impl<'a> Parser<'a> {
21052105
ClosureBinder::NotPresent
21062106
};
21072107

2108-
let constness = self.parse_closure_constness(Case::Sensitive);
2108+
let constness = self.parse_closure_constness();
21092109

21102110
let movability =
21112111
if self.eat_keyword(kw::Static) { Movability::Static } else { Movability::Movable };

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,9 +1196,13 @@ impl<'a> Parser<'a> {
11961196
self.parse_constness_(case, false)
11971197
}
11981198

1199-
/// Parses constness for closures
1200-
fn parse_closure_constness(&mut self, case: Case) -> Const {
1201-
self.parse_constness_(case, true)
1199+
/// Parses constness for closures (case sensitive, feature-gated)
1200+
fn parse_closure_constness(&mut self) -> Const {
1201+
let constness = self.parse_constness_(Case::Sensitive, true);
1202+
if let Const::Yes(span) = constness {
1203+
self.sess.gated_spans.gate(sym::const_closures, span);
1204+
}
1205+
constness
12021206
}
12031207

12041208
fn parse_constness_(&mut self, case: Case, is_closure: bool) -> Const {

0 commit comments

Comments
 (0)