Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #132815

Merged
merged 21 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1990f15
Reject raw lifetime followed by \' as well
compiler-errors Oct 30, 2024
9785c7c
Enforce that raw lifetime identifiers must be valid raw identifiers
compiler-errors Oct 30, 2024
90fa5b6
add regression test for #90781
lolbinarycat Nov 7, 2024
8f7f9b9
Add a run-make test for `rustc --help` and similar
Zalathar Nov 7, 2024
584c820
Use a method to apply `RustcOptGroup` to `getopts::Options`
Zalathar Nov 8, 2024
001013c
Simplify command-line-option declarations in the compiler
Zalathar Nov 7, 2024
b8377e5
Simplify command-line-argument declarations in librustdoc
Zalathar Nov 7, 2024
76b6090
read repository information configs at an earlier stage
onur-ozkan Nov 8, 2024
cce6f03
use `download-rustc="if-unchanged"` as default whenever possible
onur-ozkan Nov 8, 2024
2e0afc8
respect to global `download-rustc` default in non-dist profiles
onur-ozkan Nov 8, 2024
6ffab47
Use lld with non-LLVM backends
bjorn3 Nov 8, 2024
2a38108
fix `core::config::tests::override_toml`
onur-ozkan Nov 8, 2024
d37e6df
Add str to "expected primitive, found type" diagnostic
zachs18 Nov 9, 2024
5f6645d
Add test for str for "expected primitive, found type"
zachs18 Nov 9, 2024
9b50092
Rollup merge of #132341 - compiler-errors:raw-lt-prefix-id, r=chenyukang
matthiaskrgr Nov 9, 2024
910ac7e
Rollup merge of #132363 - compiler-errors:raw-lt-id-valid, r=wesleywiser
matthiaskrgr Nov 9, 2024
5f58dc9
Rollup merge of #132744 - lolbinarycat:test-90781, r=aDotInTheVoid
matthiaskrgr Nov 9, 2024
88acd49
Rollup merge of #132754 - Zalathar:opts, r=GuillaumeGomez,jieyouxu
matthiaskrgr Nov 9, 2024
c435fa8
Rollup merge of #132772 - onur-ozkan:download-rustc-default, r=jieyouxu
matthiaskrgr Nov 9, 2024
9b47807
Rollup merge of #132774 - bjorn3:cranelift_lld, r=lqd
matthiaskrgr Nov 9, 2024
3aa1a24
Rollup merge of #132799 - zachs18:str-primitive-symbol, r=compiler-er…
matthiaskrgr Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3305,23 +3305,6 @@ fn add_lld_args(
let self_contained_cli = sess.opts.cg.link_self_contained.is_linker_enabled();
let self_contained_target = self_contained_components.is_linker_enabled();

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

let self_contained_linker = self_contained_cli || self_contained_target;
if self_contained_linker && !sess.opts.cg.link_self_contained.is_linker_disabled() {
let mut linker_path_exists = false;
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ fn usage(verbose: bool, include_unstable_options: bool, nightly_build: bool) {
let groups = if verbose { config::rustc_optgroups() } else { config::rustc_short_optgroups() };
let mut options = getopts::Options::new();
for option in groups.iter().filter(|x| include_unstable_options || x.is_stable()) {
(option.apply)(&mut options);
option.apply(&mut options);
}
let message = "Usage: rustc [OPTIONS] INPUT";
let nightly_help = if nightly_build {
Expand Down Expand Up @@ -1219,7 +1219,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
let mut options = getopts::Options::new();
let optgroups = config::rustc_optgroups();
for option in &optgroups {
(option.apply)(&mut options);
option.apply(&mut options);
}
let matches = options.parse(args).unwrap_or_else(|e| {
let msg: Option<String> = match e {
Expand All @@ -1233,7 +1233,7 @@ pub fn handle_options(early_dcx: &EarlyDiagCtxt, args: &[String]) -> Option<geto
optgroups.iter().find(|option| option.name == opt).map(|option| {
// Print the help just for the option in question.
let mut options = getopts::Options::new();
(option.apply)(&mut options);
option.apply(&mut options);
// getopt requires us to pass a function for joining an iterator of
// strings, even though in this case we expect exactly one string.
options.usage_with_format(|it| {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ where
fn optgroups() -> getopts::Options {
let mut opts = getopts::Options::new();
for group in rustc_optgroups() {
(group.apply)(&mut opts);
group.apply(&mut opts);
}
return opts;
}
Expand Down
12 changes: 11 additions & 1 deletion compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,17 @@ impl Cursor<'_> {
self.bump();
self.bump();
self.eat_while(is_id_continue);
return RawLifetime;
match self.first() {
'\'' => {
// Check if after skipping literal contents we've met a closing
// single quote (which means that user attempted to create a
// string with single quotes).
self.bump();
let kind = Char { terminated: true };
return Literal { kind, suffix_start: self.pos_within_token() };
}
_ => return RawLifetime,
}
}

// Either a lifetime or a character literal with
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,7 @@ impl<'tcx> Ty<'tcx> {
ty::UintTy::U64 => Some(sym::u64),
ty::UintTy::U128 => Some(sym::u128),
},
ty::Str => Some(sym::str),
_ => None,
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_parse/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ parse_box_syntax_removed_suggestion = use `Box::new()` instead
parse_cannot_be_raw_ident = `{$ident}` cannot be a raw identifier
parse_cannot_be_raw_lifetime = `{$ident}` cannot be a raw lifetime
parse_catch_after_try = keyword `catch` cannot follow a `try` block
.help = try using `match` on the result of the `try` block instead
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,14 @@ pub(crate) struct CannotBeRawIdent {
pub ident: Symbol,
}

#[derive(Diagnostic)]
#[diag(parse_cannot_be_raw_lifetime)]
pub(crate) struct CannotBeRawLifetime {
#[primary_span]
pub span: Span,
pub ident: Symbol,
}

#[derive(Diagnostic)]
#[diag(parse_keyword_lifetime)]
pub(crate) struct KeywordLifetime {
Expand Down
14 changes: 10 additions & 4 deletions compiler/rustc_parse/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,21 @@ impl<'psess, 'src> StringReader<'psess, 'src> {
let prefix_span = self.mk_sp(start, ident_start);

if prefix_span.at_least_rust_2021() {
let lifetime_name_without_tick = self.str_from(ident_start);
let span = self.mk_sp(start, self.pos);

let lifetime_name_without_tick = Symbol::intern(&self.str_from(ident_start));
if !lifetime_name_without_tick.can_be_raw() {
self.dcx().emit_err(errors::CannotBeRawLifetime { span, ident: lifetime_name_without_tick });
}

// Put the `'` back onto the lifetime name.
let mut lifetime_name = String::with_capacity(lifetime_name_without_tick.len() + 1);
let mut lifetime_name = String::with_capacity(lifetime_name_without_tick.as_str().len() + 1);
lifetime_name.push('\'');
lifetime_name += lifetime_name_without_tick;
lifetime_name += lifetime_name_without_tick.as_str();
let sym = Symbol::intern(&lifetime_name);

// Make sure we mark this as a raw identifier.
self.psess.raw_identifier_spans.push(self.mk_sp(start, self.pos));
self.psess.raw_identifier_spans.push(span);

token::Lifetime(sym, IdentIsRaw::Yes)
} else {
Expand Down
Loading
Loading