Skip to content

Commit 8806d6d

Browse files
committed
Auto merge of #152399 - matthiaskrgr:rollup-uDIDnAN, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - rust-lang/rust#152388 (`rust-analyzer` subtree update) - rust-lang/rust#151613 (Align `ArrayWindows` trait impls with `Windows`) - rust-lang/rust#152134 (Set crt_static_allow_dylibs to true for Emscripten target) - rust-lang/rust#152166 (cleanup some more things in `proc_macro::bridge`) - rust-lang/rust#152236 (compiletest: `-Zunstable-options` for json targets) - rust-lang/rust#152287 (Fix an ICE in the vtable iteration for a trait reference in const eval when a supertrait not implemented) - rust-lang/rust#142957 (std: introduce path normalize methods at top of `std::path`) - rust-lang/rust#145504 (Add some conversion trait impls) - rust-lang/rust#152131 (Port rustc_no_implicit_bounds attribute to parser.) - rust-lang/rust#152315 (fix: rhs_span to rhs_span_new) - rust-lang/rust#152327 (Check stalled coroutine obligations eagerly) - rust-lang/rust#152377 (Rename the query system's `JobOwner` to `ActiveJobGuard`, and include `key_hash`)
2 parents 4b9e642 + 6f54d41 commit 8806d6d

69 files changed

Lines changed: 1237 additions & 579 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ rayon = "1.10.0"
135135
rowan = "=0.15.17"
136136
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
137137
# on impls without it
138-
salsa = { version = "0.25.2", default-features = false, features = [
138+
salsa = { version = "0.26", default-features = false, features = [
139139
"rayon",
140140
"salsa_unstable",
141141
"macros",
142142
"inventory",
143143
] }
144-
salsa-macros = "0.25.2"
144+
salsa-macros = "0.26"
145145
semver = "1.0.26"
146146
serde = { version = "1.0.219" }
147147
serde_derive = { version = "1.0.219" }
@@ -192,8 +192,6 @@ unused_lifetimes = "warn"
192192
unreachable_pub = "warn"
193193

194194
[workspace.lints.clippy]
195-
# FIXME Remove the tidy test once the lint table is stable
196-
197195
## lint groups
198196
complexity = { level = "warn", priority = -1 }
199197
correctness = { level = "deny", priority = -1 }

bench_data/glorious_old_parser

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ impl<'a> Parser<'a> {
724724
// {foo(bar {}}
725725
// - ^
726726
// | |
727-
// | help: `)` may belong here (FIXME: #58270)
727+
// | help: `)` may belong here
728728
// |
729729
// unclosed delimiter
730730
if let Some(sp) = unmatched.unclosed_span {
@@ -3217,7 +3217,6 @@ impl<'a> Parser<'a> {
32173217

32183218
}
32193219
_ => {
3220-
// FIXME Could factor this out into non_fatal_unexpected or something.
32213220
let actual = self.this_token_to_string();
32223221
self.span_err(self.span, &format!("unexpected token: `{}`", actual));
32233222
}
@@ -5250,7 +5249,6 @@ impl<'a> Parser<'a> {
52505249
}
52515250
}
52525251
} else {
5253-
// FIXME: Bad copy of attrs
52545252
let old_directory_ownership =
52555253
mem::replace(&mut self.directory.ownership, DirectoryOwnership::UnownedViaBlock);
52565254
let item = self.parse_item_(attrs.clone(), false, true)?;
@@ -5953,23 +5951,14 @@ impl<'a> Parser<'a> {
59535951
});
59545952
assoc_ty_bindings.push(span);
59555953
} else if self.check_const_arg() {
5956-
// FIXME(const_generics): to distinguish between idents for types and consts,
5957-
// we should introduce a GenericArg::Ident in the AST and distinguish when
5958-
// lowering to the HIR. For now, idents for const args are not permitted.
5959-
59605954
// Parse const argument.
59615955
let expr = if let token::OpenDelim(token::Brace) = self.token {
59625956
self.parse_block_expr(None, self.span, BlockCheckMode::Default, ThinVec::new())?
59635957
} else if self.token.is_ident() {
5964-
// FIXME(const_generics): to distinguish between idents for types and consts,
5965-
// we should introduce a GenericArg::Ident in the AST and distinguish when
5966-
// lowering to the HIR. For now, idents for const args are not permitted.
59675958
return Err(
59685959
self.fatal("identifiers may currently not be used for const generics")
59695960
);
59705961
} else {
5971-
// FIXME(const_generics): this currently conflicts with emplacement syntax
5972-
// with negative integer literals.
59735962
self.parse_literal_maybe_minus()?
59745963
};
59755964
let value = AnonConst {
@@ -5991,9 +5980,6 @@ impl<'a> Parser<'a> {
59915980
}
59925981
}
59935982

5994-
// FIXME: we would like to report this in ast_validation instead, but we currently do not
5995-
// preserve ordering of generic parameters with respect to associated type binding, so we
5996-
// lose that information after parsing.
59975983
if misplaced_assoc_ty_bindings.len() > 0 {
59985984
let mut err = self.struct_span_err(
59995985
args_lo.to(self.prev_span),
@@ -6079,8 +6065,6 @@ impl<'a> Parser<'a> {
60796065
bounds,
60806066
}
60816067
));
6082-
// FIXME: Decide what should be used here, `=` or `==`.
6083-
// FIXME: We are just dropping the binders in lifetime_defs on the floor here.
60846068
} else if self.eat(&token::Eq) || self.eat(&token::EqEq) {
60856069
let rhs_ty = self.parse_ty()?;
60866070
where_clause.predicates.push(ast::WherePredicate::EqPredicate(

crates/base-db/src/editioned_file_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const _: () = {
6060
}
6161
}
6262

63-
impl zalsa_struct_::HashEqLike<WithoutCrate> for EditionedFileIdData {
63+
impl zalsa_::HashEqLike<WithoutCrate> for EditionedFileIdData {
6464
#[inline]
6565
fn hash<H: Hasher>(&self, state: &mut H) {
6666
Hash::hash(self, state);

crates/edition/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ impl Edition {
1616
pub const DEFAULT: Edition = Edition::Edition2015;
1717
pub const LATEST: Edition = Edition::Edition2024;
1818
pub const CURRENT: Edition = Edition::Edition2024;
19-
/// The current latest stable edition, note this is usually not the right choice in code.
20-
pub const CURRENT_FIXME: Edition = Edition::Edition2024;
2119

2220
pub fn from_u32(u32: u32) -> Edition {
2321
match u32 {

crates/hir-def/src/expr_store/lower.rs

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub struct ExprCollector<'db> {
426426
/// and we need to find the current definition. So we track the number of definitions we saw.
427427
current_block_legacy_macro_defs_count: FxHashMap<Name, usize>,
428428

429-
current_try_block_label: Option<LabelId>,
429+
current_try_block: Option<TryBlock>,
430430

431431
label_ribs: Vec<LabelRib>,
432432
unowned_bindings: Vec<BindingId>,
@@ -472,6 +472,13 @@ enum Awaitable {
472472
No(&'static str),
473473
}
474474

475+
enum TryBlock {
476+
// `try { ... }`
477+
Homogeneous { label: LabelId },
478+
// `try bikeshed Ty { ... }`
479+
Heterogeneous { label: LabelId },
480+
}
481+
475482
#[derive(Debug, Default)]
476483
struct BindingList {
477484
map: FxHashMap<(Name, HygieneId), BindingId>,
@@ -532,7 +539,7 @@ impl<'db> ExprCollector<'db> {
532539
lang_items: OnceCell::new(),
533540
store: ExpressionStoreBuilder::default(),
534541
expander,
535-
current_try_block_label: None,
542+
current_try_block: None,
536543
is_lowering_coroutine: false,
537544
label_ribs: Vec::new(),
538545
unowned_bindings: Vec::new(),
@@ -1069,7 +1076,9 @@ impl<'db> ExprCollector<'db> {
10691076
self.alloc_expr(Expr::Let { pat, expr }, syntax_ptr)
10701077
}
10711078
ast::Expr::BlockExpr(e) => match e.modifier() {
1072-
Some(ast::BlockModifier::Try(_)) => self.desugar_try_block(e),
1079+
Some(ast::BlockModifier::Try { try_token: _, bikeshed_token: _, result_type }) => {
1080+
self.desugar_try_block(e, result_type)
1081+
}
10731082
Some(ast::BlockModifier::Unsafe(_)) => {
10741083
self.collect_block_(e, |id, statements, tail| Expr::Unsafe {
10751084
id,
@@ -1344,7 +1353,7 @@ impl<'db> ExprCollector<'db> {
13441353
.map(|it| this.lower_type_ref_disallow_impl_trait(it));
13451354

13461355
let prev_is_lowering_coroutine = mem::take(&mut this.is_lowering_coroutine);
1347-
let prev_try_block_label = this.current_try_block_label.take();
1356+
let prev_try_block = this.current_try_block.take();
13481357

13491358
let awaitable = if e.async_token().is_some() {
13501359
Awaitable::Yes
@@ -1369,7 +1378,7 @@ impl<'db> ExprCollector<'db> {
13691378
let capture_by =
13701379
if e.move_token().is_some() { CaptureBy::Value } else { CaptureBy::Ref };
13711380
this.is_lowering_coroutine = prev_is_lowering_coroutine;
1372-
this.current_try_block_label = prev_try_block_label;
1381+
this.current_try_block = prev_try_block;
13731382
this.alloc_expr(
13741383
Expr::Closure {
13751384
args: args.into(),
@@ -1686,11 +1695,15 @@ impl<'db> ExprCollector<'db> {
16861695
/// Desugar `try { <stmts>; <expr> }` into `'<new_label>: { <stmts>; ::std::ops::Try::from_output(<expr>) }`,
16871696
/// `try { <stmts>; }` into `'<new_label>: { <stmts>; ::std::ops::Try::from_output(()) }`
16881697
/// and save the `<new_label>` to use it as a break target for desugaring of the `?` operator.
1689-
fn desugar_try_block(&mut self, e: BlockExpr) -> ExprId {
1698+
fn desugar_try_block(&mut self, e: BlockExpr, result_type: Option<ast::Type>) -> ExprId {
16901699
let try_from_output = self.lang_path(self.lang_items().TryTraitFromOutput);
16911700
let label = self.generate_new_name();
16921701
let label = self.alloc_label_desugared(Label { name: label }, AstPtr::new(&e).wrap_right());
1693-
let old_label = self.current_try_block_label.replace(label);
1702+
let try_block_info = match result_type {
1703+
Some(_) => TryBlock::Heterogeneous { label },
1704+
None => TryBlock::Homogeneous { label },
1705+
};
1706+
let old_try_block = self.current_try_block.replace(try_block_info);
16941707

16951708
let ptr = AstPtr::new(&e).upcast();
16961709
let (btail, expr_id) = self.with_labeled_rib(label, HygieneId::ROOT, |this| {
@@ -1720,8 +1733,38 @@ impl<'db> ExprCollector<'db> {
17201733
unreachable!("block was lowered to non-block");
17211734
};
17221735
*tail = Some(next_tail);
1723-
self.current_try_block_label = old_label;
1724-
expr_id
1736+
self.current_try_block = old_try_block;
1737+
match result_type {
1738+
Some(ty) => {
1739+
// `{ let <name>: <ty> = <expr>; <name> }`
1740+
let name = self.generate_new_name();
1741+
let type_ref = self.lower_type_ref_disallow_impl_trait(ty);
1742+
let binding = self.alloc_binding(
1743+
name.clone(),
1744+
BindingAnnotation::Unannotated,
1745+
HygieneId::ROOT,
1746+
);
1747+
let pat = self.alloc_pat_desugared(Pat::Bind { id: binding, subpat: None });
1748+
self.add_definition_to_binding(binding, pat);
1749+
let tail_expr =
1750+
self.alloc_expr_desugared_with_ptr(Expr::Path(Path::from(name)), ptr);
1751+
self.alloc_expr_desugared_with_ptr(
1752+
Expr::Block {
1753+
id: None,
1754+
statements: Box::new([Statement::Let {
1755+
pat,
1756+
type_ref: Some(type_ref),
1757+
initializer: Some(expr_id),
1758+
else_branch: None,
1759+
}]),
1760+
tail: Some(tail_expr),
1761+
label: None,
1762+
},
1763+
ptr,
1764+
)
1765+
}
1766+
None => expr_id,
1767+
}
17251768
}
17261769

17271770
/// Desugar `ast::WhileExpr` from: `[opt_ident]: while <cond> <body>` into:
@@ -1863,6 +1906,8 @@ impl<'db> ExprCollector<'db> {
18631906
/// ControlFlow::Continue(val) => val,
18641907
/// ControlFlow::Break(residual) =>
18651908
/// // If there is an enclosing `try {...}`:
1909+
/// break 'catch_target Residual::into_try_type(residual),
1910+
/// // If there is an enclosing `try bikeshed Ty {...}`:
18661911
/// break 'catch_target Try::from_residual(residual),
18671912
/// // Otherwise:
18681913
/// return Try::from_residual(residual),
@@ -1873,7 +1918,6 @@ impl<'db> ExprCollector<'db> {
18731918
let try_branch = self.lang_path(lang_items.TryTraitBranch);
18741919
let cf_continue = self.lang_path(lang_items.ControlFlowContinue);
18751920
let cf_break = self.lang_path(lang_items.ControlFlowBreak);
1876-
let try_from_residual = self.lang_path(lang_items.TryTraitFromResidual);
18771921
let operand = self.collect_expr_opt(e.expr());
18781922
let try_branch = self.alloc_expr(try_branch.map_or(Expr::Missing, Expr::Path), syntax_ptr);
18791923
let expr = self
@@ -1910,13 +1954,23 @@ impl<'db> ExprCollector<'db> {
19101954
guard: None,
19111955
expr: {
19121956
let it = self.alloc_expr(Expr::Path(Path::from(break_name)), syntax_ptr);
1913-
let callee = self
1914-
.alloc_expr(try_from_residual.map_or(Expr::Missing, Expr::Path), syntax_ptr);
1957+
let convert_fn = match self.current_try_block {
1958+
Some(TryBlock::Homogeneous { .. }) => {
1959+
self.lang_path(lang_items.ResidualIntoTryType)
1960+
}
1961+
Some(TryBlock::Heterogeneous { .. }) | None => {
1962+
self.lang_path(lang_items.TryTraitFromResidual)
1963+
}
1964+
};
1965+
let callee =
1966+
self.alloc_expr(convert_fn.map_or(Expr::Missing, Expr::Path), syntax_ptr);
19151967
let result =
19161968
self.alloc_expr(Expr::Call { callee, args: Box::new([it]) }, syntax_ptr);
19171969
self.alloc_expr(
1918-
match self.current_try_block_label {
1919-
Some(label) => Expr::Break { expr: Some(result), label: Some(label) },
1970+
match self.current_try_block {
1971+
Some(
1972+
TryBlock::Heterogeneous { label } | TryBlock::Homogeneous { label },
1973+
) => Expr::Break { expr: Some(result), label: Some(label) },
19201974
None => Expr::Return { expr: Some(result) },
19211975
},
19221976
syntax_ptr,

crates/hir-def/src/item_scope.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,24 @@ impl ItemScope {
893893
self.macros.get_mut(name).expect("tried to update visibility of non-existent macro");
894894
res.vis = vis;
895895
}
896+
897+
pub(crate) fn update_def_types(&mut self, name: &Name, def: ModuleDefId, vis: Visibility) {
898+
let res = self.types.get_mut(name).expect("tried to update def of non-existent type");
899+
res.def = def;
900+
res.vis = vis;
901+
}
902+
903+
pub(crate) fn update_def_values(&mut self, name: &Name, def: ModuleDefId, vis: Visibility) {
904+
let res = self.values.get_mut(name).expect("tried to update def of non-existent value");
905+
res.def = def;
906+
res.vis = vis;
907+
}
908+
909+
pub(crate) fn update_def_macros(&mut self, name: &Name, def: MacroId, vis: Visibility) {
910+
let res = self.macros.get_mut(name).expect("tried to update def of non-existent macro");
911+
res.def = def;
912+
res.vis = vis;
913+
}
896914
}
897915

898916
impl PerNs {

crates/hir-def/src/lang_item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ language_item_table! { LangItems =>
456456
TryTraitFromOutput, sym::from_output, FunctionId;
457457
TryTraitBranch, sym::branch, FunctionId;
458458
TryTraitFromYeet, sym::from_yeet, FunctionId;
459+
ResidualIntoTryType, sym::into_try_type, FunctionId;
459460

460461
PointerLike, sym::pointer_like, TraitId;
461462

0 commit comments

Comments
 (0)