Skip to content
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

Rollup of 11 pull requests #124025

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
b75e6b4
fetch submodule before checking llvm stamp
onur-ozkan Mar 17, 2024
6b846cc
create new build step `clippy`
onur-ozkan Mar 22, 2024
c58f2d2
create `Builder::msg_clippy`
onur-ozkan Mar 22, 2024
bfd79f5
support different `Kind`s in `Builder::msg_tool`
onur-ozkan Mar 22, 2024
ba7d37f
for clippy, skip output handling in `run_cargo`
onur-ozkan Mar 22, 2024
0aceed7
add simple top-level doc-comment for build_steps/clippy
onur-ozkan Mar 22, 2024
d7c9f71
fix sysroot bug and update step message format
onur-ozkan Mar 22, 2024
006354c
update `mingw-check` clippy invocation
onur-ozkan Mar 22, 2024
e6a675c
allow running clippy on most of the in-tree tools
onur-ozkan Mar 22, 2024
3683b11
create `Build::update_existing_submodule` and use for llvm
onur-ozkan Mar 28, 2024
1ca1457
Support type '/' to search
mu001999 Apr 2, 2024
5519445
set --sysroot outside the driver rather than messing with the argumen…
RalfJung Mar 25, 2024
9ec38ea
readme updates
RalfJung Mar 26, 2024
a57a990
drop `changelog-seen`
onur-ozkan Apr 10, 2024
cce21be
add change entry for the removal of `changelog-seen`
onur-ozkan Apr 10, 2024
fb779ee
Windows: add basic support for FormatMessageW
RalfJung Apr 15, 2024
65978ed
Auto merge of #3464 - RalfJung:windows-err, r=RalfJung
bors Apr 15, 2024
3868c9f
fix error display for './miri run --dep'
RalfJung Apr 15, 2024
34ab668
Auto merge of #3465 - RalfJung:run-dep-error-format, r=RalfJung
bors Apr 15, 2024
e928fc5
add some basic support for GetFullPathNameW
RalfJung Apr 15, 2024
69e8e2d
Auto merge of #3411 - RalfJung:sysroot, r=RalfJung
bors Apr 15, 2024
0dee2b1
Auto merge of #3466 - RalfJung:GetFullPathNameW, r=RalfJung
bors Apr 15, 2024
54f90bc
Make `split_simd_to_128bit_chunks` take only one operand
eduardosm Apr 14, 2024
ca2bd01
Bump rustc-build-sysroot to 0.4.6
RossSmyth Apr 15, 2024
67334df
The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes`
oli-obk Apr 15, 2024
909fcfc
Stabilize checking of cfgs at compile-time: --check-cfg option
Urgau Feb 25, 2024
a20de73
Move --check-cfg documentation to stable books
Urgau Feb 25, 2024
0abd67f
Auto merge of #3462 - eduardosm:chunk-128, r=RalfJung
bors Apr 15, 2024
78ea5db
Auto merge of #3467 - RossSmyth:bumpSysroot, r=RalfJung
bors Apr 15, 2024
ef1d084
Match ergonomics 2024: `mut` doesn't reset binding mode
Jules-Bertholet Apr 6, 2024
83f330f
Migration lint
Jules-Bertholet Apr 6, 2024
d5d700d
Temporarily remove future compatibility label from migration lint
Jules-Bertholet Apr 6, 2024
1b2e471
Fix typo
Jules-Bertholet Apr 14, 2024
e13911e
Rename feature gate
Jules-Bertholet Apr 14, 2024
1b6d435
Mark gate as incomplete
Jules-Bertholet Apr 14, 2024
7a32117
Fix tests
Jules-Bertholet Apr 14, 2024
2f08c2c
update lockfile
RalfJung Apr 16, 2024
876ac7b
avoid passing --sysroot twice in bootstrap
RalfJung Apr 16, 2024
e03926c
Change a diagnostics-path-only `DefineOpaqueTypes` to `Yes`.
oli-obk Apr 16, 2024
18bfca5
interpret: pass MemoryKind to before_memory_deallocation
RalfJung Apr 16, 2024
5b8b9cf
interpret: remove outdated comment
RalfJung Apr 16, 2024
04a2e3c
Rollup merge of #122632 - onur-ozkan:fix-llvm-caching-bug, r=albertla…
matthiaskrgr Apr 16, 2024
d92cfc8
Rollup merge of #122883 - onur-ozkan:clippy-build-step, r=albertlarsan68
matthiaskrgr Apr 16, 2024
b94a4e6
Rollup merge of #123355 - mu001999:rustdoc/search, r=GuillaumeGomez
matthiaskrgr Apr 16, 2024
902487a
Rollup merge of #123501 - Urgau:stabilize-check-cfg, r=petrochenkov
matthiaskrgr Apr 16, 2024
ff34231
Rollup merge of #123535 - Jules-Bertholet:mut_dont_reset_binding_mode…
matthiaskrgr Apr 16, 2024
4f05fbc
Rollup merge of #123711 - onur-ozkan:drop-changelog-seen, r=albertlar…
matthiaskrgr Apr 16, 2024
c709c51
Rollup merge of #123969 - oli-obk:define_opaque_types6, r=compiler-er…
matthiaskrgr Apr 16, 2024
3ded9ef
Rollup merge of #124007 - RalfJung:miri, r=RalfJung
matthiaskrgr Apr 16, 2024
8e85da4
Rollup merge of #124017 - oli-obk:define_opaque_types8, r=compiler-er…
matthiaskrgr Apr 16, 2024
84e0367
Rollup merge of #124018 - RalfJung:dealloc-memory-kind, r=oli-obk
matthiaskrgr Apr 16, 2024
b03b87d
Rollup merge of #124024 - RalfJung:interpret-comment, r=oli-obk
matthiaskrgr Apr 16, 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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3364,9 +3364,9 @@ dependencies = [

[[package]]
name = "rustc-build-sysroot"
version = "0.4.5"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26170e1d79ea32f7ccec3188dd13cfc1f18c82764a9cbc1071667c0f865a4ea"
checksum = "a9bf37423495cd3a6a9ef8c75fc4566de0d26de0ab75f36f67a426e58df5768c"
dependencies = [
"anyhow",
"rustc_version",
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_const_eval/src/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
/// allocation (because a copy had to be done to adjust things), machine memory will
/// cache the result. (This relies on `AllocMap::get_or` being able to add the
/// owned allocation to the map even when the map is shared.)
///
/// This must only fail if `alloc` contains provenance.
fn adjust_allocation<'b>(
ecx: &InterpCx<'mir, 'tcx, Self>,
id: AllocId,
Expand Down Expand Up @@ -427,6 +425,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
_prov: (AllocId, Self::ProvenanceExtra),
_size: Size,
_align: Align,
_kind: MemoryKind<Self::MemoryKind>,
) -> InterpResult<'tcx> {
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.allocate_raw_ptr(alloc, kind)
}

/// This can fail only if `alloc` contains provenance.
pub fn allocate_raw_ptr(
&mut self,
alloc: Allocation,
Expand Down Expand Up @@ -355,6 +354,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
(alloc_id, prov),
size,
alloc.align,
kind,
)?;

// Don't forget to remember size and align of this now-dead allocation
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ declare_features! (
(unstable, more_qualified_paths, "1.54.0", Some(86935)),
/// Allows the `#[must_not_suspend]` attribute.
(unstable, must_not_suspend, "1.57.0", Some(83310)),
/// Make `mut` not reset the binding mode on edition >= 2024.
(incomplete, mut_preserve_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)),
/// Allows `mut ref` and `mut ref mut` identifier patterns.
(incomplete, mut_ref, "CURRENT_RUSTC_VERSION", Some(123076)),
/// Allows using `#[naked]` on functions.
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_hir_typeck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private

hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty`

hir_typeck_dereferencing_mut_binding = dereferencing `mut` binding
.label = `mut` dereferences the type of this binding
.help = this will change in edition 2024

hir_typeck_expected_default_return_type = expected `()` because of default return type

hir_typeck_expected_return_type = expected `{$expected}` because of return type
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_hir_typeck/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,3 +632,11 @@ pub enum SuggestBoxingForReturnImplTrait {
ends: Vec<Span>,
},
}

#[derive(LintDiagnostic)]
#[diag(hir_typeck_dereferencing_mut_binding)]
pub struct DereferencingMutBinding {
#[label]
#[help]
pub span: Span,
}
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
if let ProbeResult::Match = result
&& self
.at(&ObligationCause::dummy(), self.param_env)
.sup(DefineOpaqueTypes::No, return_ty, xform_ret_ty)
.sup(DefineOpaqueTypes::Yes, return_ty, xform_ret_ty)
.is_err()
{
result = ProbeResult::BadReturnType;
Expand Down
23 changes: 19 additions & 4 deletions compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use rustc_hir::pat_util::EnumerateAndAdjustIterator;
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability, Pat, PatKind};
use rustc_infer::infer;
use rustc_infer::infer::type_variable::TypeVariableOrigin;
use rustc_lint as lint;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::ty::{self, Adt, Ty, TypeVisitableExt};
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
Expand Down Expand Up @@ -629,12 +630,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expected: Ty<'tcx>,
pat_info: PatInfo<'tcx, '_>,
) -> Ty<'tcx> {
let PatInfo { binding_mode: def_bm, top_info: ti, .. } = pat_info;
let PatInfo { binding_mode: BindingAnnotation(def_br, _), top_info: ti, .. } = pat_info;

// Determine the binding mode...
let bm = match ba {
BindingAnnotation(ByRef::No, Mutability::Not) => def_bm,
_ => ba,
BindingAnnotation(ByRef::No, Mutability::Mut)
if !(pat.span.at_least_rust_2024()
&& self.tcx.features().mut_preserve_binding_mode_2024)
&& matches!(def_br, ByRef::Yes(_)) =>
{
// `mut x` resets the binding mode in edition <= 2021.
self.tcx.emit_node_span_lint(
lint::builtin::DEREFERENCING_MUT_BINDING,
pat.hir_id,
pat.span,
errors::DereferencingMutBinding { span: pat.span },
);
BindingAnnotation(ByRef::No, Mutability::Mut)
}
BindingAnnotation(ByRef::No, mutbl) => BindingAnnotation(def_br, mutbl),
BindingAnnotation(ByRef::Yes(_), _) => ba,
};
// ...and store it in a side table:
self.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);
Expand Down Expand Up @@ -743,7 +758,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

// Precondition: pat is a Ref(_) pattern
/// Precondition: pat is a `Ref(_)` pattern
fn borrow_pat_suggestion(&self, err: &mut Diag<'_>, pat: &Pat<'_>) {
let tcx = self.tcx;
if let PatKind::Ref(inner, mutbl) = pat.kind
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
{
let Trace { at, trace } = self;
debug_assert!(at.infcx.next_trait_solver());
let mut fields = at.infcx.combine_fields(trace, at.param_env, DefineOpaqueTypes::No);
let mut fields = at.infcx.combine_fields(trace, at.param_env, DefineOpaqueTypes::Yes);
fields
.equate(StructurallyRelateAliases::Yes)
.relate(a, b)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/context/diagnostics/check_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub(super) fn unexpected_cfg_name(
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#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/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
}
}

Expand Down Expand Up @@ -272,6 +272,6 @@ pub(super) fn unexpected_cfg_value(
if !is_cfg_a_well_know_name {
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
}
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
}
}
37 changes: 37 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ declare_lint_pass! {
DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
DEPRECATED_IN_FUTURE,
DEPRECATED_WHERE_CLAUSE_LOCATION,
DEREFERENCING_MUT_BINDING,
DUPLICATE_MACRO_ATTRIBUTES,
ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
ELIDED_LIFETIMES_IN_PATHS,
Expand Down Expand Up @@ -1627,6 +1628,42 @@ declare_lint! {
"detect mut variables which don't need to be mutable"
}

declare_lint! {
/// The `dereferencing_mut_binding` lint detects a `mut x` pattern that resets the binding mode,
/// as this behavior will change in rust 2024.
///
/// ### Example
///
/// ```rust
/// # #![warn(dereferencing_mut_binding)]
/// let x = Some(123u32);
/// let _y = match &x {
/// Some(mut x) => {
/// x += 1;
/// x
/// }
/// None => 0,
/// };
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// Without the `mut`, `x` would have type `&u32`. Pre-2024, adding `mut` makes `x` have type
/// `u32`, which was deemed surprising. After edition 2024, adding `mut` will not change the
/// type of `x`. This lint warns users of editions before 2024 to update their code.
pub DEREFERENCING_MUT_BINDING,
Allow,
"detects `mut x` bindings that change the type of `x`",
@feature_gate = sym::mut_preserve_binding_mode_2024;
// FIXME uncomment below upon stabilization
/*@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
reference: "123076",
};*/
}

declare_lint! {
/// The `unconditional_recursion` lint detects functions that cannot
/// return without calling themselves.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
opt::flag_s("h", "help", "Display this message"),
opt::multi_s("", "cfg", "Configure the compilation environment.
SPEC supports the syntax `NAME[=\"VALUE\"]`.", "SPEC"),
opt::multi("", "check-cfg", "Provide list of valid cfg options for checking", "SPEC"),
opt::multi_s("", "check-cfg", "Provide list of expected cfgs for checking", "SPEC"),
opt::multi_s(
"L",
"",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl CheckCfg {
// `tests/ui/check-cfg/well-known-values.rs` (in order to test the
// expected values of the new config) and bless the all directory.
//
// Don't forget to update `src/doc/unstable-book/src/compiler-flags/check-cfg.md`
// Don't forget to update `src/doc/rustc/src/check-cfg.md`
// in the unstable book as well!

ins!(sym::debug_assertions, no_values);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ symbols! {
multiple_supertrait_upcastable,
must_not_suspend,
must_use,
mut_preserve_binding_mode_2024,
mut_ref,
naked,
naked_functions,
Expand Down
4 changes: 0 additions & 4 deletions src/bootstrap/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ fn main() {
fn check_version(config: &Config) -> Option<String> {
let mut msg = String::new();

if config.changelog_seen.is_some() {
msg.push_str("WARNING: The use of `changelog-seen` is deprecated. Please refer to `change-id` option in `config.example.toml` instead.\n");
}

let latest_change_id = CONFIG_CHANGE_HISTORY.last().unwrap().change_id;
let warned_id_path = config.out.join("bootstrap").join(".last-warned-change-id");

Expand Down
Loading
Loading