Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b779120

Browse files
committed
Auto merge of rust-lang#145844 - Zalathar:rollup-4kdll9t, r=Zalathar
Rollup of 10 pull requests Successful merges: - rust-lang#135761 (Dial down detail of B-tree description) - rust-lang#145620 (Account for impossible bounds making seemingly unsatisfyable dyn-to-dyn casts) - rust-lang#145788 (Fix attribute target checking for macro calls) - rust-lang#145794 (bootstrap.py: Improve CPU detection on NetBSD) - rust-lang#145817 (cg_llvm: Replace the `llvm::Bool` typedef with a proper newtype) - rust-lang#145820 (raw-dylib-elf: set correct `DT_VERDEFNUM`) - rust-lang#145828 (Update `bitflags` to 2.9.3.) - rust-lang#145830 (Remove the lifetime from `ExpTokenPair`/`SeqSep`.) - rust-lang#145836 (Remove outdated bug comments) - rust-lang#145842 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ee361e8 + 0119d16 commit b779120

Some content is hidden

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

60 files changed

+816
-379
lines changed

‎Cargo.lock‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ dependencies = [
266266

267267
[[package]]
268268
name = "bitflags"
269-
version = "2.9.2"
269+
version = "2.9.3"
270270
source = "registry+https://github.com/rust-lang/crates.io-index"
271-
checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29"
271+
checksum = "34efbcccd345379ca2868b2b2c9d3782e9cc58ba87bc7d79d5b53d9c9ae6f25d"
272272

273273
[[package]]
274274
name = "blake3"

‎compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
127127
Warn(Target::Field),
128128
Warn(Target::Arm),
129129
Warn(Target::MacroDef),
130+
Warn(Target::MacroCall),
130131
]);
131132
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");
132133

@@ -174,6 +175,7 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
174175
Allow(Target::Method(MethodKind::Inherent)),
175176
Allow(Target::Method(MethodKind::Trait { body: true })),
176177
Allow(Target::Method(MethodKind::TraitImpl)),
178+
Warn(Target::MacroCall),
177179
]);
178180

179181
fn finalize(self, cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {
@@ -278,6 +280,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for TrackCallerParser {
278280
Warn(Target::MacroDef),
279281
Warn(Target::Arm),
280282
Warn(Target::Field),
283+
Warn(Target::MacroCall),
281284
]);
282285
const CREATE: fn(Span) -> AttributeKind = AttributeKind::TrackCaller;
283286
}
@@ -365,7 +368,8 @@ impl<S: Stage> AttributeParser<S> for UsedParser {
365368
}
366369
},
367370
)];
368-
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Static)]);
371+
const ALLOWED_TARGETS: AllowedTargets =
372+
AllowedTargets::AllowList(&[Allow(Target::Static), Warn(Target::MacroCall)]);
369373

370374
fn finalize(self, _cx: &FinalizeContext<'_, '_, S>) -> Option<AttributeKind> {
371375
// Ratcheting behaviour, if both `linker` and `compiler` are specified, use `linker`
@@ -450,6 +454,7 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
450454
Warn(Target::Field),
451455
Warn(Target::Arm),
452456
Warn(Target::MacroDef),
457+
Warn(Target::MacroCall),
453458
]);
454459
}
455460

‎compiler/rustc_attr_parsing/src/attributes/inline.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ impl<S: Stage> SingleAttributeParser<S> for InlineParser {
2525
Warn(Target::MacroDef),
2626
Warn(Target::Arm),
2727
Warn(Target::AssocConst),
28+
Warn(Target::MacroCall),
2829
]);
2930
const TEMPLATE: AttributeTemplate = template!(
3031
Word,

‎compiler/rustc_attr_parsing/src/attributes/link_attrs.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ impl<S: Stage> SingleAttributeParser<S> for LinkOrdinalParser {
110110
const PATH: &[Symbol] = &[sym::link_ordinal];
111111
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
112112
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
113-
const ALLOWED_TARGETS: AllowedTargets =
114-
AllowedTargets::AllowList(&[Allow(Target::ForeignFn), Allow(Target::ForeignStatic)]);
113+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
114+
Allow(Target::ForeignFn),
115+
Allow(Target::ForeignStatic),
116+
Warn(Target::MacroCall),
117+
]);
115118
const TEMPLATE: AttributeTemplate = template!(
116119
List: &["ordinal"],
117120
"https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute"

‎compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl<S: Stage> NoArgsAttributeParser<S> for NonExhaustiveParser {
1919
Warn(Target::Field),
2020
Warn(Target::Arm),
2121
Warn(Target::MacroDef),
22+
Warn(Target::MacroCall),
2223
]);
2324
const CREATE: fn(Span) -> AttributeKind = AttributeKind::NonExhaustive;
2425
}

‎compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
use super::prelude::*;
22

3+
const PROC_MACRO_ALLOWED_TARGETS: AllowedTargets =
4+
AllowedTargets::AllowList(&[Allow(Target::Fn), Warn(Target::Crate), Warn(Target::MacroCall)]);
5+
36
pub(crate) struct ProcMacroParser;
47
impl<S: Stage> NoArgsAttributeParser<S> for ProcMacroParser {
58
const PATH: &[Symbol] = &[sym::proc_macro];
69
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
7-
const ALLOWED_TARGETS: AllowedTargets =
8-
AllowedTargets::AllowList(&[Allow(Target::Fn), Warn(Target::Crate)]);
10+
const ALLOWED_TARGETS: AllowedTargets = PROC_MACRO_ALLOWED_TARGETS;
911
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ProcMacro;
1012
}
1113

1214
pub(crate) struct ProcMacroAttributeParser;
1315
impl<S: Stage> NoArgsAttributeParser<S> for ProcMacroAttributeParser {
1416
const PATH: &[Symbol] = &[sym::proc_macro_attribute];
1517
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
16-
const ALLOWED_TARGETS: AllowedTargets =
17-
AllowedTargets::AllowList(&[Allow(Target::Fn), Warn(Target::Crate)]);
18+
const ALLOWED_TARGETS: AllowedTargets = PROC_MACRO_ALLOWED_TARGETS;
1819
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ProcMacroAttribute;
1920
}
2021

@@ -23,8 +24,7 @@ impl<S: Stage> SingleAttributeParser<S> for ProcMacroDeriveParser {
2324
const PATH: &[Symbol] = &[sym::proc_macro_derive];
2425
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
2526
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
26-
const ALLOWED_TARGETS: AllowedTargets =
27-
AllowedTargets::AllowList(&[Allow(Target::Fn), Warn(Target::Crate)]);
27+
const ALLOWED_TARGETS: AllowedTargets = PROC_MACRO_ALLOWED_TARGETS;
2828
const TEMPLATE: AttributeTemplate = template!(
2929
List: &["TraitName", "TraitName, attributes(name1, name2, ...)"],
3030
"https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros"

‎compiler/rustc_attr_parsing/src/lints.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,14 @@ pub fn emit_attribute_lint<L: LintEmitter>(lint: &AttributeLint<L::Id>, lint_emi
4141
.emit_node_span_lint(
4242
// This check is here because `deprecated` had its own lint group and removing this would be a breaking change
4343
if name.segments[0].name == sym::deprecated
44-
&& ![Target::Closure, Target::Expression, Target::Statement, Target::Arm]
45-
.contains(target)
44+
&& ![
45+
Target::Closure,
46+
Target::Expression,
47+
Target::Statement,
48+
Target::Arm,
49+
Target::MacroCall,
50+
]
51+
.contains(target)
4652
{
4753
rustc_session::lint::builtin::USELESS_DEPRECATED
4854
} else {

‎compiler/rustc_borrowck/src/type_check/mod.rs‎

Lines changed: 74 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use rustc_mir_dataflow::points::DenseLocationMap;
3434
use rustc_span::def_id::CRATE_DEF_ID;
3535
use rustc_span::source_map::Spanned;
3636
use rustc_span::{Span, sym};
37+
use rustc_trait_selection::infer::InferCtxtExt;
3738
use rustc_trait_selection::traits::query::type_op::custom::scrape_region_constraints;
3839
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
3940
use tracing::{debug, instrument, trace};
@@ -1454,68 +1455,79 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
14541455
}
14551456
CastKind::PtrToPtr => {
14561457
let ty_from = op.ty(self.body, tcx);
1457-
let cast_ty_from = CastTy::from_ty(ty_from);
1458-
let cast_ty_to = CastTy::from_ty(*ty);
1459-
match (cast_ty_from, cast_ty_to) {
1460-
(Some(CastTy::Ptr(src)), Some(CastTy::Ptr(dst))) => {
1461-
let src_tail = self.struct_tail(src.ty, location);
1462-
let dst_tail = self.struct_tail(dst.ty, location);
1463-
1464-
// This checks (lifetime part of) vtable validity for pointer casts,
1465-
// which is irrelevant when there are aren't principal traits on
1466-
// both sides (aka only auto traits).
1467-
//
1468-
// Note that other checks (such as denying `dyn Send` -> `dyn
1469-
// Debug`) are in `rustc_hir_typeck`.
1470-
if let ty::Dynamic(src_tty, _src_lt, ty::Dyn) = *src_tail.kind()
1471-
&& let ty::Dynamic(dst_tty, dst_lt, ty::Dyn) = *dst_tail.kind()
1472-
&& src_tty.principal().is_some()
1473-
&& dst_tty.principal().is_some()
1474-
{
1475-
// Remove auto traits.
1476-
// Auto trait checks are handled in `rustc_hir_typeck` as FCW.
1477-
let src_obj = Ty::new_dynamic(
1478-
tcx,
1479-
tcx.mk_poly_existential_predicates(
1480-
&src_tty.without_auto_traits().collect::<Vec<_>>(),
1481-
),
1482-
// FIXME: Once we disallow casting `*const dyn Trait + 'short`
1483-
// to `*const dyn Trait + 'long`, then this can just be `src_lt`.
1484-
dst_lt,
1485-
ty::Dyn,
1486-
);
1487-
let dst_obj = Ty::new_dynamic(
1488-
tcx,
1489-
tcx.mk_poly_existential_predicates(
1490-
&dst_tty.without_auto_traits().collect::<Vec<_>>(),
1491-
),
1492-
dst_lt,
1493-
ty::Dyn,
1494-
);
1495-
1496-
debug!(?src_tty, ?dst_tty, ?src_obj, ?dst_obj);
1497-
1498-
self.sub_types(
1499-
src_obj,
1500-
dst_obj,
1501-
location.to_locations(),
1502-
ConstraintCategory::Cast {
1503-
is_implicit_coercion: false,
1504-
unsize_to: None,
1505-
},
1506-
)
1507-
.unwrap();
1508-
}
1509-
}
1510-
_ => {
1511-
span_mirbug!(
1512-
self,
1513-
rvalue,
1514-
"Invalid PtrToPtr cast {:?} -> {:?}",
1515-
ty_from,
1516-
ty
1517-
)
1518-
}
1458+
let Some(CastTy::Ptr(src)) = CastTy::from_ty(ty_from) else {
1459+
unreachable!();
1460+
};
1461+
let Some(CastTy::Ptr(dst)) = CastTy::from_ty(*ty) else {
1462+
unreachable!();
1463+
};
1464+
1465+
if self.infcx.type_is_sized_modulo_regions(self.infcx.param_env, dst.ty) {
1466+
// Wide to thin ptr cast. This may even occur in an env with
1467+
// impossible predicates, such as `where dyn Trait: Sized`.
1468+
// In this case, we don't want to fall into the case below,
1469+
// since the types may not actually be equatable, but it's
1470+
// fine to perform this operation in an impossible env.
1471+
let trait_ref = ty::TraitRef::new(
1472+
tcx,
1473+
tcx.require_lang_item(LangItem::Sized, self.last_span),
1474+
[dst.ty],
1475+
);
1476+
self.prove_trait_ref(
1477+
trait_ref,
1478+
location.to_locations(),
1479+
ConstraintCategory::Cast {
1480+
is_implicit_coercion: true,
1481+
unsize_to: None,
1482+
},
1483+
);
1484+
} else if let ty::Dynamic(src_tty, _src_lt, ty::Dyn) =
1485+
*self.struct_tail(src.ty, location).kind()
1486+
&& let ty::Dynamic(dst_tty, dst_lt, ty::Dyn) =
1487+
*self.struct_tail(dst.ty, location).kind()
1488+
&& src_tty.principal().is_some()
1489+
&& dst_tty.principal().is_some()
1490+
{
1491+
// This checks (lifetime part of) vtable validity for pointer casts,
1492+
// which is irrelevant when there are aren't principal traits on
1493+
// both sides (aka only auto traits).
1494+
//
1495+
// Note that other checks (such as denying `dyn Send` -> `dyn
1496+
// Debug`) are in `rustc_hir_typeck`.
1497+
1498+
// Remove auto traits.
1499+
// Auto trait checks are handled in `rustc_hir_typeck` as FCW.
1500+
let src_obj = Ty::new_dynamic(
1501+
tcx,
1502+
tcx.mk_poly_existential_predicates(
1503+
&src_tty.without_auto_traits().collect::<Vec<_>>(),
1504+
),
1505+
// FIXME: Once we disallow casting `*const dyn Trait + 'short`
1506+
// to `*const dyn Trait + 'long`, then this can just be `src_lt`.
1507+
dst_lt,
1508+
ty::Dyn,
1509+
);
1510+
let dst_obj = Ty::new_dynamic(
1511+
tcx,
1512+
tcx.mk_poly_existential_predicates(
1513+
&dst_tty.without_auto_traits().collect::<Vec<_>>(),
1514+
),
1515+
dst_lt,
1516+
ty::Dyn,
1517+
);
1518+
1519+
debug!(?src_tty, ?dst_tty, ?src_obj, ?dst_obj);
1520+
1521+
self.sub_types(
1522+
src_obj,
1523+
dst_obj,
1524+
location.to_locations(),
1525+
ConstraintCategory::Cast {
1526+
is_implicit_coercion: false,
1527+
unsize_to: None,
1528+
},
1529+
)
1530+
.unwrap();
15191531
}
15201532
}
15211533
CastKind::Transmute => {

‎compiler/rustc_codegen_llvm/src/allocator.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use smallvec::SmallVec;
1212

1313
use crate::builder::SBuilder;
1414
use crate::declare::declare_simple_fn;
15-
use crate::llvm::{self, False,True, Type, Value};
15+
use crate::llvm::{self, FALSE,TRUE, Type, Value};
1616
use crate::{SimpleCx, attributes, debuginfo, llvm_util};
1717

1818
pub(crate) unsafe fn codegen(
@@ -80,7 +80,7 @@ pub(crate) unsafe fn codegen(
8080
&cx,
8181
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
8282
&i8,
83-
&llvm::LLVMConstInt(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as u64, False),
83+
&llvm::LLVMConstInt(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as u64, FALSE),
8484
);
8585

8686
// __rust_no_alloc_shim_is_unstable_v2
@@ -201,7 +201,7 @@ fn create_wrapper_function(
201201
.map(|(i, _)| llvm::get_param(llfn, i as c_uint))
202202
.collect::<Vec<_>>();
203203
let ret = bx.call(ty, callee, &args, None);
204-
llvm::LLVMSetTailCall(ret, True);
204+
llvm::LLVMSetTailCall(ret, TRUE);
205205
if output.is_some() {
206206
bx.ret(ret);
207207
} else {

‎compiler/rustc_codegen_llvm/src/asm.rs‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use tracing::debug;
1616
use crate::builder::Builder;
1717
use crate::common::Funclet;
1818
use crate::context::CodegenCx;
19+
use crate::llvm::ToLlvmBool;
1920
use crate::type_::Type;
2021
use crate::type_of::LayoutLlvmExt;
2122
use crate::value::Value;
@@ -470,10 +471,6 @@ pub(crate) fn inline_asm_call<'ll>(
470471
dest: Option<&'ll llvm::BasicBlock>,
471472
catch_funclet: Option<(&'ll llvm::BasicBlock, Option<&Funclet<'ll>>)>,
472473
) -> Option<&'ll Value> {
473-
let volatile = if volatile { llvm::True } else { llvm::False };
474-
let alignstack = if alignstack { llvm::True } else { llvm::False };
475-
let can_throw = if unwind { llvm::True } else { llvm::False };
476-
477474
let argtys = inputs
478475
.iter()
479476
.map(|v| {
@@ -500,10 +497,10 @@ pub(crate) fn inline_asm_call<'ll>(
500497
asm.len(),
501498
cons.as_ptr(),
502499
cons.len(),
503-
volatile,
504-
alignstack,
500+
volatile.to_llvm_bool(),
501+
alignstack.to_llvm_bool(),
505502
dia,
506-
can_throw,
503+
unwind.to_llvm_bool(),
507504
)
508505
};
509506

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /