Skip to content

Rollup of 7 pull requests #134480

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

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
30f5a03
Move `tests/ui/associated-path-shl.rs` to `tests/ui/parser/`
jieyouxu Dec 17, 2024
4ca2d9f
Move `tests/ui/attempted-access-non-fatal.rs` to `tests/ui/typeck/`
jieyouxu Dec 17, 2024
0fc6be7
Adjust `tests/ui/attr-bad-crate-attr.rs`
jieyouxu Dec 17, 2024
88f8bf7
Adjust `tests/ui/attr-shebang.rs`
jieyouxu Dec 17, 2024
7424b89
Adjust `tests/ui/attr-usage-inline.rs`
jieyouxu Dec 17, 2024
836a0e0
Adjust `tests/ui/attrs-resolution-errors.rs`
jieyouxu Dec 17, 2024
47ad3b2
Adjust `tests/ui/attrs-resolution.rs`
jieyouxu Dec 17, 2024
d033809
Fix intra doc links not generated inside footnote definitions
GuillaumeGomez Dec 17, 2024
a01de76
Add regression test for #132208
GuillaumeGomez Dec 17, 2024
bfd02d8
Improve testing coverage for `#[diagnostic::do_not_recommend]`
weiznich Oct 22, 2024
ecb6fd8
Check `#[diagnostic::do_not_recommend]` for arguments
weiznich Oct 23, 2024
dd31713
Stabilize `#[diagnostic::do_not_recommend]`
weiznich Oct 23, 2024
ad29947
Also warn against `#[diagnostic::do_not_recommend]` on plain impls
weiznich Oct 25, 2024
b103347
Remove a redundant write_ty call
oli-obk Dec 12, 2024
45920d2
Remove redundant tainting. We already taint the first time we set the…
oli-obk Dec 12, 2024
38ce731
canonicalizer: keep 'static in the param_env
lcnr Nov 26, 2024
6734a04
chore: fix some typos
acceptacross Dec 18, 2024
d5a0c5c
update new solver candidate assembly
lcnr Nov 26, 2024
f0ae48d
add tests
lcnr Nov 29, 2024
5fa4b09
resolve FIXME
lcnr Dec 18, 2024
661b8f5
Forbid overwriting types in typeck
oli-obk Dec 12, 2024
b0d923c
move lint_unused_mut into subfn
lcnr Dec 18, 2024
9ef080d
Rollup merge of #132056 - weiznich:diagnostic_do_not_recommend_final_…
matthiaskrgr Dec 18, 2024
844e435
Rollup merge of #133643 - lcnr:merge-candidates, r=compiler-errors
matthiaskrgr Dec 18, 2024
a19ad5e
Rollup merge of #134418 - jieyouxu:ui-cleanup-3, r=compiler-errors
matthiaskrgr Dec 18, 2024
47614ab
Rollup merge of #134432 - GuillaumeGomez:intra-doc-in-footnotes, r=no…
matthiaskrgr Dec 18, 2024
19f6ad0
Rollup merge of #134473 - acceptacross:master, r=compiler-errors
matthiaskrgr Dec 18, 2024
750dea9
Rollup merge of #134474 - oli-obk:push-yomnkntvzlxw, r=compiler-errors
matthiaskrgr Dec 18, 2024
e01e132
Rollup merge of #134477 - lcnr:move-lint-into-subfn, r=lqd
matthiaskrgr Dec 18, 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
62 changes: 33 additions & 29 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,35 +334,7 @@ fn do_mir_borrowck<'tcx>(
mbcx.gather_used_muts(temporary_used_locals, unused_mut_locals);

debug!("mbcx.used_mut: {:?}", mbcx.used_mut);
let used_mut = std::mem::take(&mut mbcx.used_mut);
for local in mbcx.body.mut_vars_and_args_iter().filter(|local| !used_mut.contains(local)) {
let local_decl = &mbcx.body.local_decls[local];
let lint_root = match &mbcx.body.source_scopes[local_decl.source_info.scope].local_data {
ClearCrossCrate::Set(data) => data.lint_root,
_ => continue,
};

// Skip over locals that begin with an underscore or have no name
match mbcx.local_names[local] {
Some(name) => {
if name.as_str().starts_with('_') {
continue;
}
}
None => continue,
}

let span = local_decl.source_info.span;
if span.desugaring_kind().is_some() {
// If the `mut` arises as part of a desugaring, we should ignore it.
continue;
}

let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);

tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
}

mbcx.lint_unused_mut();
let tainted_by_errors = mbcx.emit_errors();

let result = BorrowCheckResult {
Expand Down Expand Up @@ -2390,6 +2362,38 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
// `BasicBlocks` computes dominators on-demand and caches them.
self.body.basic_blocks.dominators()
}

fn lint_unused_mut(&self) {
let tcx = self.infcx.tcx;
let body = self.body;
for local in body.mut_vars_and_args_iter().filter(|local| !self.used_mut.contains(local)) {
let local_decl = &body.local_decls[local];
let lint_root = match &body.source_scopes[local_decl.source_info.scope].local_data {
ClearCrossCrate::Set(data) => data.lint_root,
_ => continue,
};

// Skip over locals that begin with an underscore or have no name
match self.local_names[local] {
Some(name) => {
if name.as_str().starts_with('_') {
continue;
}
}
None => continue,
}

let span = local_decl.source_info.span;
if span.desugaring_kind().is_some() {
// If the `mut` arises as part of a desugaring, we should ignore it.
continue;
}

let mut_span = tcx.sess.source_map().span_until_non_whitespace(span);

tcx.emit_node_span_lint(UNUSED_MUT, lint_root, span, VarNeedNotMut { span: mut_span })
}
}
}

mod diags {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/compiler_builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ffi::c_int;
#[cfg(feature = "jit")]
use std::ffi::c_void;

// FIXME replace with core::ffi::c_size_t once stablized
// FIXME replace with core::ffi::c_size_t once stabilized
#[allow(non_camel_case_types)]
#[cfg(feature = "jit")]
type size_t = usize;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
sym::log2f64 => "log2",
sym::fmaf32 => "fmaf",
sym::fmaf64 => "fma",
// FIXME: calling `fma` from libc without FMA target feature uses expensive sofware emulation
// FIXME: calling `fma` from libc without FMA target feature uses expensive software emulation
sym::fmuladdf32 => "fmaf", // TODO: use gcc intrinsic analogous to llvm.fmuladd.f32
sym::fmuladdf64 => "fma", // TODO: use gcc intrinsic analogous to llvm.fmuladd.f64
sym::fabsf32 => "fabsf",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2523,7 +2523,7 @@ impl HumanEmitter {
buffer.puts(*row_num, max_line_num_len + 1, "+ ", Style::Addition);
}
[] => {
// FIXME: needed? Doesn't get excercised in any test.
// FIXME: needed? Doesn't get exercised in any test.
self.draw_col_separator_no_space(buffer, *row_num, max_line_num_len + 1);
}
_ => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/markdown/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ fn parse_with_end_pat<'a>(
None
}

/// Resturn `(match, residual)` to end of line. The EOL is returned with the
/// Return `(match, residual)` to end of line. The EOL is returned with the
/// residual.
fn parse_to_newline(buf: &[u8]) -> (&[u8], &[u8]) {
buf.iter().position(|ch| *ch == b'\n').map_or((buf, &[]), |pos| buf.split_at(pos))
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ declare_features! (
(accepted, destructuring_assignment, "1.59.0", Some(71126)),
/// Allows using the `#[diagnostic]` attribute tool namespace
(accepted, diagnostic_namespace, "1.78.0", Some(111996)),
/// Controls errors in trait implementations.
(accepted, do_not_recommend, "CURRENT_RUSTC_VERSION", Some(51992)),
/// Allows `#[doc(alias = "...")]`.
(accepted, doc_alias, "1.48.0", Some(50146)),
/// Allows `..` in tuple (struct) patterns.
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,10 +1187,9 @@ pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashMap<Symbol, &BuiltinAttribute>>
map
});

pub fn is_stable_diagnostic_attribute(sym: Symbol, features: &Features) -> bool {
pub fn is_stable_diagnostic_attribute(sym: Symbol, _features: &Features) -> bool {
match sym {
sym::on_unimplemented => true,
sym::do_not_recommend => features.do_not_recommend(),
sym::on_unimplemented | sym::do_not_recommend => true,
_ => false,
}
}
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,6 @@ declare_features! (
(unstable, deprecated_suggestion, "1.61.0", Some(94785)),
/// Allows deref patterns.
(incomplete, deref_patterns, "1.79.0", Some(87121)),
/// Controls errors in trait implementations.
(unstable, do_not_recommend, "1.67.0", Some(51992)),
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
(unstable, doc_auto_cfg, "1.58.0", Some(43781)),
/// Allows `#[doc(cfg(...))]`.
Expand Down
26 changes: 14 additions & 12 deletions compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
debug!("write_ty({:?}, {:?}) in fcx {}", id, self.resolve_vars_if_possible(ty), self.tag());
let mut typeck = self.typeck_results.borrow_mut();
let mut node_ty = typeck.node_types_mut();
if let Some(ty) = node_ty.get(id)
&& let Err(e) = ty.error_reported()
{
// Do not overwrite nodes that were already marked as `{type error}`. This allows us to
// silence unnecessary errors from obligations that were set earlier than a type error
// was produced, but that is overwritten by later analysis. This happens in particular
// for `Sized` obligations introduced in gather_locals. (#117846)
self.set_tainted_by_errors(e);
return;
}

node_ty.insert(id, ty);
if let Some(prev) = node_ty.insert(id, ty) {
if prev.references_error() {
node_ty.insert(id, prev);
} else if !ty.references_error() {
// Could change this to a bug, but there's lots of diagnostic code re-lowering
// or re-typechecking nodes that were already typecked.
// Lots of that diagnostics code relies on subtle effects of re-lowering, so we'll
// let it keep doing that and just ensure that compilation won't succeed.
self.dcx().span_delayed_bug(
self.tcx.hir().span(id),
format!("`{prev}` overridden by `{ty}` for {id:?} in {:?}", self.body_id),
);
}
}

if let Err(e) = ty.error_reported() {
self.set_tainted_by_errors(e);
Expand Down Expand Up @@ -1104,7 +1107,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Res::Local(hid) = res {
let ty = self.local_ty(span, hid);
let ty = self.normalize(span, ty);
self.write_ty(hir_id, ty);
return (ty, res);
}

Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,10 +1750,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

pub(in super::super) fn check_decl(&self, decl: Declaration<'tcx>) {
pub(in super::super) fn check_decl(&self, decl: Declaration<'tcx>) -> Ty<'tcx> {
// Determine and write the type which we'll check the pattern against.
let decl_ty = self.local_ty(decl.span, decl.hir_id);
self.write_ty(decl.hir_id, decl_ty);

// Type check the initializer.
if let Some(ref init) = decl.init {
Expand Down Expand Up @@ -1785,11 +1784,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
self.diverges.set(previous_diverges);
}
decl_ty
}

/// Type check a `let` statement.
fn check_decl_local(&self, local: &'tcx hir::LetStmt<'tcx>) {
self.check_decl(local.into());
let ty = self.check_decl(local.into());
self.write_ty(local.hir_id, ty);
if local.pat.is_never_pattern() {
self.diverges.set(Diverges::Always {
span: local.pat.span,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ pub struct ParamEnv<'tcx> {
}

impl<'tcx> rustc_type_ir::inherent::ParamEnv<TyCtxt<'tcx>> for ParamEnv<'tcx> {
fn caller_bounds(self) -> impl IntoIterator<Item = ty::Clause<'tcx>> {
fn caller_bounds(self) -> impl inherent::SliceLike<Item = ty::Clause<'tcx>> {
self.caller_bounds()
}
}
Expand Down
Loading
Loading