Skip to content

Commit 8483293

Browse files
committed
Auto merge of #148404 - matthiaskrgr:rollup-o61qhjw, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #147137 (Mention crate being analyzed in query description) - #147155 (arm-linux.md: various fixes/improvements) - #147642 (Miscellaneous const-generics-related fixes) - #147806 (Ignore test-dashboard related files) - #147947 (Implement `strip_circumfix` lib feature) - #148346 (Change cfg_trace, cfg_attr_trace symbol values) - #148348 (dangling ptr lint cleanup) - #148393 (Remove `tests/run-make/fmt-write-bloat/`) - #148400 (Better warning message for crate type unsupported by codegen backend) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6a884ad + 1f4086b commit 8483293

File tree

29 files changed

+253
-231
lines changed

29 files changed

+253
-231
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ node_modules
9090
## Rustdoc GUI tests
9191
tests/rustdoc-gui/src/**.lock
9292

93+
## Test dashboard
94+
.citool-cache/
95+
test-dashboard/
96+
9397
## direnv
9498
/.envrc
9599
/.direnv/

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,12 @@ fn print_crate_info(
686686
};
687687
let t_outputs = rustc_interface::util::build_output_filenames(attrs, sess);
688688
let crate_name = passes::get_crate_name(sess, attrs);
689-
let crate_types =
690-
collect_crate_types(sess, &codegen_backend.supported_crate_types(sess), attrs);
689+
let crate_types = collect_crate_types(
690+
sess,
691+
&codegen_backend.supported_crate_types(sess),
692+
codegen_backend.name(),
693+
attrs,
694+
);
691695
for &style in &crate_types {
692696
let fname = rustc_session::output::filename_for_input(
693697
sess, style, crate_name, &t_outputs,

compiler/rustc_hir_analysis/src/collect/generics_of.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
7777
// stable enough and does not need a feature gate anymore.
7878
Node::AnonConst(_) => {
7979
let parent_did = tcx.parent(def_id.to_def_id());
80-
81-
// We don't do this unconditionally because the `DefId` parent of an anon const
82-
// might be an implicitly created closure during `async fn` desugaring. This would
83-
// have the wrong generics.
84-
//
85-
// i.e. `async fn foo<'a>() { let a = [(); { 1 + 2 }]; bar().await() }`
86-
// would implicitly have a closure in its body that would be the parent of
87-
// the `{ 1 + 2 }` anon const. This closure's generics is simply a witness
88-
// instead of `['a]`.
89-
let parent_did = if let DefKind::AnonConst = tcx.def_kind(parent_did) {
90-
parent_did
91-
} else {
92-
tcx.hir_get_parent_item(hir_id).to_def_id()
93-
};
9480
debug!(?parent_did);
9581

9682
let mut in_param_ty = false;

compiler/rustc_interface/src/passes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,7 @@ pub fn create_and_enter_global_ctxt<T, F: for<'tcx> FnOnce(TyCtxt<'tcx>) -> T>(
929929
let crate_types = collect_crate_types(
930930
sess,
931931
&compiler.codegen_backend.supported_crate_types(sess),
932+
compiler.codegen_backend.name(),
932933
&pre_configured_attrs,
933934
);
934935
let stable_crate_id = StableCrateId::new(

compiler/rustc_lint/messages.ftl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ lint_confusable_identifier_pair = found both `{$existing_sym}` and `{$sym}` as i
193193
.current_use = this identifier can be confused with `{$existing_sym}`
194194
.other_use = other identifier used here
195195
196-
lint_dangling_pointers_from_locals = a dangling pointer will be produced because the local variable `{$local_var_name}` will be dropped
197-
.ret_ty = return type of the {$fn_kind} is `{$ret_ty}`
198-
.local_var = `{$local_var_name}` is part the {$fn_kind} and will be dropped at the end of the {$fn_kind}
196+
lint_dangling_pointers_from_locals = {$fn_kind} returns a dangling pointer to dropped local variable `{$local_var_name}`
197+
.ret_ty = return type is `{$ret_ty}`
198+
.local_var = local variable `{$local_var_name}` is dropped at the end of the {$fn_kind}
199199
.created_at = dangling pointer created here
200-
.note = pointers do not have a lifetime; after returning, the `{$local_var_ty}` will be deallocated at the end of the {$fn_kind} because nothing is referencing it as far as the type system is concerned
200+
.note = a dangling pointer is safe, but dereferencing one is undefined behavior
201201
202202
lint_dangling_pointers_from_temporaries = a dangling pointer will be produced because the temporary `{$ty}` will be dropped
203203
.label_ptr = this pointer will immediately be invalid

compiler/rustc_middle/src/query/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ rustc_queries! {
397397
/// The root query triggering all analysis passes like typeck or borrowck.
398398
query analysis(key: ()) {
399399
eval_always
400-
desc { "running analysis passes on this crate" }
400+
desc { |tcx|
401+
"running analysis passes on crate `{}`",
402+
tcx.crate_name(LOCAL_CRATE),
403+
}
401404
}
402405

403406
/// This query checks the fulfillment of collected lint expectations.

compiler/rustc_mir_build/src/thir/constant.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,12 @@ pub(crate) fn lit_to_const<'tcx>(
5858
(ast::LitKind::Byte(n), ty::Uint(ty::UintTy::U8)) => {
5959
ty::ValTree::from_scalar_int(tcx, n.into())
6060
}
61-
(ast::LitKind::CStr(byte_sym, _), ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::CStr)) => {
62-
ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str())
61+
(ast::LitKind::CStr(byte_sym, _), ty::Ref(_, inner_ty, _)) if matches!(inner_ty.kind(), ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::CStr)) =>
62+
{
63+
// A CStr is a newtype around a byte slice, so we create the inner slice here.
64+
// We need a branch for each "level" of the data structure.
65+
let bytes = ty::ValTree::from_raw_bytes(tcx, byte_sym.as_byte_str());
66+
ty::ValTree::from_branches(tcx, [bytes])
6367
}
6468
(ast::LitKind::Int(n, _), ty::Uint(ui)) if !neg => {
6569
let scalar_int = trunc(n.get(), *ui);

compiler/rustc_session/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ session_unleashed_feature_help_unnamed = skipping check that does not even have
140140
141141
session_unstable_virtual_function_elimination = `-Zvirtual-function-elimination` requires `-Clto`
142142
143+
session_unsupported_crate_type_for_codegen_backend =
144+
dropping unsupported crate type `{$crate_type}` for codegen backend `{$codegen_backend}`
145+
143146
session_unsupported_crate_type_for_target =
144147
dropping unsupported crate type `{$crate_type}` for target `{$target_triple}`
145148

compiler/rustc_session/src/errors.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,13 @@ struct BinaryFloatLiteralNotSupported {
371371
span: Span,
372372
}
373373

374+
#[derive(Diagnostic)]
375+
#[diag(session_unsupported_crate_type_for_codegen_backend)]
376+
pub(crate) struct UnsupportedCrateTypeForCodegenBackend {
377+
pub(crate) crate_type: CrateType,
378+
pub(crate) codegen_backend: &'static str,
379+
}
380+
374381
#[derive(Diagnostic)]
375382
#[diag(session_unsupported_crate_type_for_target)]
376383
pub(crate) struct UnsupportedCrateTypeForTarget<'a> {

compiler/rustc_session/src/output.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ pub fn categorize_crate_type(s: Symbol) -> Option<CrateType> {
177177
pub fn collect_crate_types(
178178
session: &Session,
179179
backend_crate_types: &[CrateType],
180+
codegen_backend_name: &'static str,
180181
attrs: &[ast::Attribute],
181182
) -> Vec<CrateType> {
182183
// If we're generating a test executable, then ignore all other output
@@ -223,17 +224,18 @@ pub fn collect_crate_types(
223224
}
224225

225226
base.retain(|crate_type| {
226-
if invalid_output_for_target(session, *crate_type)
227-
|| !backend_crate_types.contains(crate_type)
228-
{
229-
// FIXME provide a better warning for the case where the codegen
230-
// backend doesn't support it once cargo doesn't hard code this
231-
// warning message.
227+
if invalid_output_for_target(session, *crate_type) {
232228
session.dcx().emit_warn(errors::UnsupportedCrateTypeForTarget {
233229
crate_type: *crate_type,
234230
target_triple: &session.opts.target_triple,
235231
});
236232
false
233+
} else if !backend_crate_types.contains(crate_type) {
234+
session.dcx().emit_warn(errors::UnsupportedCrateTypeForCodegenBackend {
235+
crate_type: *crate_type,
236+
codegen_backend: codegen_backend_name,
237+
});
238+
false
237239
} else {
238240
true
239241
}

0 commit comments

Comments
 (0)