Skip to content

Commit e82c861

Browse files
committed
Auto merge of #124726 - matthiaskrgr:rollup-m6i3day, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #124501 (add support to override lldb binary path for ./x test) - #124573 (add a reference link to the comment of the "cc" and "cmake".) - #124663 (Enable reusing CI Docker cache when running CI images locally) - #124690 (Only consider ambiguous goals when finding best obligation for ambiguities) - #124713 (Update Cargo specific diagnostics in check-cfg) - #124717 (Implement `do_not_recommend` in the new solver) - #124718 (Record impl args in the proof tree) - #124720 (interpret: Drop: always evaluate place) - #124721 (library/std: Fix build for NetBSD targets with 32-bit `c_long`) - #124723 (Use correct Hermit links in The `rustc` Book) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d568423 + e186740 commit e82c861

File tree

24 files changed

+247
-104
lines changed

24 files changed

+247
-104
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
540540
// \-------/
541541
//
542542
let virtual_drop = Instance {
543-
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0),
543+
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0), // idx 0: the drop function
544544
args: drop_fn.args,
545545
};
546546
debug!("ty = {:?}", ty);
@@ -581,7 +581,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
581581
//
582582
// SO THEN WE CAN USE THE ABOVE CODE.
583583
let virtual_drop = Instance {
584-
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0),
584+
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0), // idx 0: the drop function
585585
args: drop_fn.args,
586586
};
587587
debug!("ty = {:?}", ty);

compiler/rustc_const_eval/src/interpret/terminator.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
169169
}
170170

171171
Drop { place, target, unwind, replace: _ } => {
172-
let frame = self.frame();
173-
let ty = place.ty(&frame.body.local_decls, *self.tcx).ty;
174-
let ty = self.instantiate_from_frame_and_normalize_erasing_regions(frame, ty)?;
175-
let instance = Instance::resolve_drop_in_place(*self.tcx, ty);
172+
let place = self.eval_place(place)?;
173+
let instance = Instance::resolve_drop_in_place(*self.tcx, place.layout.ty);
176174
if let ty::InstanceDef::DropGlue(_, None) = instance.def {
177175
// This is the branch we enter if and only if the dropped type has no drop glue
178176
// whatsoever. This can happen as a result of monomorphizing a drop of a
@@ -181,8 +179,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
181179
self.go_to_block(target);
182180
return Ok(());
183181
}
184-
let place = self.eval_place(place)?;
185-
trace!("TerminatorKind::drop: {:?}, type {}", place, ty);
182+
trace!("TerminatorKind::drop: {:?}, type {}", place, place.layout.ty);
186183
self.drop_in_place(&place, instance, target, unwind)?;
187184
}
188185

@@ -952,6 +949,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
952949
// implementation fail -- a problem shared by rustc.
953950
let place = self.force_allocation(place)?;
954951

952+
// We behave a bit different from codegen here.
953+
// Codegen creates an `InstanceDef::Virtual` with index 0 (the slot of the drop method) and
954+
// then dispatches that to the normal call machinery. However, our call machinery currently
955+
// only supports calling `VtblEntry::Method`; it would choke on a `MetadataDropInPlace`. So
956+
// instead we do the virtual call stuff ourselves. It's easier here than in `eval_fn_call`
957+
// since we can just get a place of the underlying type and use `mplace_to_ref`.
955958
let place = match place.layout.ty.kind() {
956959
ty::Dynamic(data, _, ty::Dyn) => {
957960
// Dropping a trait object. Need to find actual drop fn.

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
518518
// RFC 2397
519519
gated!(
520520
do_not_recommend, Normal, template!(Word), WarnFollowing,
521-
EncodeCrossCrate::No, experimental!(do_not_recommend)
521+
EncodeCrossCrate::Yes, experimental!(do_not_recommend)
522522
),
523523

524524
// `#[cfi_encoding = ""]`

compiler/rustc_lint/src/context/diagnostics/check_cfg.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ pub(super) fn unexpected_cfg_name(
164164

165165
if is_from_cargo {
166166
if !is_feature_cfg {
167-
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
167+
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo::rustc-check-cfg={inst}\");` to the top of the `build.rs`"));
168168
}
169-
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
169+
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration");
170170
} else {
171171
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
172172
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
@@ -266,9 +266,9 @@ pub(super) fn unexpected_cfg_value(
266266
diag.help("consider defining some features in `Cargo.toml`");
267267
}
268268
} else if !is_cfg_a_well_know_name {
269-
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
269+
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo::rustc-check-cfg={inst}\");` to the top of the `build.rs`"));
270270
}
271-
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
271+
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration");
272272
} else {
273273
if !is_cfg_a_well_know_name {
274274
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));

compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,12 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
888888
self.infcx.resolve_vars_if_possible(value)
889889
}
890890

891-
pub(super) fn fresh_args_for_item(&self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
892-
self.infcx.fresh_args_for_item(DUMMY_SP, def_id)
891+
pub(super) fn fresh_args_for_item(&mut self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
892+
let args = self.infcx.fresh_args_for_item(DUMMY_SP, def_id);
893+
for arg in args {
894+
self.inspect.add_var_value(arg);
895+
}
896+
args
893897
}
894898

895899
pub(super) fn translate_args(

compiler/rustc_trait_selection/src/solve/fulfill.rs

+20-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_infer::traits::{
1111
};
1212
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1313
use rustc_middle::ty::{self, TyCtxt};
14+
use rustc_span::symbol::sym;
1415

1516
use super::eval_ctxt::GenerateProofTree;
1617
use super::inspect::{ProofTreeInferCtxtExt, ProofTreeVisitor};
@@ -137,7 +138,7 @@ impl<'tcx> TraitEngine<'tcx> for FulfillmentCtxt<'tcx> {
137138
.collect();
138139

139140
errors.extend(self.obligations.overflowed.drain(..).map(|obligation| FulfillmentError {
140-
obligation: find_best_leaf_obligation(infcx, &obligation),
141+
obligation: find_best_leaf_obligation(infcx, &obligation, true),
141142
code: FulfillmentErrorCode::Ambiguity { overflow: Some(true) },
142143
root_obligation: obligation,
143144
}));
@@ -198,7 +199,7 @@ fn fulfillment_error_for_no_solution<'tcx>(
198199
infcx: &InferCtxt<'tcx>,
199200
root_obligation: PredicateObligation<'tcx>,
200201
) -> FulfillmentError<'tcx> {
201-
let obligation = find_best_leaf_obligation(infcx, &root_obligation);
202+
let obligation = find_best_leaf_obligation(infcx, &root_obligation, false);
202203

203204
let code = match obligation.predicate.kind().skip_binder() {
204205
ty::PredicateKind::Clause(ty::ClauseKind::Projection(_)) => {
@@ -266,7 +267,7 @@ fn fulfillment_error_for_stalled<'tcx>(
266267
});
267268

268269
FulfillmentError {
269-
obligation: find_best_leaf_obligation(infcx, &obligation),
270+
obligation: find_best_leaf_obligation(infcx, &obligation, true),
270271
code,
271272
root_obligation: obligation,
272273
}
@@ -275,19 +276,21 @@ fn fulfillment_error_for_stalled<'tcx>(
275276
fn find_best_leaf_obligation<'tcx>(
276277
infcx: &InferCtxt<'tcx>,
277278
obligation: &PredicateObligation<'tcx>,
279+
consider_ambiguities: bool,
278280
) -> PredicateObligation<'tcx> {
279281
let obligation = infcx.resolve_vars_if_possible(obligation.clone());
280282
infcx
281283
.visit_proof_tree(
282284
obligation.clone().into(),
283-
&mut BestObligation { obligation: obligation.clone() },
285+
&mut BestObligation { obligation: obligation.clone(), consider_ambiguities },
284286
)
285287
.break_value()
286288
.unwrap_or(obligation)
287289
}
288290

289291
struct BestObligation<'tcx> {
290292
obligation: PredicateObligation<'tcx>,
293+
consider_ambiguities: bool,
291294
}
292295

293296
impl<'tcx> BestObligation<'tcx> {
@@ -320,6 +323,14 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
320323
return ControlFlow::Break(self.obligation.clone());
321324
};
322325

326+
// Don't walk into impls that have `do_not_recommend`.
327+
if let ProbeKind::TraitCandidate { source: CandidateSource::Impl(impl_def_id), result: _ } =
328+
candidate.kind()
329+
&& goal.infcx().tcx.has_attr(impl_def_id, sym::do_not_recommend)
330+
{
331+
return ControlFlow::Break(self.obligation.clone());
332+
}
333+
323334
// FIXME: Could we extract a trait ref from a projection here too?
324335
// FIXME: Also, what about considering >1 layer up the stack? May be necessary
325336
// for normalizes-to.
@@ -355,11 +366,11 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
355366
}
356367
}
357368

358-
// Skip nested goals that hold.
359-
//FIXME: We should change the max allowed certainty based on if we're
360-
// visiting an ambiguity or error obligation.
361-
if matches!(nested_goal.result(), Ok(Certainty::Yes)) {
362-
continue;
369+
// Skip nested goals that aren't the *reason* for our goal's failure.
370+
match self.consider_ambiguities {
371+
true if matches!(nested_goal.result(), Ok(Certainty::Maybe(_))) => {}
372+
false if matches!(nested_goal.result(), Err(_)) => {}
373+
_ => continue,
363374
}
364375

365376
self.with_derived_obligation(obligation, |this| nested_goal.visit_with(this))?;

config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@
254254
# executing the debuginfo test suite.
255255
#gdb = "gdb"
256256

257+
# The path to (or name of) the LLDB executable to use. This is only used for
258+
# executing the debuginfo test suite.
259+
#lldb = "lldb"
260+
257261
# The node.js executable to use. Note that this is only used for the emscripten
258262
# target when running tests, otherwise this can be omitted.
259263
#nodejs = "node"

library/std/src/sys/pal/unix/thread_parking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::ffi::{c_int, c_void};
66
use crate::ptr;
77
use crate::time::Duration;
8-
use libc::{_lwp_self, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
8+
use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
99

1010
extern "C" {
1111
fn ___lwp_park60(
@@ -38,7 +38,7 @@ pub fn park_timeout(dur: Duration, hint: usize) {
3838
// Saturate so that the operation will definitely time out
3939
// (even if it is after the heat death of the universe).
4040
tv_sec: dur.as_secs().try_into().ok().unwrap_or(time_t::MAX),
41-
tv_nsec: dur.subsec_nanos().into(),
41+
tv_nsec: dur.subsec_nanos() as c_long,
4242
};
4343

4444
// Timeout needs to be mutable since it is modified on NetBSD 9.0 and

src/bootstrap/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ path = "src/bin/sccache-plus-cl.rs"
3333
test = false
3434

3535
[dependencies]
36-
# Most of the time updating these dependencies requires modifications
37-
# to the bootstrap codebase; otherwise, some targets will fail. That's
38-
# why these dependencies are explicitly pinned.
36+
# Most of the time updating these dependencies requires modifications to the
37+
# bootstrap codebase(e.g., https://github.com./rust-lang/rust/issues/124565);
38+
# otherwise, some targets will fail. That's why these dependencies are explicitly pinned.
3939
cc = "=1.0.73"
4040
cmake = "=0.1.48"
4141

src/bootstrap/src/core/build_steps/test.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1892,15 +1892,16 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
18921892
.to_string()
18931893
})
18941894
};
1895-
let lldb_exe = "lldb";
1896-
let lldb_version = Command::new(lldb_exe)
1895+
1896+
let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
1897+
let lldb_version = Command::new(&lldb_exe)
18971898
.arg("--version")
18981899
.output()
18991900
.map(|output| String::from_utf8_lossy(&output.stdout).to_string())
19001901
.ok();
19011902
if let Some(ref vers) = lldb_version {
19021903
cmd.arg("--lldb-version").arg(vers);
1903-
let lldb_python_dir = run(Command::new(lldb_exe).arg("-P")).ok();
1904+
let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok();
19041905
if let Some(ref dir) = lldb_python_dir {
19051906
cmd.arg("--lldb-python-dir").arg(dir);
19061907
}

src/bootstrap/src/core/config/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ pub struct Config {
329329
pub nodejs: Option<PathBuf>,
330330
pub npm: Option<PathBuf>,
331331
pub gdb: Option<PathBuf>,
332+
pub lldb: Option<PathBuf>,
332333
pub python: Option<PathBuf>,
333334
pub reuse: Option<PathBuf>,
334335
pub cargo_native_static: bool,
@@ -834,6 +835,7 @@ define_config! {
834835
docs_minification: Option<bool> = "docs-minification",
835836
submodules: Option<bool> = "submodules",
836837
gdb: Option<String> = "gdb",
838+
lldb: Option<String> = "lldb",
837839
nodejs: Option<String> = "nodejs",
838840
npm: Option<String> = "npm",
839841
python: Option<String> = "python",
@@ -1410,6 +1412,7 @@ impl Config {
14101412
docs_minification,
14111413
submodules,
14121414
gdb,
1415+
lldb,
14131416
nodejs,
14141417
npm,
14151418
python,
@@ -1502,6 +1505,7 @@ impl Config {
15021505
config.nodejs = nodejs.map(PathBuf::from);
15031506
config.npm = npm.map(PathBuf::from);
15041507
config.gdb = gdb.map(PathBuf::from);
1508+
config.lldb = lldb.map(PathBuf::from);
15051509
config.python = python.map(PathBuf::from);
15061510
config.reuse = reuse.map(PathBuf::from);
15071511
config.submodules = submodules;

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
175175
severity: ChangeSeverity::Warning,
176176
summary: "The deprecated field `changelog-seen` has been removed. Using that field in `config.toml` from now on will result in breakage.",
177177
},
178+
ChangeInfo {
179+
change_id: 124501,
180+
severity: ChangeSeverity::Info,
181+
summary: "New option `build.lldb` that will override the default lldb binary path used in debuginfo tests",
182+
},
178183
];

src/ci/docker/run.sh

+39-35
Original file line numberDiff line numberDiff line change
@@ -50,39 +50,35 @@ fi
5050
CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}"
5151

5252
if [ -f "$docker_dir/$image/Dockerfile" ]; then
53-
if isCI; then
54-
hash_key=/tmp/.docker-hash-key.txt
55-
rm -f "${hash_key}"
56-
echo $image >> $hash_key
57-
58-
cat "$docker_dir/$image/Dockerfile" >> $hash_key
59-
# Look for all source files involves in the COPY command
60-
copied_files=/tmp/.docker-copied-files.txt
61-
rm -f "$copied_files"
62-
for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \
63-
"$docker_dir/$image/Dockerfile"); do
64-
# List the file names
65-
find "$script_dir/$i" -type f >> $copied_files
66-
done
67-
# Sort the file names and cat the content into the hash key
68-
sort $copied_files | xargs cat >> $hash_key
69-
70-
# Include the architecture in the hash key, since our Linux CI does not
71-
# only run in x86_64 machines.
72-
uname -m >> $hash_key
73-
74-
docker --version >> $hash_key
75-
76-
# Include cache version. Can be used to manually bust the Docker cache.
77-
echo "2" >> $hash_key
78-
79-
echo "Image input"
80-
cat $hash_key
81-
82-
cksum=$(sha512sum $hash_key | \
83-
awk '{print $1}')
84-
echo "Image input checksum ${cksum}"
85-
fi
53+
hash_key=/tmp/.docker-hash-key.txt
54+
rm -f "${hash_key}"
55+
echo $image >> $hash_key
56+
57+
cat "$docker_dir/$image/Dockerfile" >> $hash_key
58+
# Look for all source files involves in the COPY command
59+
copied_files=/tmp/.docker-copied-files.txt
60+
rm -f "$copied_files"
61+
for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \
62+
"$docker_dir/$image/Dockerfile"); do
63+
# List the file names
64+
find "$script_dir/$i" -type f >> $copied_files
65+
done
66+
# Sort the file names and cat the content into the hash key
67+
sort $copied_files | xargs cat >> $hash_key
68+
69+
# Include the architecture in the hash key, since our Linux CI does not
70+
# only run in x86_64 machines.
71+
uname -m >> $hash_key
72+
73+
# Include cache version. Can be used to manually bust the Docker cache.
74+
echo "2" >> $hash_key
75+
76+
echo "Image input"
77+
cat $hash_key
78+
79+
cksum=$(sha512sum $hash_key | \
80+
awk '{print $1}')
81+
echo "Image input checksum ${cksum}"
8682

8783
dockerfile="$docker_dir/$image/Dockerfile"
8884
if [ -x /usr/bin/cygpath ]; then
@@ -105,10 +101,18 @@ if [ -f "$docker_dir/$image/Dockerfile" ]; then
105101
# It seems that it cannot be the same as $IMAGE_TAG, otherwise it overwrites the cache
106102
CACHE_IMAGE_TAG=${REGISTRY}/${REGISTRY_USERNAME}/rust-ci-cache:${cksum}
107103

108-
# On non-CI jobs, we don't do any caching.
104+
# On non-CI jobs, we try to download a pre-built image from the rust-lang-ci
105+
# ghcr.io registry. If it is not possible, we fall back to building the image
106+
# locally.
109107
if ! isCI;
110108
then
111-
retry docker build --rm -t rust-ci -f "$dockerfile" "$context"
109+
if docker pull "${IMAGE_TAG}"; then
110+
echo "Downloaded Docker image from CI"
111+
docker tag "${IMAGE_TAG}" rust-ci
112+
else
113+
echo "Building local Docker image"
114+
retry docker build --rm -t rust-ci -f "$dockerfile" "$context"
115+
fi
112116
# On PR CI jobs, we don't have permissions to write to the registry cache,
113117
# but we can still read from it.
114118
elif [[ "$PR_CI_JOB" == "1" ]];

0 commit comments

Comments
 (0)