Skip to content
/ rust Public
forked from rust-lang/rust

Commit 6276e5a

Browse files
committed
Auto merge of rust-lang#3023 - RalfJung:gamma, r=RalfJung
add gamma function shims needs a rustup to fetch the new declarations in std
2 parents d4fbaa6 + 9281ddc commit 6276e5a

File tree

439 files changed

+4240
-3024
lines changed

Some content is hidden

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

439 files changed

+4240
-3024
lines changed

Diff for: .github/ISSUE_TEMPLATE/tracking_issue.md

+3
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ for larger features an implementation could be broken up into multiple PRs.
3939
- [ ] Implement the RFC (cc @rust-lang/XXX -- can anyone write up mentoring
4040
instructions?)
4141
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
42+
- [ ] Formatting for new syntax has been added to the [Style Guide] ([nightly-style-procedure])
4243
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])
4344

4445
[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
4546
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
47+
[nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/master/nightly-style-procedure.md
48+
[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide
4649

4750
### Unresolved Questions
4851
<!--

Diff for: .github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ jobs:
336336
os: macos-13
337337
- name: x86_64-apple-1
338338
env:
339-
SCRIPT: "./x.py --stage 2 test --exclude tests/ui --exclude tests/rustdoc --exclude tests/run-make-fulldeps"
339+
SCRIPT: "./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc --skip tests/run-make-fulldeps"
340340
RUST_CONFIGURE_ARGS: "--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
341341
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
342342
MACOSX_DEPLOYMENT_TARGET: 10.8

Diff for: Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,9 @@ dependencies = [
641641

642642
[[package]]
643643
name = "compiler_builtins"
644-
version = "0.1.98"
644+
version = "0.1.100"
645645
source = "registry+https://github.com/rust-lang/crates.io-index"
646-
checksum = "dfbefa16407456e5cad1ad066c84dfcb980afe4437103a0007d1c2f136130210"
646+
checksum = "d6c0f24437059853f0fa64afc51f338f93647a3de4cf3358ba1bb4171a199775"
647647
dependencies = [
648648
"cc",
649649
"rustc-std-workspace-core",

Diff for: compiler/rustc_ast/src/ast.rs

+10
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ pub enum TraitBoundModifier {
313313
MaybeConstMaybe,
314314
}
315315

316+
impl TraitBoundModifier {
317+
pub fn to_constness(self) -> Const {
318+
match self {
319+
// FIXME(effects) span
320+
Self::MaybeConst => Const::Yes(DUMMY_SP),
321+
_ => Const::No,
322+
}
323+
}
324+
}
325+
316326
/// The AST represents all type param bounds as types.
317327
/// `typeck::collect::compute_bounds` matches these against
318328
/// the "special" built-in traits (see `middle::lang_items`) and

Diff for: compiler/rustc_ast_lowering/src/asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
207207
&sym.path,
208208
ParamMode::Optional,
209209
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
210+
None,
210211
);
211212
hir::InlineAsmOperand::SymStatic { path, def_id }
212213
} else {

Diff for: compiler/rustc_ast_lowering/src/errors.rs

+17
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,26 @@ pub struct InvalidAbi {
3131
pub abi: Symbol,
3232
pub command: String,
3333
#[subdiagnostic]
34+
pub explain: Option<InvalidAbiReason>,
35+
#[subdiagnostic]
3436
pub suggestion: Option<InvalidAbiSuggestion>,
3537
}
3638

39+
pub struct InvalidAbiReason(pub &'static str);
40+
41+
impl rustc_errors::AddToDiagnostic for InvalidAbiReason {
42+
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
43+
where
44+
F: Fn(
45+
&mut rustc_errors::Diagnostic,
46+
rustc_errors::SubdiagnosticMessage,
47+
) -> rustc_errors::SubdiagnosticMessage,
48+
{
49+
#[allow(rustc::untranslatable_diagnostic)]
50+
diag.note(self.0);
51+
}
52+
}
53+
3754
#[derive(Subdiagnostic)]
3855
#[suggestion(
3956
ast_lowering_invalid_abi_suggestion,

Diff for: compiler/rustc_ast_lowering/src/expr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
100100
ParamMode::Optional,
101101
ParenthesizedGenericArgs::Err,
102102
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
103+
None,
103104
));
104105
let receiver = self.lower_expr(receiver);
105106
let args =
@@ -260,6 +261,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
260261
path,
261262
ParamMode::Optional,
262263
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
264+
None,
263265
);
264266
hir::ExprKind::Path(qpath)
265267
}
@@ -307,6 +309,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
307309
&se.path,
308310
ParamMode::Optional,
309311
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
312+
None,
310313
)),
311314
self.arena
312315
.alloc_from_iter(se.fields.iter().map(|x| self.lower_expr_field(x))),
@@ -1179,6 +1182,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11791182
path,
11801183
ParamMode::Optional,
11811184
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
1185+
None,
11821186
);
11831187
// Destructure like a tuple struct.
11841188
let tuple_struct_pat = hir::PatKind::TupleStruct(
@@ -1198,6 +1202,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11981202
path,
11991203
ParamMode::Optional,
12001204
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
1205+
None,
12011206
);
12021207
// Destructure like a unit struct.
12031208
let unit_struct_pat = hir::PatKind::Path(qpath);
@@ -1222,6 +1227,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12221227
&se.path,
12231228
ParamMode::Optional,
12241229
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
1230+
None,
12251231
);
12261232
let fields_omitted = match &se.rest {
12271233
StructRest::Base(e) => {

Diff for: compiler/rustc_ast_lowering/src/item.rs

+67-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::errors::{InvalidAbi, InvalidAbiSuggestion, MisplacedRelaxTraitBound};
1+
use super::errors::{InvalidAbi, InvalidAbiReason, InvalidAbiSuggestion, MisplacedRelaxTraitBound};
22
use super::ResolverAstLoweringExt;
33
use super::{AstOwner, ImplTraitContext, ImplTraitPosition};
44
use super::{FnDeclKind, LoweringContext, ParamMode};
@@ -90,6 +90,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
9090
allow_try_trait: Some([sym::try_trait_v2, sym::yeet_desugar_details][..].into()),
9191
allow_gen_future,
9292
generics_def_id_map: Default::default(),
93+
host_param_id: None,
9394
};
9495
lctx.with_hir_id_owner(owner, |lctx| f(lctx));
9596

@@ -144,8 +145,24 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
144145
// This is used to track which lifetimes have already been defined,
145146
// and which need to be replicated when lowering an async fn.
146147

147-
if let hir::ItemKind::Impl(impl_) = parent_hir.node().expect_item().kind {
148-
lctx.is_in_trait_impl = impl_.of_trait.is_some();
148+
match parent_hir.node().expect_item().kind {
149+
hir::ItemKind::Impl(impl_) => {
150+
lctx.is_in_trait_impl = impl_.of_trait.is_some();
151+
}
152+
hir::ItemKind::Trait(_, _, generics, _, _) if lctx.tcx.features().effects => {
153+
lctx.host_param_id = generics
154+
.params
155+
.iter()
156+
.find(|param| {
157+
parent_hir
158+
.attrs
159+
.get(param.hir_id.local_id)
160+
.iter()
161+
.any(|attr| attr.has_name(sym::rustc_host))
162+
})
163+
.map(|param| param.def_id);
164+
}
165+
_ => {}
149166
}
150167

151168
match ctxt {
@@ -389,6 +406,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
389406
self.lower_generics(ast_generics, *constness, id, &itctx, |this| {
390407
let trait_ref = trait_ref.as_ref().map(|trait_ref| {
391408
this.lower_trait_ref(
409+
*constness,
392410
trait_ref,
393411
&ImplTraitContext::Disallowed(ImplTraitPosition::Trait),
394412
)
@@ -419,7 +437,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
419437
polarity,
420438
defaultness,
421439
defaultness_span,
422-
constness: self.lower_constness(*constness),
423440
generics,
424441
of_trait: trait_ref,
425442
self_ty: lowered_ty,
@@ -1254,8 +1271,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
12541271
}
12551272

12561273
pub(super) fn lower_abi(&mut self, abi: StrLit) -> abi::Abi {
1257-
abi::lookup(abi.symbol_unescaped.as_str()).unwrap_or_else(|| {
1258-
self.error_on_invalid_abi(abi);
1274+
abi::lookup(abi.symbol_unescaped.as_str()).unwrap_or_else(|err| {
1275+
self.error_on_invalid_abi(abi, err);
12591276
abi::Abi::Rust
12601277
})
12611278
}
@@ -1268,7 +1285,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12681285
}
12691286
}
12701287

1271-
fn error_on_invalid_abi(&self, abi: StrLit) {
1288+
fn error_on_invalid_abi(&self, abi: StrLit, err: abi::AbiUnsupported) {
12721289
let abi_names = abi::enabled_names(self.tcx.features(), abi.span)
12731290
.iter()
12741291
.map(|s| Symbol::intern(s))
@@ -1277,6 +1294,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
12771294
self.tcx.sess.emit_err(InvalidAbi {
12781295
abi: abi.symbol_unescaped,
12791296
span: abi.span,
1297+
explain: match err {
1298+
abi::AbiUnsupported::Reason { explain } => Some(InvalidAbiReason(explain)),
1299+
_ => None,
1300+
},
12801301
suggestion: suggested_name.map(|suggested_name| InvalidAbiSuggestion {
12811302
span: abi.span,
12821303
suggestion: format!("\"{suggested_name}\""),
@@ -1363,6 +1384,29 @@ impl<'hir> LoweringContext<'_, 'hir> {
13631384
}
13641385
}
13651386

1387+
// Desugar `~const` bound in generics into an additional `const host: bool` param
1388+
// if the effects feature is enabled. This needs to be done before we lower where
1389+
// clauses since where clauses need to bind to the DefId of the host param
1390+
let host_param_parts = if let Const::Yes(span) = constness && self.tcx.features().effects {
1391+
if let Some(param) = generics.params.iter().find(|x| {
1392+
x.attrs.iter().any(|x| x.has_name(sym::rustc_host))
1393+
}) {
1394+
// user has manually specified a `rustc_host` param, in this case, we set
1395+
// the param id so that lowering logic can use that. But we don't create
1396+
// another host param, so this gives `None`.
1397+
self.host_param_id = Some(self.local_def_id(param.id));
1398+
None
1399+
} else {
1400+
let param_node_id = self.next_node_id();
1401+
let hir_id = self.next_id();
1402+
let def_id = self.create_def(self.local_def_id(parent_node_id), param_node_id, DefPathData::TypeNs(sym::host), span);
1403+
self.host_param_id = Some(def_id);
1404+
Some((span, hir_id, def_id))
1405+
}
1406+
} else {
1407+
None
1408+
};
1409+
13661410
let mut predicates: SmallVec<[hir::WherePredicate<'hir>; 4]> = SmallVec::new();
13671411
predicates.extend(generics.params.iter().filter_map(|param| {
13681412
self.lower_generic_bound_predicate(
@@ -1410,22 +1454,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
14101454
let impl_trait_bounds = std::mem::take(&mut self.impl_trait_bounds);
14111455
predicates.extend(impl_trait_bounds.into_iter());
14121456

1413-
// Desugar `~const` bound in generics into an additional `const host: bool` param
1414-
// if the effects feature is enabled.
1415-
if let Const::Yes(span) = constness && self.tcx.features().effects
1416-
// Do not add host param if it already has it (manually specified)
1417-
&& !params.iter().any(|x| {
1418-
self.attrs.get(&x.hir_id.local_id).map_or(false, |attrs| {
1419-
attrs.iter().any(|x| x.has_name(sym::rustc_host))
1420-
})
1421-
})
1422-
{
1423-
let param_node_id = self.next_node_id();
1457+
if let Some((span, hir_id, def_id)) = host_param_parts {
14241458
let const_node_id = self.next_node_id();
1425-
let def_id = self.create_def(self.local_def_id(parent_node_id), param_node_id, DefPathData::TypeNs(sym::host), span);
1426-
let anon_const: LocalDefId = self.create_def(def_id, const_node_id, DefPathData::AnonConst, span);
1459+
let anon_const: LocalDefId =
1460+
self.create_def(def_id, const_node_id, DefPathData::AnonConst, span);
14271461

1428-
let hir_id = self.next_id();
14291462
let const_id = self.next_id();
14301463
let const_expr_id = self.next_id();
14311464
let bool_id = self.next_id();
@@ -1435,14 +1468,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
14351468

14361469
let attr_id = self.tcx.sess.parse_sess.attr_id_generator.mk_attr_id();
14371470

1438-
let attrs = self.arena.alloc_from_iter([
1439-
Attribute {
1440-
kind: AttrKind::Normal(P(NormalAttr::from_ident(Ident::new(sym::rustc_host, span)))),
1471+
let attrs = self.arena.alloc_from_iter([Attribute {
1472+
kind: AttrKind::Normal(P(NormalAttr::from_ident(Ident::new(
1473+
sym::rustc_host,
14411474
span,
1442-
id: attr_id,
1443-
style: AttrStyle::Outer,
1444-
},
1445-
]);
1475+
)))),
1476+
span,
1477+
id: attr_id,
1478+
style: AttrStyle::Outer,
1479+
}]);
14461480
self.attrs.insert(hir_id.local_id, attrs);
14471481

14481482
let const_body = self.lower_body(|this| {
@@ -1481,7 +1515,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
14811515
}),
14821516
)),
14831517
)),
1484-
default: Some(hir::AnonConst { def_id: anon_const, hir_id: const_id, body: const_body }),
1518+
default: Some(hir::AnonConst {
1519+
def_id: anon_const,
1520+
hir_id: const_id,
1521+
body: const_body,
1522+
}),
14851523
},
14861524
colon_span: None,
14871525
pure_wrt_drop: false,

0 commit comments

Comments
 (0)