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 9 pull requests #127876

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2f305ff
Remove an unnecessary `?`.
nnethercote Jul 16, 2024
48cdfc3
Inline `Parser::parse_item_common_`.
nnethercote Jul 16, 2024
d247489
Reorder `Parser::parse_expr_dot_or_call_with` arguments.
nnethercote Jul 16, 2024
96cc9c9
Inline and remove `Parser::parse_and_disallow_postfix_after_cast`.
nnethercote Jul 16, 2024
96b39f1
Inline and remove `Parser::parse_expr_dot_or_call_with_`.
nnethercote Jul 16, 2024
8cb6bc3
Fix a comment.
nnethercote Jul 16, 2024
9c4f3db
Remove references to `maybe_whole_expr`.
nnethercote Jul 16, 2024
17c70a9
unix: split stack_overflow::install_main_guard by os
workingjubilee Jul 17, 2024
e285c95
unix: stack_start_aligned is a safe fn
workingjubilee Jul 17, 2024
6ed563d
unix: clean up install_main_guard_freebsd
workingjubilee Jul 17, 2024
d47cb26
unix: unsafe-wrap install_main_guard_default
workingjubilee Jul 17, 2024
adc48b0
Add internal lint for detecting non-glob imports of `rustc_type_ir::i…
fmease Jul 17, 2024
99f879c
Document the column numbers for the dbg! macro
Kriskras99 Jul 17, 2024
1d40d4c
Fix precise capturing suggestion for hidden type when APITs are involved
compiler-errors Jul 12, 2024
f3f0b57
Commonize `uname -m` results for `aarch64` in docker runner
tgross35 Jul 16, 2024
e1852d0
Unignore cg_gcc fmt
GuillaumeGomez Jul 12, 2024
261d92c
Align cg_gcc rustfmt.toml with rust's
GuillaumeGomez Jul 17, 2024
12bedc3
Ignore files in cg_gcc example folder
GuillaumeGomez Jul 17, 2024
213782d
Format cg_gcc with same formatting parameters
GuillaumeGomez Jul 17, 2024
553279b
Add support for literals
c410-f3r Jul 17, 2024
37257b4
style-guide: Clarify version-sorting
joshtriplett Jul 17, 2024
2b60845
Rollup merge of #127542 - c410-f3r:concat-again, r=petrochenkov
matthiaskrgr Jul 17, 2024
51caf9c
Rollup merge of #127652 - GuillaumeGomez:cg-gcc-fmt, r=Urgau
matthiaskrgr Jul 17, 2024
52fffe9
Rollup merge of #127664 - compiler-errors:precise-capturing-better-su…
matthiaskrgr Jul 17, 2024
a560a59
Rollup merge of #127806 - nnethercote:parser-improvements, r=spastorino
matthiaskrgr Jul 17, 2024
909309b
Rollup merge of #127828 - tgross35:docker-aarch64-uname, r=onur-ozkan
matthiaskrgr Jul 17, 2024
aaa1041
Rollup merge of #127845 - workingjubilee:actually-break-up-big-ass-st…
matthiaskrgr Jul 17, 2024
831a039
Rollup merge of #127854 - fmease:glob-import-type_ir_inherent-lint, r…
matthiaskrgr Jul 17, 2024
9f7c8d1
Rollup merge of #127861 - Kriskras99:patch-1, r=tgross35
matthiaskrgr Jul 17, 2024
5a8d0ec
Rollup merge of #127875 - joshtriplett:style-guide-clarify-sorting, r…
matthiaskrgr Jul 17, 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
3 changes: 1 addition & 2 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,7 @@ impl Token {
false
}

/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
/// That is, is this a pre-parsed expression dropped into the token stream
/// Is this a pre-parsed expression dropped into the token stream
/// (which happens while parsing the result of macro expansion)?
pub fn is_whole_expr(&self) -> bool {
if let Interpolated(nt) = &self.kind
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_gcc/.rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
version = "Two"
use_small_heuristics = "Max"
merge_derives = false
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/build_system/src/clone_gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Args {
"--out-path" => match args.next() {
Some(path) if !path.is_empty() => out_path = Some(path),
_ => {
return Err("Expected an argument after `--out-path`, found nothing".into())
return Err("Expected an argument after `--out-path`, found nothing".into());
}
},
"--help" => {
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_codegen_gcc/build_system/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl ConfigFile {
config.gcc_path = Some(value.as_str().to_string())
}
("gcc-path", _) => {
return failed_config_parsing(config_file, "Expected a string for `gcc-path`")
return failed_config_parsing(config_file, "Expected a string for `gcc-path`");
}
("download-gccjit", TomlValue::Boolean(value)) => {
config.download_gccjit = Some(*value)
Expand All @@ -63,7 +63,7 @@ impl ConfigFile {
return failed_config_parsing(
config_file,
"Expected a boolean for `download-gccjit`",
)
);
}
_ => return failed_config_parsing(config_file, &format!("Unknown key `{}`", key)),
}
Expand All @@ -73,7 +73,7 @@ impl ConfigFile {
return failed_config_parsing(
config_file,
"At least one of `gcc-path` or `download-gccjit` value must be set",
)
);
}
(Some(_), Some(true)) => {
println!(
Expand Down Expand Up @@ -144,7 +144,7 @@ impl ConfigInfo {
_ => {
return Err(
"Expected a value after `--target-triple`, found nothing".to_string()
)
);
}
},
"--out-dir" => match args.next() {
Expand All @@ -158,7 +158,7 @@ impl ConfigInfo {
self.config_file = Some(arg.to_string());
}
_ => {
return Err("Expected a value after `--config-file`, found nothing".to_string())
return Err("Expected a value after `--config-file`, found nothing".to_string());
}
},
"--release-sysroot" => self.sysroot_release_channel = true,
Expand All @@ -169,7 +169,7 @@ impl ConfigInfo {
self.cg_gcc_path = Some(arg.into());
}
_ => {
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string())
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string());
}
},
"--use-backend" => match args.next() {
Expand Down Expand Up @@ -277,7 +277,7 @@ impl ConfigInfo {
self.gcc_path = match gcc_path {
Some(path) => path,
None => {
return Err(format!("missing `gcc-path` value from `{}`", config_file.display(),))
return Err(format!("missing `gcc-path` value from `{}`", config_file.display(),));
}
};
Ok(())
Expand Down
14 changes: 3 additions & 11 deletions compiler/rustc_codegen_gcc/build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl TestArg {
test_arg.flags.extend_from_slice(&["--features".into(), feature]);
}
_ => {
return Err("Expected an argument after `--features`, found nothing".into())
return Err("Expected an argument after `--features`, found nothing".into());
}
},
"--use-system-gcc" => {
Expand Down Expand Up @@ -458,11 +458,7 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
.map_err(|error| format!("Failed to retrieve cargo path: {:?}", error))
.and_then(|cargo| {
let cargo = cargo.trim().to_owned();
if cargo.is_empty() {
Err(format!("`cargo` path is empty"))
} else {
Ok(cargo)
}
if cargo.is_empty() { Err(format!("`cargo` path is empty")) } else { Ok(cargo) }
})?;
let rustc = String::from_utf8(
run_command_with_env(&[&"rustup", &toolchain, &"which", &"rustc"], rust_dir, Some(env))?
Expand All @@ -471,11 +467,7 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<PathBuf, String> {
.map_err(|error| format!("Failed to retrieve rustc path: {:?}", error))
.and_then(|rustc| {
let rustc = rustc.trim().to_owned();
if rustc.is_empty() {
Err(format!("`rustc` path is empty"))
} else {
Ok(rustc)
}
if rustc.is_empty() { Err(format!("`rustc` path is empty")) } else { Ok(rustc) }
})?;
let llvm_filecheck = match run_command_with_env(
&[
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_gcc/build_system/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,7 @@ pub fn cargo_install(to_install: &str) -> Result<(), String> {
pub fn get_os_name() -> Result<String, String> {
let output = run_command(&[&"uname"], None)?;
let name = std::str::from_utf8(&output.stdout).unwrap_or("").trim().to_string();
if !name.is_empty() {
Ok(name)
} else {
Err("Failed to retrieve the OS name".to_string())
}
if !name.is_empty() { Ok(name) } else { Err("Failed to retrieve the OS name".to_string()) }
}

#[derive(Default, PartialEq)]
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_gcc/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ impl<'a, 'gcc, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
} else {
false
};
if on_stack {
param.to_lvalue().get_address(None)
} else {
param.to_rvalue()
}
if on_stack { param.to_lvalue().get_address(None) } else { param.to_rvalue() }
}
}

Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_gcc/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,7 @@ fn modifier_to_gcc(
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::reg) => modifier,
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg)
| InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::vreg_low16) => {
if modifier == Some('v') {
None
} else {
modifier
}
if modifier == Some('v') { None } else { modifier }
}
InlineAsmRegClass::AArch64(AArch64InlineAsmRegClass::preg) => {
unreachable!("clobber-only")
Expand Down
18 changes: 3 additions & 15 deletions compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,11 +1043,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let llty = place.layout.scalar_pair_element_gcc_type(self, i);
let load = self.load(llty, llptr, align);
scalar_load_metadata(self, load, scalar);
if scalar.is_bool() {
self.trunc(load, self.type_i1())
} else {
load
}
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
};

OperandValue::Pair(
Expand Down Expand Up @@ -1795,18 +1791,10 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
// This already happens today with u128::MAX = 2^128 - 1 > f32::MAX.
let int_max = |signed: bool, int_width: u64| -> u128 {
let shift_amount = 128 - int_width;
if signed {
i128::MAX as u128 >> shift_amount
} else {
u128::MAX >> shift_amount
}
if signed { i128::MAX as u128 >> shift_amount } else { u128::MAX >> shift_amount }
};
let int_min = |signed: bool, int_width: u64| -> i128 {
if signed {
i128::MIN >> (128 - int_width)
} else {
0
}
if signed { i128::MIN >> (128 - int_width) } else { 0 }
};

let compute_clamp_bounds_single = |signed: bool, int_width: u64| -> (u128, u128) {
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ pub fn type_is_pointer(typ: Type<'_>) -> bool {

impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
fn const_null(&self, typ: Type<'gcc>) -> RValue<'gcc> {
if type_is_pointer(typ) {
self.context.new_null(typ)
} else {
self.const_int(typ, 0)
}
if type_is_pointer(typ) { self.context.new_null(typ) } else { self.const_int(typ, 0) }
}

fn const_undef(&self, typ: Type<'gcc>) -> RValue<'gcc> {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_expand/src/mbe/metavar_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ impl MetaVarExpr {
}
}

/// Indicates what is placed in a `concat` parameter. For example, literals
/// (`${concat("foo", "bar")}`) or adhoc identifiers (`${concat(foo, bar)}`).
#[derive(Debug, Decodable, Encodable, PartialEq)]
pub(crate) enum MetaVarExprConcatElem {
/// Identifier WITHOUT a preceding dollar sign, which means that this identifier should be
Expand Down
59 changes: 35 additions & 24 deletions compiler/rustc_expand/src/mbe/transcribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use crate::mbe::macro_parser::{NamedMatch, NamedMatch::*};
use crate::mbe::metavar_expr::{MetaVarExprConcatElem, RAW_IDENT_ERR};
use crate::mbe::{self, KleeneOp, MetaVarExpr};
use rustc_ast::mut_visit::{self, MutVisitor};
use rustc_ast::token::IdentIsRaw;
use rustc_ast::token::{self, Delimiter, Token, TokenKind};
use rustc_ast::token::{self, Delimiter, Nonterminal, Token, TokenKind};
use rustc_ast::token::{IdentIsRaw, Lit, LitKind};
use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree};
use rustc_ast::ExprKind;
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{pluralize, Diag, DiagCtxtHandle, PResult};
use rustc_parse::lexer::nfc_normalize;
Expand All @@ -17,7 +18,7 @@ use rustc_session::parse::ParseSess;
use rustc_session::parse::SymbolGallery;
use rustc_span::hygiene::{LocalExpnId, Transparency};
use rustc_span::symbol::{sym, Ident, MacroRulesNormalizedIdent};
use rustc_span::{with_metavar_spans, Span, SyntaxContext};
use rustc_span::{with_metavar_spans, Span, Symbol, SyntaxContext};
use smallvec::{smallvec, SmallVec};
use std::mem;

Expand Down Expand Up @@ -691,12 +692,12 @@ fn transcribe_metavar_expr<'a>(
MetaVarExpr::Concat(ref elements) => {
let mut concatenated = String::new();
for element in elements.into_iter() {
let string = match element {
MetaVarExprConcatElem::Ident(elem) => elem.to_string(),
MetaVarExprConcatElem::Literal(elem) => elem.as_str().into(),
MetaVarExprConcatElem::Var(elem) => extract_ident(dcx, *elem, interp)?,
let symbol = match element {
MetaVarExprConcatElem::Ident(elem) => elem.name,
MetaVarExprConcatElem::Literal(elem) => *elem,
MetaVarExprConcatElem::Var(elem) => extract_var_symbol(dcx, *elem, interp)?,
};
concatenated.push_str(&string);
concatenated.push_str(symbol.as_str());
}
let symbol = nfc_normalize(&concatenated);
let concatenated_span = visited_span();
Expand Down Expand Up @@ -750,32 +751,42 @@ fn transcribe_metavar_expr<'a>(
Ok(())
}

/// Extracts an identifier that can be originated from a `$var:ident` variable or from a token tree.
fn extract_ident<'a>(
/// Extracts an metavariable symbol that can be an identifier, a token tree or a literal.
fn extract_var_symbol<'a>(
dcx: DiagCtxtHandle<'a>,
ident: Ident,
interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
) -> PResult<'a, String> {
) -> PResult<'a, Symbol> {
if let NamedMatch::MatchedSingle(pnr) = matched_from_ident(dcx, ident, interp)? {
if let ParseNtResult::Ident(nt_ident, is_raw) = pnr {
if let IdentIsRaw::Yes = is_raw {
return Err(dcx.struct_span_err(ident.span, RAW_IDENT_ERR));
}
return Ok(nt_ident.to_string());
return Ok(nt_ident.name);
}
if let ParseNtResult::Tt(TokenTree::Token(
Token { kind: TokenKind::Ident(token_ident, is_raw), .. },
_,
)) = pnr
{
if let IdentIsRaw::Yes = is_raw {
return Err(dcx.struct_span_err(ident.span, RAW_IDENT_ERR));

if let ParseNtResult::Tt(TokenTree::Token(Token { kind, .. }, _)) = pnr {
if let TokenKind::Ident(symbol, is_raw) = kind {
if let IdentIsRaw::Yes = is_raw {
return Err(dcx.struct_span_err(ident.span, RAW_IDENT_ERR));
}
return Ok(*symbol);
}
return Ok(token_ident.to_string());

if let TokenKind::Literal(Lit { kind: LitKind::Str, symbol, suffix: None }) = kind {
return Ok(*symbol);
}
}

if let ParseNtResult::Nt(nt) = pnr
&& let Nonterminal::NtLiteral(expr) = &**nt
&& let ExprKind::Lit(Lit { kind: LitKind::Str, symbol, suffix: None }) = &expr.kind
{
return Ok(*symbol);
}
}
Err(dcx.struct_span_err(
ident.span,
"`${concat(..)}` currently only accepts identifiers or meta-variables as parameters",
))
Err(dcx
.struct_err("metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`")
.with_note("currently only string literals are supported")
.with_span(ident.span))
}
5 changes: 5 additions & 0 deletions compiler/rustc_infer/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ infer_outlives_content = lifetime of reference outlives lifetime of borrowed con
infer_precise_capturing_existing = add `{$new_lifetime}` to the `use<...>` bound to explicitly capture it
infer_precise_capturing_new = add a `use<...>` bound to explicitly capture `{$new_lifetime}`

infer_precise_capturing_new_but_apit = add a `use<...>` bound to explicitly capture `{$new_lifetime}` after turning all argument-position `impl Trait` into type parameters, noting that this possibly affects the API of this crate

infer_prlf_defined_with_sub = the lifetime `{$sub_symbol}` defined here...
infer_prlf_defined_without_sub = the lifetime defined here...
infer_prlf_known_limitation = this is a known limitation that will be removed in the future (see issue #100013 <https://github.com/rust-lang/rust/issues/100013> for more information)
Expand Down Expand Up @@ -387,6 +389,9 @@ infer_type_annotations_needed = {$source_kind ->
.label = type must be known at this point

infer_types_declared_different = these two types are declared with different lifetimes...

infer_warn_removing_apit_params = you could use a `use<...>` bound to explicitly capture `{$new_lifetime}`, but argument-position `impl Trait`s are not nameable

infer_where_copy_predicates = copy the `where` clause predicates from the trait

infer_where_remove = remove the `where` clause
Loading
Loading