Skip to content

Commit 4adafcf

Browse files
committed
Auto merge of #132815 - matthiaskrgr:rollup-nti992u, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #132341 (Reject raw lifetime followed by `'`, like regular lifetimes do) - #132363 (Enforce that raw lifetimes must be valid raw identifiers) - #132744 (add regression test for #90781) - #132754 (Simplify the internal API for declaring command-line options) - #132772 (use `download-rustc="if-unchanged"` as a global default) - #132774 (Use lld with non-LLVM backends) - #132799 (Make `Ty::primitive_symbol` recognize `str`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b026d85 + 3aa1a24 commit 4adafcf

File tree

27 files changed

+1059
-651
lines changed

27 files changed

+1059
-651
lines changed

Diff for: compiler/rustc_codegen_ssa/src/back/link.rs

-17
Original file line numberDiff line numberDiff line change
@@ -3305,23 +3305,6 @@ fn add_lld_args(
33053305
let self_contained_cli = sess.opts.cg.link_self_contained.is_linker_enabled();
33063306
let self_contained_target = self_contained_components.is_linker_enabled();
33073307

3308-
// FIXME: in the future, codegen backends may need to have more control over this process: they
3309-
// don't always support all the features the linker expects here, and vice versa. For example,
3310-
// at the time of writing this, lld expects a newer style of aarch64 TLS relocations that
3311-
// cranelift doesn't implement yet. That in turn can impact whether linking would succeed on
3312-
// such a target when using the `cg_clif` backend and lld.
3313-
//
3314-
// Until interactions between backends and linker features are expressible, we limit target
3315-
// specs to opt-in to lld only when we're on the llvm backend, where it's expected to work and
3316-
// tested on CI. As usual, the CLI still has precedence over this, so that users and developers
3317-
// can still override this default when needed (e.g. for tests).
3318-
let uses_llvm_backend =
3319-
matches!(sess.opts.unstable_opts.codegen_backend.as_deref(), None | Some("llvm"));
3320-
if !uses_llvm_backend && !self_contained_cli && sess.opts.cg.linker_flavor.is_none() {
3321-
// We bail if we're not using llvm and lld was not explicitly requested on the CLI.
3322-
return;
3323-
}
3324-
33253308
let self_contained_linker = self_contained_cli || self_contained_target;
33263309
if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() {
33273310
let mut linker_path_exists = false;

Diff for: compiler/rustc_driver_impl/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ fn usage(verbose: bool, include_unstable_options: bool, nightly_build: bool) {
937937
let groups = if verbose { config::rustc_optgroups() } else { config::rustc_short_optgroups() };
938938
let mut options = getopts::Options::new();
939939
for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
940-
(option.apply)(&mut options);
940+
option.apply(&mut options);
941941
}
942942
let message = "Usage: rustc [OPTIONS] INPUT";
943943
let nightly_help = if nightly_build {
@@ -1219,7 +1219,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
12191219
let mut options = getopts::Options::new();
12201220
let optgroups = config::rustc_optgroups();
12211221
for option in &optgroups {
1222-
(option.apply)(&mut options);
1222+
option.apply(&mut options);
12231223
}
12241224
let matches = options.parse(args).unwrap_or_else(|e| {
12251225
let msg: Option<String> = match e {
@@ -1233,7 +1233,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
12331233
optgroups.iter().find(|option| option.name == opt).map(|option| {
12341234
// Print the help just for the option in question.
12351235
let mut options = getopts::Options::new();
1236-
(option.apply)(&mut options);
1236+
option.apply(&mut options);
12371237
// getopt requires us to pass a function for joining an iterator of
12381238
// strings, even though in this case we expect exactly one string.
12391239
options.usage_with_format(|it| {

Diff for: compiler/rustc_interface/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
fn optgroups() -> getopts::Options {
103103
let mut opts = getopts::Options::new();
104104
for group in rustc_optgroups() {
105-
(group.apply)(&mut opts);
105+
group.apply(&mut opts);
106106
}
107107
return opts;
108108
}

Diff for: compiler/rustc_lexer/src/lib.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,17 @@ impl Cursor<'_> {
715715
self.bump();
716716
self.bump();
717717
self.eat_while(is_id_continue);
718-
return RawLifetime;
718+
match self.first() {
719+
'\'' => {
720+
// Check if after skipping literal contents we've met a closing
721+
// single quote (which means that user attempted to create a
722+
// string with single quotes).
723+
self.bump();
724+
let kind = Char { terminated: true };
725+
return Literal { kind, suffix_start: self.pos_within_token() };
726+
}
727+
_ => return RawLifetime,
728+
}
719729
}
720730

721731
// Either a lifetime or a character literal with

Diff for: compiler/rustc_middle/src/ty/sty.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1933,6 +1933,7 @@ impl<'tcx> Ty<'tcx> {
19331933
ty::UintTy::U64 => Some(sym::u64),
19341934
ty::UintTy::U128 => Some(sym::u128),
19351935
},
1936+
ty::Str => Some(sym::str),
19361937
_ => None,
19371938
}
19381939
}

Diff for: compiler/rustc_parse/messages.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ parse_box_syntax_removed_suggestion = use `Box::new()` instead
7777
7878
parse_cannot_be_raw_ident = `{$ident}` cannot be a raw identifier
7979
80+
parse_cannot_be_raw_lifetime = `{$ident}` cannot be a raw lifetime
81+
8082
parse_catch_after_try = keyword `catch` cannot follow a `try` block
8183
.help = try using `match` on the result of the `try` block instead
8284

Diff for: compiler/rustc_parse/src/errors.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,14 @@ pub(crate) struct CannotBeRawIdent {
20182018
pub ident: Symbol,
20192019
}
20202020

2021+
#[derive(Diagnostic)]
2022+
#[diag(parse_cannot_be_raw_lifetime)]
2023+
pub(crate) struct CannotBeRawLifetime {
2024+
#[primary_span]
2025+
pub span: Span,
2026+
pub ident: Symbol,
2027+
}
2028+
20212029
#[derive(Diagnostic)]
20222030
#[diag(parse_keyword_lifetime)]
20232031
pub(crate) struct KeywordLifetime {

Diff for: compiler/rustc_parse/src/lexer/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,21 @@ impl<'psess, 'src> StringReader<'psess, 'src> {
294294
let prefix_span = self.mk_sp(start, ident_start);
295295

296296
if prefix_span.at_least_rust_2021() {
297-
let lifetime_name_without_tick = self.str_from(ident_start);
297+
let span = self.mk_sp(start, self.pos);
298+
299+
let lifetime_name_without_tick = Symbol::intern(&self.str_from(ident_start));
300+
if !lifetime_name_without_tick.can_be_raw() {
301+
self.dcx().emit_err(errors::CannotBeRawLifetime { span, ident: lifetime_name_without_tick });
302+
}
303+
298304
// Put the `'` back onto the lifetime name.
299-
let mut lifetime_name = String::with_capacity(lifetime_name_without_tick.len() + 1);
305+
let mut lifetime_name = String::with_capacity(lifetime_name_without_tick.as_str().len() + 1);
300306
lifetime_name.push('\'');
301-
lifetime_name += lifetime_name_without_tick;
307+
lifetime_name += lifetime_name_without_tick.as_str();
302308
let sym = Symbol::intern(&lifetime_name);
303309

304310
// Make sure we mark this as a raw identifier.
305-
self.psess.raw_identifier_spans.push(self.mk_sp(start, self.pos));
311+
self.psess.raw_identifier_spans.push(span);
306312

307313
token::Lifetime(sym, IdentIsRaw::Yes)
308314
} else {

0 commit comments

Comments
 (0)