Skip to content

Try bumping our nightly version through the power of slop-coding#1614

Draft
randomPoison wants to merge 26 commits intomasterfrom
legare/codex-bump-nightly-experiment
Draft

Try bumping our nightly version through the power of slop-coding#1614
randomPoison wants to merge 26 commits intomasterfrom
legare/codex-bump-nightly-experiment

Conversation

@randomPoison
Copy link
Contributor

Copilot choked and died on this, but Codex seems to have succeeded. I let it spin for like an hour and it got code compiling and tests running, so let's let CI run and see if anything is broken that I didn't catch locally.

ConstBlock(anon_const),
Call(#[prec=POSTFIX] #[prec_special=Callee] func, #[mac_table_seq] args),
MethodCall(path_seg, #[prec_first=POSTFIX] #[mac_table_seq] args, span),
MethodCall(path_seg, #[prec=POSTFIX] receiver, #[mac_table_seq] args, span),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is our internal attribute, I wonder why it decided this change was needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary because the method call receiver was pulled out of the args list into its own field. The old prec_first attribute was specifically there to handle this case in the method call syntax, where we needed to give the first element of the args list different precedence. Now that the receiver is its own field, the prec attribute is the one to use.

Also, prec_first was only used in this one place, so we can probably remove it entirely after rolling the toolchain (unless you think we should keep it around in case that case comes up again in a future toolchain).

attr.style = style;
self.attrs.push(attr);
self.attrs.push(Attribute {
id: AttrId::from_u32(0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a constant for this, DUMMY_NODE_ID I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DUMMY_NODE_ID is a NodeId, this as an AttrId. Other code within this file is doing AttrId::from_u32(0), hence why it did the same here.

match self.kind {
// FIXME: can this conflict with regular Err literals???
LitKind::Err(ref sym) => Some(*sym),
LitKind::Err => Some(self.token_lit.symbol),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is now irrelevant, though what we're doing here is a little weird so it's a bit hard to tell. This functionality is used in the matcher syntax, so we can do matches like $x:Lit. This ends up getting parsed in the AST as a LitKind::Err, since it's not a valid literal, and we then extract the $x part of the symbol from the error. This is a bit weird because we're overloading LitKind::Err for a case that's not actually an error, but it seems to work for our purposes.

We didn't have any tests around matching literals, so I've added a couple snapshot tests to cover that, along with adding support for substituting the matched literal into the rewritten code, which didn't previously work. I think we can remove the FIXME comment given that we can now be somewhat confident that it works as intended.

config.opts.incremental = None;

run_in_thread_pool_with_globals(Edition::Edition2021, 1, move || {
rustc_span::create_session_globals_then(Edition::Edition2021, move || {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems extremely questionably, create_session_globals_then was around in the old nightly, and the other function did a lot more than just call it. We'll need to check what happened upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_in_thread_pool_with_globals was made private (well, pub(crate)) so we can't call it anymore. create_session_globals is used internally in run_in_thread_pool_with_globals, so it makes sense that that's the fix here. It doesn't seem like we need to thread pool to run the refactorer here, so maybe create_session_globals does what we need? At least it doesn't seem to be interfering with our ability to run the refactorer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, we were specifically running it with only 1 thread before, so I think we can do without the thread pool.

// collide with `DUMMY_SP` (which is `0 .. 0`).
source_map.new_source_file(FileName::Custom("<dummy>".to_string()), " ".to_string());

let codegen_backend = get_codegen_backend(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really weird that it decided to delete a bunch of code here, we need to check upstream.

@Rua
Copy link
Contributor

Rua commented Mar 3, 2026

Why was that particular nightly version chosen and not, say, a much newer one?

Copy link
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was that particular nightly version chosen and not, say, a much newer one?

We were mostly just testing out codex on this. We decided to first start with a smaller jump so that it could handle it better. We may try a longer jump next, but there's a larger risk things go wrong, and in case we introduce some regression, it'll be harder to debug/rollback, and a much larger set of changes will be much more difficult to review as well.

@randomPoison randomPoison force-pushed the legare/codex-bump-nightly-experiment branch from 6efc208 to 017cb29 Compare March 10, 2026 22:16
PatKind::Ident(BindingMode::ByValue(Mutability::Not), ref i, None) => {
i.pattern_symbol()
}
PatKind::Ident(BindingAnnotation(ByRef::No, _), ref i, None) => i.pattern_symbol(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh weird, this one actually fixed a bug in the rewriter where we weren't handling mut patterns correctly. I added tests to exercise the relevant code paths and confirmed that the new behavior is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants