Skip to content

Rollup of 10 pull requests #124726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d6b88a5
add support to override lldb binary path for ./x test
Apr 28, 2024
fca7c04
add a reference link to the comment of the "cc" and "cmake".
onur-ozkan May 1, 2024
27d1d0a
Do not include Docker version in caching key
Kobzol May 3, 2024
0372065
Calculate the Docker hash key also locally
Kobzol May 3, 2024
02f4ef7
Allow reusing CI Docker cache when running CI images locally
Kobzol May 3, 2024
dcf6853
Update Cargo diagnostics in check-cfg
Urgau May 4, 2024
6714216
Only consider ambiguous goals when finding best obligation for ambigu…
compiler-errors May 4, 2024
b335994
Implement do_not_recommend in the new solver
compiler-errors May 4, 2024
50338aa
Record impl args in the proof tree
compiler-errors May 4, 2024
79e09a6
Added an entry for "lldb" in config.example.toml
VladimirMakaev May 4, 2024
86a933a
interpret: Drop: always evaluate place
RalfJung May 4, 2024
f0dee6b
some comments or dynamic drop handling
RalfJung May 4, 2024
7dc27d5
library/std: Fix build for NetBSD targets with 32-bit `c_long`
ids1024 May 4, 2024
eade836
docs(fix): incorrect Hermit links in the rustc book
onkoe May 4, 2024
da961a8
fix(docs): Correct Hermit links to loader + 'rusty-demo'
onkoe May 4, 2024
3abefa1
docs(hermit): Explain Hermit's template link
onkoe May 4, 2024
43a5e3f
Rollup merge of #124501 - VladimirMakaev:add-lldb-to-config-toml, r=M…
matthiaskrgr May 4, 2024
bad5382
Rollup merge of #124573 - onur-ozkan:update-dep-comment, r=Mark-Simul…
matthiaskrgr May 4, 2024
f4d0776
Rollup merge of #124663 - Kobzol:docker-local-download, r=Mark-Simula…
matthiaskrgr May 4, 2024
7fbfd8d
Rollup merge of #124690 - compiler-errors:only-ambig-if-ambig, r=lcnr
matthiaskrgr May 4, 2024
6ece08f
Rollup merge of #124713 - Urgau:check-cfg-update-cargo-diagnostics, r…
matthiaskrgr May 4, 2024
79071ee
Rollup merge of #124717 - compiler-errors:do-not-recomment-next-solve…
matthiaskrgr May 4, 2024
07dc4aa
Rollup merge of #124718 - compiler-errors:record-impl-args, r=lcnr
matthiaskrgr May 4, 2024
5d413c1
Rollup merge of #124720 - RalfJung:interpret-drop, r=compiler-errors
matthiaskrgr May 4, 2024
4577b1a
Rollup merge of #124721 - ids1024:netbsd-32-bit-ulong, r=workingjubilee
matthiaskrgr May 4, 2024
e186740
Rollup merge of #124723 - onkoe:issue-124722-fix, r=workingjubilee
matthiaskrgr May 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// \-------/
//
let virtual_drop = Instance {
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0),
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0), // idx 0: the drop function
args: drop_fn.args,
};
debug!("ty = {:?}", ty);
Expand Down Expand Up @@ -581,7 +581,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
//
// SO THEN WE CAN USE THE ABOVE CODE.
let virtual_drop = Instance {
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0),
def: ty::InstanceDef::Virtual(drop_fn.def_id(), 0), // idx 0: the drop function
args: drop_fn.args,
};
debug!("ty = {:?}", ty);
Expand Down
15 changes: 9 additions & 6 deletions compiler/rustc_const_eval/src/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}

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

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

// We behave a bit different from codegen here.
// Codegen creates an `InstanceDef::Virtual` with index 0 (the slot of the drop method) and
// then dispatches that to the normal call machinery. However, our call machinery currently
// only supports calling `VtblEntry::Method`; it would choke on a `MetadataDropInPlace`. So
// instead we do the virtual call stuff ourselves. It's easier here than in `eval_fn_call`
// since we can just get a place of the underlying type and use `mplace_to_ref`.
let place = match place.layout.ty.kind() {
ty::Dynamic(data, _, ty::Dyn) => {
// Dropping a trait object. Need to find actual drop fn.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// RFC 2397
gated!(
do_not_recommend, Normal, template!(Word), WarnFollowing,
EncodeCrossCrate::No, experimental!(do_not_recommend)
EncodeCrossCrate::Yes, experimental!(do_not_recommend)
),

// `#[cfi_encoding = ""]`
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_lint/src/context/diagnostics/check_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ pub(super) fn unexpected_cfg_name(

if is_from_cargo {
if !is_feature_cfg {
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo::rustc-check-cfg={inst}\");` to the top of the `build.rs`"));
}
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration");
} else {
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
Expand Down Expand Up @@ -266,9 +266,9 @@ pub(super) fn unexpected_cfg_value(
diag.help("consider defining some features in `Cargo.toml`");
}
} else if !is_cfg_a_well_know_name {
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo:rustc-check-cfg={inst}\");` to the top of a `build.rs`"));
diag.help(format!("consider using a Cargo feature instead or adding `println!(\"cargo::rustc-check-cfg={inst}\");` to the top of the `build.rs`"));
}
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration");
} else {
if !is_cfg_a_well_know_name {
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,12 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
self.infcx.resolve_vars_if_possible(value)
}

pub(super) fn fresh_args_for_item(&self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
self.infcx.fresh_args_for_item(DUMMY_SP, def_id)
pub(super) fn fresh_args_for_item(&mut self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
let args = self.infcx.fresh_args_for_item(DUMMY_SP, def_id);
for arg in args {
self.inspect.add_var_value(arg);
}
args
}

pub(super) fn translate_args(
Expand Down
29 changes: 20 additions & 9 deletions compiler/rustc_trait_selection/src/solve/fulfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use rustc_infer::traits::{
};
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::symbol::sym;

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

errors.extend(self.obligations.overflowed.drain(..).map(|obligation| FulfillmentError {
obligation: find_best_leaf_obligation(infcx, &obligation),
obligation: find_best_leaf_obligation(infcx, &obligation, true),
code: FulfillmentErrorCode::Ambiguity { overflow: Some(true) },
root_obligation: obligation,
}));
Expand Down Expand Up @@ -198,7 +199,7 @@ fn fulfillment_error_for_no_solution<'tcx>(
infcx: &InferCtxt<'tcx>,
root_obligation: PredicateObligation<'tcx>,
) -> FulfillmentError<'tcx> {
let obligation = find_best_leaf_obligation(infcx, &root_obligation);
let obligation = find_best_leaf_obligation(infcx, &root_obligation, false);

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

FulfillmentError {
obligation: find_best_leaf_obligation(infcx, &obligation),
obligation: find_best_leaf_obligation(infcx, &obligation, true),
code,
root_obligation: obligation,
}
Expand All @@ -275,19 +276,21 @@ fn fulfillment_error_for_stalled<'tcx>(
fn find_best_leaf_obligation<'tcx>(
infcx: &InferCtxt<'tcx>,
obligation: &PredicateObligation<'tcx>,
consider_ambiguities: bool,
) -> PredicateObligation<'tcx> {
let obligation = infcx.resolve_vars_if_possible(obligation.clone());
infcx
.visit_proof_tree(
obligation.clone().into(),
&mut BestObligation { obligation: obligation.clone() },
&mut BestObligation { obligation: obligation.clone(), consider_ambiguities },
)
.break_value()
.unwrap_or(obligation)
}

struct BestObligation<'tcx> {
obligation: PredicateObligation<'tcx>,
consider_ambiguities: bool,
}

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

// Don't walk into impls that have `do_not_recommend`.
if let ProbeKind::TraitCandidate { source: CandidateSource::Impl(impl_def_id), result: _ } =
candidate.kind()
&& goal.infcx().tcx.has_attr(impl_def_id, sym::do_not_recommend)
{
return ControlFlow::Break(self.obligation.clone());
}

// FIXME: Could we extract a trait ref from a projection here too?
// FIXME: Also, what about considering >1 layer up the stack? May be necessary
// for normalizes-to.
Expand Down Expand Up @@ -355,11 +366,11 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
}
}

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

self.with_derived_obligation(obligation, |this| nested_goal.visit_with(this))?;
Expand Down
4 changes: 4 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@
# executing the debuginfo test suite.
#gdb = "gdb"

# The path to (or name of) the LLDB executable to use. This is only used for
# executing the debuginfo test suite.
#lldb = "lldb"

# The node.js executable to use. Note that this is only used for the emscripten
# target when running tests, otherwise this can be omitted.
#nodejs = "node"
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/pal/unix/thread_parking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::ffi::{c_int, c_void};
use crate::ptr;
use crate::time::Duration;
use libc::{_lwp_self, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
use libc::{_lwp_self, c_long, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};

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

// Timeout needs to be mutable since it is modified on NetBSD 9.0 and
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ path = "src/bin/sccache-plus-cl.rs"
test = false

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

Expand Down
7 changes: 4 additions & 3 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1892,15 +1892,16 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
.to_string()
})
};
let lldb_exe = "lldb";
let lldb_version = Command::new(lldb_exe)

let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
let lldb_version = Command::new(&lldb_exe)
.arg("--version")
.output()
.map(|output| String::from_utf8_lossy(&output.stdout).to_string())
.ok();
if let Some(ref vers) = lldb_version {
cmd.arg("--lldb-version").arg(vers);
let lldb_python_dir = run(Command::new(lldb_exe).arg("-P")).ok();
let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok();
if let Some(ref dir) = lldb_python_dir {
cmd.arg("--lldb-python-dir").arg(dir);
}
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ pub struct Config {
pub nodejs: Option<PathBuf>,
pub npm: Option<PathBuf>,
pub gdb: Option<PathBuf>,
pub lldb: Option<PathBuf>,
pub python: Option<PathBuf>,
pub reuse: Option<PathBuf>,
pub cargo_native_static: bool,
Expand Down Expand Up @@ -834,6 +835,7 @@ define_config! {
docs_minification: Option<bool> = "docs-minification",
submodules: Option<bool> = "submodules",
gdb: Option<String> = "gdb",
lldb: Option<String> = "lldb",
nodejs: Option<String> = "nodejs",
npm: Option<String> = "npm",
python: Option<String> = "python",
Expand Down Expand Up @@ -1410,6 +1412,7 @@ impl Config {
docs_minification,
submodules,
gdb,
lldb,
nodejs,
npm,
python,
Expand Down Expand Up @@ -1502,6 +1505,7 @@ impl Config {
config.nodejs = nodejs.map(PathBuf::from);
config.npm = npm.map(PathBuf::from);
config.gdb = gdb.map(PathBuf::from);
config.lldb = lldb.map(PathBuf::from);
config.python = python.map(PathBuf::from);
config.reuse = reuse.map(PathBuf::from);
config.submodules = submodules;
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Warning,
summary: "The deprecated field `changelog-seen` has been removed. Using that field in `config.toml` from now on will result in breakage.",
},
ChangeInfo {
change_id: 124501,
severity: ChangeSeverity::Info,
summary: "New option `build.lldb` that will override the default lldb binary path used in debuginfo tests",
},
];
74 changes: 39 additions & 35 deletions src/ci/docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,35 @@ fi
CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}"

if [ -f "$docker_dir/$image/Dockerfile" ]; then
if isCI; then
hash_key=/tmp/.docker-hash-key.txt
rm -f "${hash_key}"
echo $image >> $hash_key

cat "$docker_dir/$image/Dockerfile" >> $hash_key
# Look for all source files involves in the COPY command
copied_files=/tmp/.docker-copied-files.txt
rm -f "$copied_files"
for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \
"$docker_dir/$image/Dockerfile"); do
# List the file names
find "$script_dir/$i" -type f >> $copied_files
done
# Sort the file names and cat the content into the hash key
sort $copied_files | xargs cat >> $hash_key

# Include the architecture in the hash key, since our Linux CI does not
# only run in x86_64 machines.
uname -m >> $hash_key

docker --version >> $hash_key

# Include cache version. Can be used to manually bust the Docker cache.
echo "2" >> $hash_key

echo "Image input"
cat $hash_key

cksum=$(sha512sum $hash_key | \
awk '{print $1}')
echo "Image input checksum ${cksum}"
fi
hash_key=/tmp/.docker-hash-key.txt
rm -f "${hash_key}"
echo $image >> $hash_key

cat "$docker_dir/$image/Dockerfile" >> $hash_key
# Look for all source files involves in the COPY command
copied_files=/tmp/.docker-copied-files.txt
rm -f "$copied_files"
for i in $(sed -n -e '/^COPY --from=/! s/^COPY \(.*\) .*$/\1/p' \
"$docker_dir/$image/Dockerfile"); do
# List the file names
find "$script_dir/$i" -type f >> $copied_files
done
# Sort the file names and cat the content into the hash key
sort $copied_files | xargs cat >> $hash_key

# Include the architecture in the hash key, since our Linux CI does not
# only run in x86_64 machines.
uname -m >> $hash_key

# Include cache version. Can be used to manually bust the Docker cache.
echo "2" >> $hash_key

echo "Image input"
cat $hash_key

cksum=$(sha512sum $hash_key | \
awk '{print $1}')
echo "Image input checksum ${cksum}"

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

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