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 #105059

Closed
wants to merge 21 commits into from
Closed
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
5dd073e
Encourage developers not to use periods in target names
flba-eb Nov 17, 2022
9c3555d
Remove periods from QNX/nto target names
flba-eb Nov 17, 2022
102a5d8
Print all features with --print target-features, including aliases an…
calebzulawski Nov 20, 2022
005c6df
type annotate &str when stack allocating a string
ismailmaj Nov 21, 2022
6a25bfa
Don't silently ignore errors that happen during rendering
jyn514 Nov 27, 2022
9d66ab0
Add `as_mut_os_string` to `&mut PathBuf` and `as_mut_os_str` to `&mut…
zertosh Nov 28, 2022
63915be
Statics used in reachable function's inline asm are reachable
tmiasko Nov 28, 2022
c975051
Remove useless borrows and derefs
WaffleLapkin Nov 29, 2022
7022962
`rustc_data_structures` deref in a more humane way
WaffleLapkin Nov 29, 2022
c8f3203
hermit: Fix fuzzy_provenance_casts
mkroening Nov 29, 2022
0a4e5ef
hermit: Remove unused exports
mkroening Nov 29, 2022
537488e
Make inferred_outlives_crate return Clause
spastorino Nov 25, 2022
439eaed
Rollup merge of #104436 - ismailmaj:add-slice-to-stack-allocated-stri…
matthiaskrgr Nov 29, 2022
7baba03
Rollup merge of #104523 - flba-eb:fix_nto_target_name, r=wesleywiser
matthiaskrgr Nov 29, 2022
3966485
Rollup merge of #104627 - calebzulawski:print-target-features, r=comp…
matthiaskrgr Nov 29, 2022
de1af83
Rollup merge of #104911 - spastorino:inferred_outlives_crate-return-c…
matthiaskrgr Nov 29, 2022
8937a2e
Rollup merge of #104995 - jyn514:lint-errors, r=Manishearth
matthiaskrgr Nov 29, 2022
34935e1
Rollup merge of #105002 - zertosh:acp-140, r=dtolnay
matthiaskrgr Nov 29, 2022
1505fc0
Rollup merge of #105023 - tmiasko:asm-sym-static-reachable, r=wesleyw…
matthiaskrgr Nov 29, 2022
93d698e
Rollup merge of #105049 - mkroening:hermit-fixes, r=jyn514
matthiaskrgr Nov 29, 2022
9126103
Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514
matthiaskrgr Nov 29, 2022
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
10 changes: 5 additions & 5 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ pub trait LayoutCalculator {
if !always_sized { StructKind::MaybeUnsized } else { StructKind::AlwaysSized }
};

let mut st = self.univariant(dl, &variants[v], &repr, kind)?;
let mut st = self.univariant(dl, &variants[v], repr, kind)?;
st.variants = Variants::Single { index: v };

if is_unsafe_cell {
Expand Down Expand Up @@ -457,7 +457,7 @@ pub trait LayoutCalculator {
let mut variant_layouts = variants
.iter_enumerated()
.map(|(j, v)| {
let mut st = self.univariant(dl, v, &repr, StructKind::AlwaysSized)?;
let mut st = self.univariant(dl, v, repr, StructKind::AlwaysSized)?;
st.variants = Variants::Single { index: j };

align = align.max(st.align);
Expand Down Expand Up @@ -647,8 +647,8 @@ pub trait LayoutCalculator {
.map(|(i, field_layouts)| {
let mut st = self.univariant(
dl,
&field_layouts,
&repr,
field_layouts,
repr,
StructKind::Prefixed(min_ity.size(), prefix_align),
)?;
st.variants = Variants::Single { index: i };
Expand Down Expand Up @@ -755,7 +755,7 @@ pub trait LayoutCalculator {
// Try to use a ScalarPair for all tagged enums.
let mut common_prim = None;
let mut common_prim_initialized_in_all_variants = true;
for (field_layouts, layout_variant) in iter::zip(&*variants, &layout_variants) {
for (field_layouts, layout_variant) in iter::zip(variants, &layout_variants) {
let FieldsShape::Arbitrary { ref offsets, .. } = layout_variant.fields else {
panic!();
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ impl Expr {
pub fn peel_parens(&self) -> &Expr {
let mut expr = self;
while let ExprKind::Paren(inner) = &expr.kind {
expr = &inner;
expr = inner;
}
expr
}
Expand Down Expand Up @@ -2023,7 +2023,7 @@ impl Ty {
pub fn peel_refs(&self) -> &Self {
let mut final_ty = self;
while let TyKind::Rptr(_, MutTy { ty, .. }) = &final_ty.kind {
final_ty = &ty;
final_ty = ty;
}
final_ty
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,7 @@ pub fn visit_token<T: MutVisitor>(t: &mut Token, vis: &mut T) {
return; // Avoid visiting the span for the second time.
}
token::Interpolated(nt) => {
let mut nt = Lrc::make_mut(nt);
visit_nonterminal(&mut nt, vis);
visit_nonterminal(Lrc::make_mut(nt), vis);
}
_ => {}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl TokenTree {
match (self, other) {
(TokenTree::Token(token, _), TokenTree::Token(token2, _)) => token.kind == token2.kind,
(TokenTree::Delimited(_, delim, tts), TokenTree::Delimited(_, delim2, tts2)) => {
delim == delim2 && tts.eq_unspanned(&tts2)
delim == delim2 && tts.eq_unspanned(tts2)
}
_ => false,
}
Expand Down Expand Up @@ -402,7 +402,7 @@ impl TokenStream {
let mut t1 = self.trees();
let mut t2 = other.trees();
for (t1, t2) in iter::zip(&mut t1, &mut t2) {
if !t1.eq_unspanned(&t2) {
if !t1.eq_unspanned(t2) {
return false;
}
}
Expand Down Expand Up @@ -475,7 +475,7 @@ impl TokenStream {
token::Interpolated(nt) => TokenTree::Delimited(
DelimSpan::from_single(token.span),
Delimiter::Invisible,
TokenStream::from_nonterminal_ast(&nt).flattened(),
TokenStream::from_nonterminal_ast(nt).flattened(),
),
_ => TokenTree::Token(token.clone(), spacing),
}
Expand Down Expand Up @@ -511,7 +511,7 @@ impl TokenStream {
fn try_glue_to_last(vec: &mut Vec<TokenTree>, tt: &TokenTree) -> bool {
if let Some(TokenTree::Token(last_tok, Spacing::Joint)) = vec.last()
&& let TokenTree::Token(tok, spacing) = tt
&& let Some(glued_tok) = last_tok.glue(&tok)
&& let Some(glued_tok) = last_tok.glue(tok)
{
// ...then overwrite the last token tree in `vec` with the
// glued token, and skip the first token tree from `stream`.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast/src/util/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {
} else {
&mut lines
};
if let Some(horizontal) = get_horizontal_trim(&lines, kind) {
if let Some(horizontal) = get_horizontal_trim(lines, kind) {
changes = true;
// remove a "[ \t]*\*" block from each line, if possible
for line in lines.iter_mut() {
Expand Down Expand Up @@ -147,7 +147,7 @@ fn all_whitespace(s: &str, col: CharPos) -> Option<usize> {

fn trim_whitespace_prefix(s: &str, col: CharPos) -> &str {
let len = s.len();
match all_whitespace(&s, col) {
match all_whitespace(s, col) {
Some(col) => {
if col < len {
&s[col..]
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_ast/src/util/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ impl LitKind {
// new symbol because the string in the LitKind is different to the
// string in the token.
let s = symbol.as_str();
let symbol = if s.contains(&['\\', '\r']) {
let symbol = if s.contains(['\\', '\r']) {
let mut buf = String::with_capacity(s.len());
let mut error = Ok(());
// Force-inlining here is aggressive but the closure is
// called on every char in the string, so it can be
// hot in programs with many long strings.
unescape_literal(
&s,
s,
Mode::Str,
&mut #[inline(always)]
|_, unescaped_char| match unescaped_char {
Expand All @@ -85,7 +85,7 @@ impl LitKind {
if s.contains('\r') {
let mut buf = String::with_capacity(s.len());
let mut error = Ok(());
unescape_literal(&s, Mode::RawStr, &mut |_, unescaped_char| {
unescape_literal(s, Mode::RawStr, &mut |_, unescaped_char| {
match unescaped_char {
Ok(c) => buf.push(c),
Err(err) => {
Expand All @@ -106,7 +106,7 @@ impl LitKind {
let s = symbol.as_str();
let mut buf = Vec::with_capacity(s.len());
let mut error = Ok(());
unescape_literal(&s, Mode::ByteStr, &mut |_, c| match c {
unescape_literal(s, Mode::ByteStr, &mut |_, c| match c {
Ok(c) => buf.push(byte_from_char(c)),
Err(err) => {
if err.is_fatal() {
Expand All @@ -122,7 +122,7 @@ impl LitKind {
let bytes = if s.contains('\r') {
let mut buf = Vec::with_capacity(s.len());
let mut error = Ok(());
unescape_literal(&s, Mode::RawByteStr, &mut |_, c| match c {
unescape_literal(s, Mode::RawByteStr, &mut |_, c| match c {
Ok(c) => buf.push(byte_from_char(c)),
Err(err) => {
if err.is_fatal() {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast/src/util/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
| ast::ExprKind::AssignOp(_, lhs, rhs)
| ast::ExprKind::Binary(_, lhs, rhs) => {
// X { y: 1 } + X { y: 2 }
contains_exterior_struct_lit(&lhs) || contains_exterior_struct_lit(&rhs)
contains_exterior_struct_lit(lhs) || contains_exterior_struct_lit(rhs)
}
ast::ExprKind::Await(x)
| ast::ExprKind::Unary(_, x)
Expand All @@ -393,12 +393,12 @@ pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
| ast::ExprKind::Field(x, _)
| ast::ExprKind::Index(x, _) => {
// &X { y: 1 }, X { y: 1 }.y
contains_exterior_struct_lit(&x)
contains_exterior_struct_lit(x)
}

ast::ExprKind::MethodCall(box ast::MethodCall { receiver, .. }) => {
// X { y: 1 }.bar(...)
contains_exterior_struct_lit(&receiver)
contains_exterior_struct_lit(receiver)
}

_ => false,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/util/unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn contains_text_flow_control_chars(s: &str) -> bool {
// U+2069 - E2 81 A9
let mut bytes = s.as_bytes();
loop {
match core::slice::memchr::memchr(0xE2, &bytes) {
match core::slice::memchr::memchr(0xE2, bytes) {
Some(idx) => {
// bytes are valid UTF-8 -> E2 must be followed by two bytes
let ch = &bytes[idx..idx + 3];
Expand Down
24 changes: 12 additions & 12 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
ast::MetaItemKind::List(ref items) => {
self.print_path(&item.path, false, 0);
self.popen();
self.commasep(Consistent, &items, |s, i| s.print_meta_list_item(i));
self.commasep(Consistent, items, |s, i| s.print_meta_list_item(i));
self.pclose();
}
}
Expand All @@ -532,7 +532,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool) {
match tt {
TokenTree::Token(token, _) => {
let token_str = self.token_to_string_ext(&token, convert_dollar_crate);
let token_str = self.token_to_string_ext(token, convert_dollar_crate);
self.word(token_str);
if let token::DocComment(..) = token.kind {
self.hardbreak()
Expand Down Expand Up @@ -994,7 +994,7 @@ impl<'a> State<'a> {
ast::AssocConstraintKind::Bound { bounds } => {
if !bounds.is_empty() {
self.word_nbsp(":");
self.print_type_bounds(&bounds);
self.print_type_bounds(bounds);
}
}
}
Expand Down Expand Up @@ -1031,7 +1031,7 @@ impl<'a> State<'a> {
}
ast::TyKind::Tup(ref elts) => {
self.popen();
self.commasep(Inconsistent, &elts, |s, ty| s.print_type(ty));
self.commasep(Inconsistent, elts, |s, ty| s.print_type(ty));
if elts.len() == 1 {
self.word(",");
}
Expand Down Expand Up @@ -1250,7 +1250,7 @@ impl<'a> State<'a> {

self.popen();
self.commasep(Consistent, &args, |s, arg| match arg {
AsmArg::Template(template) => s.print_string(&template, ast::StrStyle::Cooked),
AsmArg::Template(template) => s.print_string(template, ast::StrStyle::Cooked),
AsmArg::Operand(op) => {
let print_reg_or_class = |s: &mut Self, r: &InlineAsmRegOrRegClass| match r {
InlineAsmRegOrRegClass::Reg(r) => s.print_symbol(*r, ast::StrStyle::Cooked),
Expand Down Expand Up @@ -1420,11 +1420,11 @@ impl<'a> State<'a> {
self.print_path(path, true, 0);
}
self.popen();
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));
self.pclose();
}
PatKind::Or(ref pats) => {
self.strsep("|", true, Inconsistent, &pats, |s, p| s.print_pat(p));
self.strsep("|", true, Inconsistent, pats, |s, p| s.print_pat(p));
}
PatKind::Path(None, ref path) => {
self.print_path(path, true, 0);
Expand All @@ -1446,7 +1446,7 @@ impl<'a> State<'a> {
}
self.commasep_cmnt(
Consistent,
&fields,
fields,
|s, f| {
s.cbox(INDENT_UNIT);
if !f.is_shorthand {
Expand All @@ -1471,7 +1471,7 @@ impl<'a> State<'a> {
}
PatKind::Tuple(ref elts) => {
self.popen();
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));
if elts.len() == 1 {
self.word(",");
}
Expand All @@ -1494,7 +1494,7 @@ impl<'a> State<'a> {
self.print_pat(inner);
}
}
PatKind::Lit(ref e) => self.print_expr(&**e),
PatKind::Lit(ref e) => self.print_expr(e),
PatKind::Range(ref begin, ref end, Spanned { node: ref end_kind, .. }) => {
if let Some(e) = begin {
self.print_expr(e);
Expand All @@ -1510,7 +1510,7 @@ impl<'a> State<'a> {
}
PatKind::Slice(ref elts) => {
self.word("[");
self.commasep(Inconsistent, &elts, |s, p| s.print_pat(p));
self.commasep(Inconsistent, elts, |s, p| s.print_pat(p));
self.word("]");
}
PatKind::Rest => self.word(".."),
Expand Down Expand Up @@ -1596,7 +1596,7 @@ impl<'a> State<'a> {

self.word("<");

self.commasep(Inconsistent, &generic_params, |s, param| {
self.commasep(Inconsistent, generic_params, |s, param| {
s.print_outer_attributes_inline(&param.attrs);

match param.kind {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_ast_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ impl<'a> State<'a> {
self.print_expr_tup(exprs);
}
ast::ExprKind::Call(ref func, ref args) => {
self.print_expr_call(func, &args);
self.print_expr_call(func, args);
}
ast::ExprKind::MethodCall(box ast::MethodCall {
ref seg,
ref receiver,
ref args,
..
}) => {
self.print_expr_method_call(seg, &receiver, &args);
self.print_expr_method_call(seg, receiver, args);
}
ast::ExprKind::Binary(op, ref lhs, ref rhs) => {
self.print_expr_binary(op, lhs, rhs);
Expand Down Expand Up @@ -613,7 +613,7 @@ impl<'a> State<'a> {
match binder {
ast::ClosureBinder::NotPresent => {}
ast::ClosureBinder::For { generic_params, .. } => {
self.print_formal_generic_params(&generic_params)
self.print_formal_generic_params(generic_params)
}
}
}
Expand Down
35 changes: 19 additions & 16 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,30 +292,33 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
}

fn print_target_features(sess: &Session, tm: &llvm::TargetMachine) {
let mut target_features = llvm_target_features(tm);
let mut llvm_target_features = llvm_target_features(tm);
let mut known_llvm_target_features = FxHashSet::<&'static str>::default();
let mut rustc_target_features = supported_target_features(sess)
.iter()
.filter_map(|(feature, _gate)| {
for llvm_feature in to_llvm_features(sess, *feature) {
.map(|(feature, _gate)| {
let desc = if let Some(llvm_feature) = to_llvm_features(sess, *feature).first() {
// LLVM asserts that these are sorted. LLVM and Rust both use byte comparison for these strings.
match target_features.binary_search_by_key(&llvm_feature, |(f, _d)| f).ok().map(
|index| {
let (_f, desc) = target_features.remove(index);
(*feature, desc)
},
) {
Some(v) => return Some(v),
None => {}
match llvm_target_features.binary_search_by_key(&llvm_feature, |(f, _d)| f).ok() {
Some(index) => {
known_llvm_target_features.insert(llvm_feature);
llvm_target_features[index].1
}
None => "",
}
}
None
} else {
""
};
(*feature, desc)
})
.collect::<Vec<_>>();
rustc_target_features.extend_from_slice(&[(
"crt-static",
"Enables C Run-time Libraries to be statically linked",
)]);
let max_feature_len = target_features
llvm_target_features.retain(|(f, _d)| !known_llvm_target_features.contains(f));

let max_feature_len = llvm_target_features
.iter()
.chain(rustc_target_features.iter())
.map(|(feature, _desc)| feature.len())
Expand All @@ -327,10 +330,10 @@ fn print_target_features(sess: &Session, tm: &llvm::TargetMachine) {
println!(" {1:0$} - {2}.", max_feature_len, feature, desc);
}
println!("\nCode-generation features supported by LLVM for this target:");
for (feature, desc) in &target_features {
for (feature, desc) in &llvm_target_features {
println!(" {1:0$} - {2}.", max_feature_len, feature, desc);
}
if target_features.is_empty() {
if llvm_target_features.is_empty() {
println!(" Target features listing is not supported by this LLVM version.");
}
println!("\nUse +feature to enable a feature, or -feature to disable it.");
Expand Down
Loading