Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e3051d8

Browse files
committed
Auto merge of rust-lang#78028 - JohnTitor:rollup-jt3hikb, r=JohnTitor
Rollup of 10 pull requests Successful merges: - rust-lang#75209 (Suggest imports of unresolved macros) - rust-lang#77547 (stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union') - rust-lang#77827 (Don't link to nightly primitives on stable channel) - rust-lang#77855 (resolve: further improvements to "try using the enum's variant" diagnostic) - rust-lang#77900 (Use fdatasync for File::sync_data on more OSes) - rust-lang#77925 (Suggest minimal subset features in `incomplete_features` lint) - rust-lang#77971 (Deny broken intra-doc links in linkchecker) - rust-lang#77991 (Bump backtrace-rs) - rust-lang#77992 (instrument-coverage: try our best to not ICE) - rust-lang#78013 (Fix sidebar scroll on mobile devices) Failed merges: r? `@ghost`
2 parents 5a51185 + 001fcd9 commit e3051d8

File tree

154 files changed

+667
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+667
-275
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,10 @@ dependencies = [
17441744
[[package]]
17451745
name = "linkchecker"
17461746
version = "0.1.0"
1747+
dependencies = [
1748+
"once_cell",
1749+
"regex",
1750+
]
17471751

17481752
[[package]]
17491753
name = "linked-hash-map"

compiler/rustc_error_codes/src/error_codes/E0660.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ llvm_asm!("nop" "nop");
99
Considering that this would be a long explanation, we instead recommend you
1010
take a look at the [`llvm_asm`] chapter of the Unstable book:
1111

12-
[llvm_asm]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html
12+
[`llvm_asm`]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html

compiler/rustc_error_codes/src/error_codes/E0661.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ llvm_asm!("nop" : "r"(a));
1010
Considering that this would be a long explanation, we instead recommend you
1111
take a look at the [`llvm_asm`] chapter of the Unstable book:
1212

13-
[llvm_asm]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html
13+
[`llvm_asm`]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html

compiler/rustc_error_codes/src/error_codes/E0662.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ llvm_asm!("xor %eax, %eax"
1313
Considering that this would be a long explanation, we instead recommend you
1414
take a look at the [`llvm_asm`] chapter of the Unstable book:
1515

16-
[llvm_asm]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html
16+
[`llvm_asm`]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html

compiler/rustc_error_codes/src/error_codes/E0663.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ llvm_asm!("xor %eax, %eax"
1313
Considering that this would be a long explanation, we instead recommend you
1414
take a look at the [`llvm_asm`] chapter of the Unstable book:
1515

16-
[llvm_asm]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html
16+
[`llvm_asm`]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html

compiler/rustc_error_codes/src/error_codes/E0664.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ llvm_asm!("mov $$0x200, %eax"
1313
Considering that this would be a long explanation, we instead recommend you
1414
take a look at the [`llvm_asm`] chapter of the Unstable book:
1515

16-
[llvm_asm]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html
16+
[`llvm_asm`]: https://doc.rust-lang.org/stable/unstable-book/library-features/llvm-asm.html

compiler/rustc_lint/src/builtin.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,12 +2288,20 @@ impl EarlyLintPass for IncompleteFeatures {
22882288
n, n,
22892289
));
22902290
}
2291+
if HAS_MIN_FEATURES.contains(&name) {
2292+
builder.help(&format!(
2293+
"consider using `min_{}` instead, which is more stable and complete",
2294+
name,
2295+
));
2296+
}
22912297
builder.emit();
22922298
})
22932299
});
22942300
}
22952301
}
22962302

2303+
const HAS_MIN_FEATURES: &[Symbol] = &[sym::const_generics, sym::specialization];
2304+
22972305
declare_lint! {
22982306
/// The `invalid_value` lint detects creating a value that is not valid,
22992307
/// such as a NULL reference.

compiler/rustc_mir/src/transform/instrument_coverage.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ use rustc_middle::ty::query::Providers;
2222
use rustc_middle::ty::TyCtxt;
2323
use rustc_span::def_id::DefId;
2424
use rustc_span::source_map::original_sp;
25-
use rustc_span::{
26-
BytePos, CharPos, FileName, Pos, RealFileName, SourceFile, Span, Symbol, SyntaxContext,
27-
};
25+
use rustc_span::{BytePos, CharPos, Pos, SourceFile, Span, Symbol, SyntaxContext};
2826

2927
use std::cmp::Ordering;
3028

@@ -549,13 +547,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
549547
let mir_body = &self.mir_body;
550548
let body_span = self.body_span();
551549
let source_file = source_map.lookup_source_file(body_span.lo());
552-
let file_name = match &source_file.name {
553-
FileName::Real(RealFileName::Named(path)) => Symbol::intern(&path.to_string_lossy()),
554-
_ => bug!(
555-
"source_file.name should be a RealFileName, but it was: {:?}",
556-
source_file.name
557-
),
558-
};
550+
let file_name = Symbol::intern(&source_file.name.to_string());
559551

560552
debug!("instrumenting {:?}, span: {}", def_id, source_map.span_to_string(body_span));
561553

compiler/rustc_passes/src/stability.rs

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ use rustc_hir::{Generics, HirId, Item, StructField, TraitRef, Ty, TyKind, Varian
1313
use rustc_middle::hir::map::Map;
1414
use rustc_middle::middle::privacy::AccessLevels;
1515
use rustc_middle::middle::stability::{DeprecationEntry, Index};
16-
use rustc_middle::ty::query::Providers;
17-
use rustc_middle::ty::TyCtxt;
16+
use rustc_middle::ty::{self, query::Providers, TyCtxt};
1817
use rustc_session::lint;
1918
use rustc_session::lint::builtin::INEFFECTIVE_UNSTABLE_TRAIT_IMPL;
2019
use rustc_session::parse::feature_err;
2120
use rustc_session::Session;
2221
use rustc_span::symbol::{sym, Symbol};
23-
use rustc_span::Span;
24-
use rustc_trait_selection::traits::misc::can_type_implement_copy;
22+
use rustc_span::{Span, DUMMY_SP};
2523

2624
use std::cmp::Ordering;
2725
use std::mem::replace;
@@ -711,27 +709,35 @@ impl Visitor<'tcx> for Checker<'tcx> {
711709
// so semi-randomly perform it here in stability.rs
712710
hir::ItemKind::Union(..) if !self.tcx.features().untagged_unions => {
713711
let def_id = self.tcx.hir().local_def_id(item.hir_id);
714-
let adt_def = self.tcx.adt_def(def_id);
715712
let ty = self.tcx.type_of(def_id);
713+
let (adt_def, substs) = match ty.kind() {
714+
ty::Adt(adt_def, substs) => (adt_def, substs),
715+
_ => bug!(),
716+
};
716717

717-
if adt_def.has_dtor(self.tcx) {
718-
feature_err(
719-
&self.tcx.sess.parse_sess,
720-
sym::untagged_unions,
721-
item.span,
722-
"unions with `Drop` implementations are unstable",
723-
)
724-
.emit();
725-
} else {
726-
let param_env = self.tcx.param_env(def_id);
727-
if can_type_implement_copy(self.tcx, param_env, ty).is_err() {
728-
feature_err(
729-
&self.tcx.sess.parse_sess,
730-
sym::untagged_unions,
731-
item.span,
732-
"unions with non-`Copy` fields are unstable",
733-
)
734-
.emit();
718+
// Non-`Copy` fields are unstable, except for `ManuallyDrop`.
719+
let param_env = self.tcx.param_env(def_id);
720+
for field in &adt_def.non_enum_variant().fields {
721+
let field_ty = field.ty(self.tcx, substs);
722+
if !field_ty.ty_adt_def().map_or(false, |adt_def| adt_def.is_manually_drop())
723+
&& !field_ty.is_copy_modulo_regions(self.tcx.at(DUMMY_SP), param_env)
724+
{
725+
if field_ty.needs_drop(self.tcx, param_env) {
726+
// Avoid duplicate error: This will error later anyway because fields
727+
// that need drop are not allowed.
728+
self.tcx.sess.delay_span_bug(
729+
item.span,
730+
"union should have been rejected due to potentially dropping field",
731+
);
732+
} else {
733+
feature_err(
734+
&self.tcx.sess.parse_sess,
735+
sym::untagged_unions,
736+
self.tcx.def_span(field.did),
737+
"unions with non-`Copy` fields other than `ManuallyDrop<T>` are unstable",
738+
)
739+
.emit();
740+
}
735741
}
736742
}
737743
}

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,17 @@ impl<'a> Resolver<'a> {
922922
);
923923
self.add_typo_suggestion(err, suggestion, ident.span);
924924

925+
let import_suggestions = self.lookup_import_candidates(
926+
ident,
927+
Namespace::MacroNS,
928+
parent_scope,
929+
|res| match res {
930+
Res::Def(DefKind::Macro(MacroKind::Bang), _) => true,
931+
_ => false,
932+
},
933+
);
934+
show_candidates(err, None, &import_suggestions, false, true);
935+
925936
if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
926937
let msg = format!("unsafe traits like `{}` should be implemented explicitly", ident);
927938
err.span_note(ident.span, &msg);

0 commit comments

Comments
 (0)