Skip to content

Rollup of 12 pull requests #137959

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

Merged
merged 110 commits into from
Mar 4, 2025
Merged
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
d1fb18e
Calculate drop glue and show it on hover
ChayimFriedman2 Jan 20, 2025
629fa76
feat: update insta inline snapshot when clicks 'Update Test' runnable
andylokandy Feb 21, 2025
2b6ea13
fix
andylokandy Feb 21, 2025
a0c69fd
Allow "package/feature" format feature flag
kazatsuyu Feb 22, 2025
4ab9329
Include private items in completions for local crates
Timmmm Feb 21, 2025
e2a7731
Downgrade to ubuntu-22.04 for aarch64-unknown-linux-gnu and arm-unkno…
lnicola Feb 24, 2025
5397431
Fix event_name check in workflows
lnicola Feb 24, 2025
dac3460
Merge pull request #19216 from lnicola/ubuntu-22.04
lnicola Feb 24, 2025
af83f2f
Merge pull request #19217 from lnicola/event-name
lnicola Feb 24, 2025
7bba76e
Disable incremental on release builds
Veykril Feb 24, 2025
d761f9b
Vendor always-assert
Veykril Feb 24, 2025
a4bd32c
Merge pull request #19218 from Veykril/push-vqsronpuvrnx
Veykril Feb 24, 2025
49116c6
Merge pull request #19197 from andylokandy/insta
Veykril Feb 24, 2025
6e2abbf
Merge pull request #19211 from Timmmm/user/timh/import_private
Veykril Feb 24, 2025
18c6f22
Merge pull request #19219 from Veykril/push-rvosplwpwqqt
Veykril Feb 24, 2025
67a99a3
Migrate some leftovers in `add_missing_match_arms`
ShoyuVanilla Feb 17, 2025
756f213
Migrate `apply_demorgan` to `SyntaxEditor`
ShoyuVanilla Feb 17, 2025
1c2225b
Add `take()` method to `SyntaxEditor`
ShoyuVanilla Feb 18, 2025
32e4049
Merge pull request #18987 from ChayimFriedman2/drop-glue
Veykril Feb 24, 2025
a9dbd49
Merge pull request #19171 from ShoyuVanilla/migrate-de-morgan-assist
Veykril Feb 24, 2025
1ff2593
minor: Add tabstop to impl body in `generate_trait_impl` assist
Giga-Bowser Feb 24, 2025
e6bb047
Merge pull request #19221 from Giga-Bowser/generate-trait-impl-tabstop
lnicola Feb 24, 2025
91ff420
doc: remove nit from setup.md
Shourya742 Feb 24, 2025
d5a85af
Support target features implications in target_feature 1.1
ChayimFriedman2 Feb 25, 2025
5c654dc
Disable typos checker for the target feature names
ChayimFriedman2 Feb 25, 2025
16402de
Merge pull request #19223 from ChayimFriedman2/implied-target-feature
Veykril Feb 25, 2025
f7adafc
internal: Improve reporting of intersecting changes
Giga-Bowser Jan 10, 2025
cac5153
internal: Migrate `remove_mut` assist to `SyntaxEditor`
Giga-Bowser Nov 30, 2024
8036e84
internal: Migrate `remove_parentheses` assist to `SyntaxEditor`
Giga-Bowser Dec 5, 2024
1d5f831
fix: Properly handle removals in `SyntaxEditor`
Giga-Bowser Dec 5, 2024
6e6e7e9
internal: Migrate `remove_unused_param` assist to `SyntaxEditor`
Giga-Bowser Dec 5, 2024
3b4e268
Merge pull request #19204 from kazatsuyu/allow-package-specific-feature
ChayimFriedman2 Feb 26, 2025
aa32933
Merge pull request #19225 from Giga-Bowser/remove-assists
Veykril Feb 26, 2025
fae88f2
Use cargo zigbuild for releases
lnicola Feb 26, 2025
444ce09
Merge pull request #19220 from Shourya742/2025-02-24-nit-setup-doc
lnicola Feb 26, 2025
faaba55
Allow rust-project.json to specify sysroot workspace
darichey Feb 4, 2025
5109c0b
Drop support for stitched sysroot
darichey Feb 6, 2025
dae664d
Cofigurate out ohos target to avoid compilation crashes
LuuuXXX Feb 27, 2025
230ce20
Merge pull request #19239 from LuuuXXX/add-support-for-ohos
lnicola Feb 27, 2025
e162475
Merge pull request #19096 from darichey/rust-project-sysroot
Veykril Feb 27, 2025
d4b92f4
Merge pull request #19230 from lnicola/zig
lnicola Feb 27, 2025
cabb08d
Fix sysroot crate-graph construction not mapping crate-ids for proc-m…
Veykril Feb 27, 2025
494192b
Merge pull request #19241 from Veykril/push-lqumoruvuyvo
Veykril Feb 27, 2025
8c16ded
enable doctest
BenjaminBrienen Feb 26, 2025
df903a5
fix doc tests
BenjaminBrienen Feb 26, 2025
0404156
ignore doc test that only fails on windows
BenjaminBrienen Feb 27, 2025
1b6c4b7
ignore another test that fails on windows
BenjaminBrienen Feb 27, 2025
239a686
Merge pull request #19237 from BenjaminBrienen/doc-tests
lnicola Feb 27, 2025
d6f5377
Update Node.js, vscode, and ts deps
BenjaminBrienen Feb 26, 2025
13eb834
Merge pull request #19194 from BenjaminBrienen/node
lnicola Feb 27, 2025
af0c8b7
Add anchor for intra-doc links to associated items
ncrothers Feb 27, 2025
7348844
Avoid suggesting redundant borrowing in completion results
Shourya742 Feb 26, 2025
2071cc2
add test
Shourya742 Feb 26, 2025
bd8b58d
Merge pull request #19246 from ncrothers/add-anchor-for-associated-items
Veykril Feb 28, 2025
637dbe5
Fix prefix adjustment hints unnecessarily introducing parens
Veykril Feb 28, 2025
fd1f2e3
Merge pull request #19249 from Veykril/push-noosrywrsuvn
Veykril Feb 28, 2025
ff7de58
Have inline_local_variable use precedence calculation for parentheses
Veykril Feb 28, 2025
e862daf
Merge pull request #19250 from Veykril/push-tmrnrlotwtmr
Veykril Feb 28, 2025
dfb2e35
Migrate `convert_bool_then` to `SyntaxEditor`
ShoyuVanilla Feb 28, 2025
08eeb8f
Cleanup highlighting macro-def handling
Veykril Mar 1, 2025
b0e3526
More precise macro modifiers for syntax highlighting
Veykril Mar 1, 2025
497f140
Cleanup string handling in syntax highlighting
Veykril Mar 1, 2025
28a5eeb
Fix `test_keyword_highlighting` test
Veykril Mar 1, 2025
629baf2
Remove syntax editing from parenthesis computation
Veykril Feb 28, 2025
a565f7f
Merge pull request #19257 from Veykril/push-myvwxskworsn
Veykril Mar 1, 2025
e6a0fc5
Merge pull request #19251 from Veykril/push-tkmpqtzxynxk
Veykril Mar 1, 2025
1b85bef
Add flip or-pattern assist
Veykril Mar 2, 2025
7d8e958
Merge pull request #19253 from ShoyuVanilla/migrate-convert-bool-then
Veykril Mar 2, 2025
768749f
Merge pull request #19259 from Veykril/push-skmvrmtorqso
Veykril Mar 2, 2025
ef028d7
do not build additional stage on compiler paths
onur-ozkan Mar 2, 2025
cfb475c
extend scope of build_all test
onur-ozkan Mar 2, 2025
cbe32a7
Remove layouting dead code for non-array SIMD types.
moulins Mar 1, 2025
6c1e5b4
Fix transparent diagnostics
lnicola Mar 2, 2025
5c124a3
Merge pull request #19264 from lnicola/theme-color
lnicola Mar 2, 2025
1c00d8f
Add `identifier` to pull diagnostic LSP capabilities
the-mikedavis Mar 2, 2025
a43a5f9
Merge pull request #19266 from the-mikedavis/lsp-pull-diagnostics-ide…
lnicola Mar 2, 2025
a59a8f9
Revert "Auto merge of #135335 - oli-obk:push-zxwssomxxtnq, r=saethlin"
compiler-errors Mar 2, 2025
5f575bc
Add a test
compiler-errors Mar 2, 2025
2a1e2e9
Replace `ast::TokenKind::BinOp{,Eq}` and remove `BinOpToken`.
nnethercote Dec 19, 2024
53167c0
Rename `ast::TokenKind::Not` as `ast::TokenKind::Bang`.
nnethercote Dec 20, 2024
83fa2fa
Fix pretty printing of unsafe binders
compiler-errors Mar 1, 2025
a05a8c8
Rename a bit
compiler-errors Mar 3, 2025
c6a7251
Merge pull request #19226 from Shourya742/2025-02-25-fix-completion-r…
ChayimFriedman2 Mar 3, 2025
969868b
Preparing for merge from rust-lang/rust
lnicola Mar 3, 2025
dd3a5f9
Merge from rust-lang/rust
lnicola Mar 3, 2025
24c480e
Bump rustc crates
lnicola Mar 3, 2025
015e81d
Merge pull request #19269 from lnicola/sync-from-rust
lnicola Mar 3, 2025
5afd122
Remove leading underscores from parameter names in `Sharded`
Zalathar Mar 2, 2025
9b78d48
After introducing the warning in 1.83, now also warn in deps
tdittr Jan 20, 2025
2bf5cc9
Bless UI tests
tdittr Jan 20, 2025
310f837
Change variadic-ffi-2 to use a platform independant ABI
tdittr Feb 18, 2025
6657aa9
Bless UI tests
tdittr Mar 3, 2025
7c62a47
fix order on shl impl
speedy-lex Mar 3, 2025
32c5449
Remove some unnecessary aliases from `rustc_data_structures::sync`
Zalathar Mar 3, 2025
cfa27fb
Tidy imports in `rustc_data_structures::sync`
Zalathar Mar 3, 2025
93b8279
Fix docker run-local docs
ehuss Mar 3, 2025
dfed028
Always allow rustdoc-json tests to contain long lines
Noratrieb Mar 3, 2025
f0de899
triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search
aDotInTheVoid Mar 3, 2025
1b4e66e
Rollup merge of #135767 - tdittr:fn_ptr_calling_conventions-in-deps, …
matthiaskrgr Mar 3, 2025
74e9ca6
Rollup merge of #137852 - moulins:layout-nonarray-simd-deadcode, r=wo…
matthiaskrgr Mar 3, 2025
0b9ff83
Rollup merge of #137863 - compiler-errors:unsafe-binder-render, r=oli…
matthiaskrgr Mar 3, 2025
a4b6181
Rollup merge of #137882 - onur-ozkan:remove-extra-compiler-stage, r=K…
matthiaskrgr Mar 3, 2025
70b9968
Rollup merge of #137894 - compiler-errors:no-scalar-pair-opt, r=oli-obk
matthiaskrgr Mar 3, 2025
decb0c9
Rollup merge of #137902 - nnethercote:ast-lexer-TokenKind, r=compiler…
matthiaskrgr Mar 3, 2025
566f34c
Rollup merge of #137921 - lnicola:sync-from-ra, r=lnicola
matthiaskrgr Mar 3, 2025
795af36
Rollup merge of #137922 - Zalathar:sharded, r=SparrowLii
matthiaskrgr Mar 3, 2025
afb88ed
Rollup merge of #137939 - speedy-lex:shl-fix, r=Noratrieb
matthiaskrgr Mar 3, 2025
61f3ec4
Rollup merge of #137946 - ehuss:ci-docker-readme, r=Kobzol
matthiaskrgr Mar 3, 2025
e2d40b2
Rollup merge of #137955 - Noratrieb:rustdoc-json-long-lines, r=aDotIn…
matthiaskrgr Mar 3, 2025
5d093cb
Rollup merge of #137958 - aDotInTheVoid:aDotInTheVoid-patch-2, r=jiey…
matthiaskrgr Mar 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
296 changes: 170 additions & 126 deletions compiler/rustc_ast/src/token.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
@@ -651,7 +651,7 @@ impl TokenStream {
if attr_style == AttrStyle::Inner {
vec![
TokenTree::token_joint(token::Pound, span),
TokenTree::token_joint_hidden(token::Not, span),
TokenTree::token_joint_hidden(token::Bang, span),
body,
]
} else {
42 changes: 21 additions & 21 deletions compiler/rustc_ast/src/util/parser.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_span::kw;

use crate::ast::{self, BinOpKind, RangeLimits};
use crate::token::{self, BinOpToken, Token};
use crate::token::{self, Token};

/// Associative operator.
#[derive(Copy, Clone, PartialEq, Debug)]
@@ -34,26 +34,26 @@ impl AssocOp {
use AssocOp::*;
match t.kind {
token::Eq => Some(Assign),
token::BinOp(BinOpToken::Plus) => Some(Binary(BinOpKind::Add)),
token::BinOp(BinOpToken::Minus) => Some(Binary(BinOpKind::Sub)),
token::BinOp(BinOpToken::Star) => Some(Binary(BinOpKind::Mul)),
token::BinOp(BinOpToken::Slash) => Some(Binary(BinOpKind::Div)),
token::BinOp(BinOpToken::Percent) => Some(Binary(BinOpKind::Rem)),
token::BinOp(BinOpToken::Caret) => Some(Binary(BinOpKind::BitXor)),
token::BinOp(BinOpToken::And) => Some(Binary(BinOpKind::BitAnd)),
token::BinOp(BinOpToken::Or) => Some(Binary(BinOpKind::BitOr)),
token::BinOp(BinOpToken::Shl) => Some(Binary(BinOpKind::Shl)),
token::BinOp(BinOpToken::Shr) => Some(Binary(BinOpKind::Shr)),
token::BinOpEq(BinOpToken::Plus) => Some(AssignOp(BinOpKind::Add)),
token::BinOpEq(BinOpToken::Minus) => Some(AssignOp(BinOpKind::Sub)),
token::BinOpEq(BinOpToken::Star) => Some(AssignOp(BinOpKind::Mul)),
token::BinOpEq(BinOpToken::Slash) => Some(AssignOp(BinOpKind::Div)),
token::BinOpEq(BinOpToken::Percent) => Some(AssignOp(BinOpKind::Rem)),
token::BinOpEq(BinOpToken::Caret) => Some(AssignOp(BinOpKind::BitXor)),
token::BinOpEq(BinOpToken::And) => Some(AssignOp(BinOpKind::BitAnd)),
token::BinOpEq(BinOpToken::Or) => Some(AssignOp(BinOpKind::BitOr)),
token::BinOpEq(BinOpToken::Shl) => Some(AssignOp(BinOpKind::Shl)),
token::BinOpEq(BinOpToken::Shr) => Some(AssignOp(BinOpKind::Shr)),
token::Plus => Some(Binary(BinOpKind::Add)),
token::Minus => Some(Binary(BinOpKind::Sub)),
token::Star => Some(Binary(BinOpKind::Mul)),
token::Slash => Some(Binary(BinOpKind::Div)),
token::Percent => Some(Binary(BinOpKind::Rem)),
token::Caret => Some(Binary(BinOpKind::BitXor)),
token::And => Some(Binary(BinOpKind::BitAnd)),
token::Or => Some(Binary(BinOpKind::BitOr)),
token::Shl => Some(Binary(BinOpKind::Shl)),
token::Shr => Some(Binary(BinOpKind::Shr)),
token::PlusEq => Some(AssignOp(BinOpKind::Add)),
token::MinusEq => Some(AssignOp(BinOpKind::Sub)),
token::StarEq => Some(AssignOp(BinOpKind::Mul)),
token::SlashEq => Some(AssignOp(BinOpKind::Div)),
token::PercentEq => Some(AssignOp(BinOpKind::Rem)),
token::CaretEq => Some(AssignOp(BinOpKind::BitXor)),
token::AndEq => Some(AssignOp(BinOpKind::BitAnd)),
token::OrEq => Some(AssignOp(BinOpKind::BitOr)),
token::ShlEq => Some(AssignOp(BinOpKind::Shl)),
token::ShrEq => Some(AssignOp(BinOpKind::Shr)),
token::Lt => Some(Binary(BinOpKind::Lt)),
token::Le => Some(Binary(BinOpKind::Le)),
token::Ge => Some(Binary(BinOpKind::Ge)),
45 changes: 23 additions & 22 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
@@ -11,9 +11,7 @@ use std::sync::Arc;

use rustc_ast::attr::AttrIdGenerator;
use rustc_ast::ptr::P;
use rustc_ast::token::{
self, BinOpToken, CommentKind, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind,
};
use rustc_ast::token::{self, CommentKind, Delimiter, IdentIsRaw, Nonterminal, Token, TokenKind};
use rustc_ast::tokenstream::{Spacing, TokenStream, TokenTree};
use rustc_ast::util::classify;
use rustc_ast::util::comments::{Comment, CommentStyle};
@@ -319,7 +317,7 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
(tt1, Tok(Token { kind: Comma | Semi | Dot, .. }, _)) if !is_punct(tt1) => false,

// IDENT + `!`: `println!()`, but `if !x { ... }` needs a space after the `if`
(Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Not, .. }, _))
(Tok(Token { kind: Ident(sym, is_raw), span }, _), Tok(Token { kind: Bang, .. }, _))
if !Ident::new(*sym, *span).is_reserved() || matches!(is_raw, IdentIsRaw::Yes) =>
{
false
@@ -344,21 +342,6 @@ fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
}
}

fn binop_to_string(op: BinOpToken) -> &'static str {
match op {
token::Plus => "+",
token::Minus => "-",
token::Star => "*",
token::Slash => "/",
token::Percent => "%",
token::Caret => "^",
token::And => "&",
token::Or => "|",
token::Shl => "<<",
token::Shr => ">>",
}
}

pub fn doc_comment_to_string(
comment_kind: CommentKind,
attr_style: ast::AttrStyle,
@@ -913,12 +896,30 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
token::Ne => "!=".into(),
token::Ge => ">=".into(),
token::Gt => ">".into(),
token::Not => "!".into(),
token::Bang => "!".into(),
token::Tilde => "~".into(),
token::OrOr => "||".into(),
token::AndAnd => "&&".into(),
token::BinOp(op) => binop_to_string(op).into(),
token::BinOpEq(op) => format!("{}=", binop_to_string(op)).into(),
token::Plus => "+".into(),
token::Minus => "-".into(),
token::Star => "*".into(),
token::Slash => "/".into(),
token::Percent => "%".into(),
token::Caret => "^".into(),
token::And => "&".into(),
token::Or => "|".into(),
token::Shl => "<<".into(),
token::Shr => ">>".into(),
token::PlusEq => "+=".into(),
token::MinusEq => "-=".into(),
token::StarEq => "*=".into(),
token::SlashEq => "/=".into(),
token::PercentEq => "%=".into(),
token::CaretEq => "^=".into(),
token::AndEq => "&=".into(),
token::OrEq => "|=".into(),
token::ShlEq => "<<=".into(),
token::ShrEq => ">>=".into(),

/* Structural symbols */
token::At => "@".into(),
5 changes: 0 additions & 5 deletions compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
@@ -64,11 +64,6 @@ impl<'gcc, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
if type_is_pointer(typ) { self.context.new_null(typ) } else { self.const_int(typ, 0) }
}

fn is_undef(&self, _val: RValue<'gcc>) -> bool {
// FIXME: actually check for undef
false
}

fn const_undef(&self, typ: Type<'gcc>) -> RValue<'gcc> {
let local = self.current_func.borrow().expect("func").new_local(None, typ, "undefined");
if typ.is_struct().is_some() {
4 changes: 0 additions & 4 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
@@ -127,10 +127,6 @@ impl<'ll, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
unsafe { llvm::LLVMGetUndef(t) }
}

fn is_undef(&self, v: &'ll Value) -> bool {
unsafe { llvm::LLVMIsUndef(v) == True }
}

fn const_poison(&self, t: &'ll Type) -> &'ll Value {
unsafe { llvm::LLVMGetPoison(t) }
}
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
@@ -1046,7 +1046,6 @@ unsafe extern "C" {
pub(crate) fn LLVMMetadataTypeInContext(C: &Context) -> &Type;

// Operations on all values
pub(crate) fn LLVMIsUndef(Val: &Value) -> Bool;
pub(crate) fn LLVMTypeOf(Val: &Value) -> &Type;
pub(crate) fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
pub(crate) fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
59 changes: 22 additions & 37 deletions compiler/rustc_codegen_ssa/src/mir/operand.rs
Original file line number Diff line number Diff line change
@@ -203,30 +203,14 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
let alloc_align = alloc.inner().align;
assert!(alloc_align >= layout.align.abi);

// Returns `None` when the value is partially undefined or any byte of it has provenance.
// Otherwise returns the value or (if the entire value is undef) returns an undef.
let read_scalar = |start, size, s: abi::Scalar, ty| {
let range = alloc_range(start, size);
match alloc.0.read_scalar(
bx,
range,
alloc_range(start, size),
/*read_provenance*/ matches!(s.primitive(), abi::Primitive::Pointer(_)),
) {
Ok(val) => Some(bx.scalar_to_backend(val, s, ty)),
Err(_) => {
// We may have failed due to partial provenance or unexpected provenance,
// continue down the normal code path if so.
if alloc.0.provenance().range_empty(range, &bx.tcx())
// Since `read_scalar` failed, but there were no relocations involved, the
// bytes must be partially or fully uninitialized. Thus we can now unwrap the
// information about the range of uninit bytes and check if it's the full range.
&& alloc.0.init_mask().is_range_initialized(range).unwrap_err() == range
{
Some(bx.const_undef(ty))
} else {
None
}
}
Ok(val) => bx.scalar_to_backend(val, s, ty),
Err(_) => bx.const_poison(ty),
}
};

@@ -237,14 +221,16 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
// check that walks over the type of `mplace` to make sure it is truly correct to treat this
// like a `Scalar` (or `ScalarPair`).
match layout.backend_repr {
BackendRepr::Scalar(s) => {
BackendRepr::Scalar(s @ abi::Scalar::Initialized { .. }) => {
let size = s.size(bx);
assert_eq!(size, layout.size, "abi::Scalar size does not match layout size");
if let Some(val) = read_scalar(offset, size, s, bx.immediate_backend_type(layout)) {
return OperandRef { val: OperandValue::Immediate(val), layout };
}
let val = read_scalar(offset, size, s, bx.immediate_backend_type(layout));
OperandRef { val: OperandValue::Immediate(val), layout }
}
BackendRepr::ScalarPair(a, b) => {
BackendRepr::ScalarPair(
a @ abi::Scalar::Initialized { .. },
b @ abi::Scalar::Initialized { .. },
) => {
let (a_size, b_size) = (a.size(bx), b.size(bx));
let b_offset = (offset + a_size).align_to(b.align(bx).abi);
assert!(b_offset.bytes() > 0);
@@ -260,21 +246,20 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
b,
bx.scalar_pair_element_backend_type(layout, 1, true),
);
if let (Some(a_val), Some(b_val)) = (a_val, b_val) {
return OperandRef { val: OperandValue::Pair(a_val, b_val), layout };
}
OperandRef { val: OperandValue::Pair(a_val, b_val), layout }
}
_ if layout.is_zst() => OperandRef::zero_sized(layout),
_ => {
// Neither a scalar nor scalar pair. Load from a place
// FIXME: should we cache `const_data_from_alloc` to avoid repeating this for the
// same `ConstAllocation`?
let init = bx.const_data_from_alloc(alloc);
let base_addr = bx.static_addr_of(init, alloc_align, None);

let llval = bx.const_ptr_byte_offset(base_addr, offset);
bx.load_operand(PlaceRef::new_sized(llval, layout))
}
_ if layout.is_zst() => return OperandRef::zero_sized(layout),
_ => {}
}
// Neither a scalar nor scalar pair. Load from a place
// FIXME: should we cache `const_data_from_alloc` to avoid repeating this for the
// same `ConstAllocation`?
let init = bx.const_data_from_alloc(alloc);
let base_addr = bx.static_addr_of(init, alloc_align, None);

let llval = bx.const_ptr_byte_offset(base_addr, offset);
bx.load_operand(PlaceRef::new_sized(llval, layout))
}

/// Asserts that this operand refers to a scalar and returns
26 changes: 2 additions & 24 deletions compiler/rustc_codegen_ssa/src/mir/rvalue.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_middle::{bug, mir, span_bug};
use rustc_session::config::OptLevel;
use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument, trace};
use tracing::{debug, instrument};

use super::operand::{OperandRef, OperandValue};
use super::place::PlaceRef;
@@ -93,8 +93,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
return;
}

// If `v` is an integer constant whose value is just a single byte repeated N times,
// emit a `memset` filling the entire `dest` with that byte.
let try_init_all_same = |bx: &mut Bx, v| {
let start = dest.val.llval;
let size = bx.const_usize(dest.layout.size.bytes());
@@ -119,33 +117,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
false
};

trace!(?cg_elem.val);
match cg_elem.val {
OperandValue::Immediate(v) => {
if try_init_all_same(bx, v) {
return;
}
}
OperandValue::Pair(a, b) => {
let a_is_undef = bx.cx().is_undef(a);
match (a_is_undef, bx.cx().is_undef(b)) {
// Can happen for uninit unions
(true, true) => {
// FIXME: can we produce better output here?
}
(false, true) | (true, false) => {
let val = if a_is_undef { b } else { a };
if try_init_all_same(bx, val) {
return;
}
}
(false, false) => {
// FIXME: if both are the same value, use try_init_all_same
}
}
}
OperandValue::ZeroSized => unreachable!("checked above"),
OperandValue::Ref(..) => {}
_ => (),
}

let count = self
1 change: 0 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/consts.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ pub trait ConstCodegenMethods<'tcx>: BackendTypes {
/// Generate an uninitialized value (matching uninitialized memory in MIR).
/// Whether memory is initialized or not is tracked byte-for-byte.
fn const_undef(&self, t: Self::Type) -> Self::Value;
fn is_undef(&self, v: Self::Value) -> bool;
/// Generate a fake value. Poison always affects the entire value, even if just a single byte is
/// poison. This can only be used in codepaths that are already UB, i.e., UB-free Rust code
/// (including code that e.g. copies uninit memory with `MaybeUninit`) can never encounter a
16 changes: 8 additions & 8 deletions compiler/rustc_data_structures/src/sharded.rs
Original file line number Diff line number Diff line change
@@ -43,10 +43,10 @@ impl<T> Sharded<T> {

/// The shard is selected by hashing `val` with `FxHasher`.
#[inline]
pub fn get_shard_by_value<K: Hash + ?Sized>(&self, _val: &K) -> &Lock<T> {
pub fn get_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> &Lock<T> {
match self {
Self::Single(single) => single,
Self::Shards(..) => self.get_shard_by_hash(make_hash(_val)),
Self::Shards(..) => self.get_shard_by_hash(make_hash(val)),
}
}

@@ -56,20 +56,20 @@ impl<T> Sharded<T> {
}

#[inline]
pub fn get_shard_by_index(&self, _i: usize) -> &Lock<T> {
pub fn get_shard_by_index(&self, i: usize) -> &Lock<T> {
match self {
Self::Single(single) => single,
Self::Shards(shards) => {
// SAFETY: The index gets ANDed with the shard mask, ensuring it is always inbounds.
unsafe { &shards.get_unchecked(_i & (SHARDS - 1)).0 }
unsafe { &shards.get_unchecked(i & (SHARDS - 1)).0 }
}
}
}

/// The shard is selected by hashing `val` with `FxHasher`.
#[inline]
#[track_caller]
pub fn lock_shard_by_value<K: Hash + ?Sized>(&self, _val: &K) -> LockGuard<'_, T> {
pub fn lock_shard_by_value<K: Hash + ?Sized>(&self, val: &K) -> LockGuard<'_, T> {
match self {
Self::Single(single) => {
// Synchronization is disabled so use the `lock_assume_no_sync` method optimized
@@ -79,7 +79,7 @@ impl<T> Sharded<T> {
// `might_be_dyn_thread_safe` was also false.
unsafe { single.lock_assume(Mode::NoSync) }
}
Self::Shards(..) => self.lock_shard_by_hash(make_hash(_val)),
Self::Shards(..) => self.lock_shard_by_hash(make_hash(val)),
}
}

@@ -91,7 +91,7 @@ impl<T> Sharded<T> {

#[inline]
#[track_caller]
pub fn lock_shard_by_index(&self, _i: usize) -> LockGuard<'_, T> {
pub fn lock_shard_by_index(&self, i: usize) -> LockGuard<'_, T> {
match self {
Self::Single(single) => {
// Synchronization is disabled so use the `lock_assume_no_sync` method optimized
@@ -109,7 +109,7 @@ impl<T> Sharded<T> {
// always inbounds.
// SAFETY (lock_assume_sync): We know `is_dyn_thread_safe` was true when creating
// the lock thus `might_be_dyn_thread_safe` was also true.
unsafe { shards.get_unchecked(_i & (SHARDS - 1)).0.lock_assume(Mode::Sync) }
unsafe { shards.get_unchecked(i & (SHARDS - 1)).0.lock_assume(Mode::Sync) }
}
}
}
Loading