Skip to content

Commit db492ec

Browse files
committed
Auto merge of #83432 - Dylan-DPC:rollup-4z5f6al, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #83051 (Sidebar trait items order) - #83313 (Only enable assert_dep_graph when query-dep-graph is enabled.) - #83353 (Add internal io::Error::new_const to avoid allocations.) - #83391 (Allow not emitting `uwtable` on Android) - #83392 (Change `-W help` to display edition level.) - #83393 (Codeblock tooltip position) - #83399 (rustdoc: Record crate name instead of using `None`) - #83405 (Slight visual improvements to warning boxes in the docs) - #83415 (Remove unnecessary `Option` wrapping around `Crate.module`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 673d0db + 5c0d880 commit db492ec

Some content is hidden

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

77 files changed

+522
-295
lines changed

compiler/rustc_driver/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,12 @@ Available lint options:
895895
let print_lints = |lints: Vec<&Lint>| {
896896
for lint in lints {
897897
let name = lint.name_lower().replace("_", "-");
898-
println!(" {} {:7.7} {}", padded(&name), lint.default_level.as_str(), lint.desc);
898+
println!(
899+
" {} {:7.7} {}",
900+
padded(&name),
901+
lint.default_level(sess.edition()).as_str(),
902+
lint.desc
903+
);
899904
}
900905
println!("\n");
901906
};

compiler/rustc_incremental/src/assert_dep_graph.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
5757
dump_graph(tcx);
5858
}
5959

60+
if !tcx.sess.opts.debugging_opts.query_dep_graph {
61+
return;
62+
}
63+
6064
// if the `rustc_attrs` feature is not enabled, then the
6165
// attributes we are interested in cannot be present anyway, so
6266
// skip the walk.

compiler/rustc_incremental/src/persist/dirty_clean.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ impl Assertion {
148148
}
149149

150150
pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
151+
if !tcx.sess.opts.debugging_opts.query_dep_graph {
152+
return;
153+
}
154+
151155
// can't add `#[rustc_dirty]` etc without opting in to this feature
152156
if !tcx.features().rustc_attrs {
153157
return;

compiler/rustc_passes/src/check_attr.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ impl CheckAttrVisitor<'tcx> {
9999
self.check_naked(hir_id, attr, span, target)
100100
} else if self.tcx.sess.check_name(attr, sym::rustc_legacy_const_generics) {
101101
self.check_rustc_legacy_const_generics(&attr, span, target, item)
102+
} else if self.tcx.sess.check_name(attr, sym::rustc_clean)
103+
|| self.tcx.sess.check_name(attr, sym::rustc_dirty)
104+
|| self.tcx.sess.check_name(attr, sym::rustc_if_this_changed)
105+
|| self.tcx.sess.check_name(attr, sym::rustc_then_this_would_need)
106+
{
107+
self.check_rustc_dirty_clean(&attr)
102108
} else {
103109
// lint-only checks
104110
if self.tcx.sess.check_name(attr, sym::cold) {
@@ -1012,6 +1018,20 @@ impl CheckAttrVisitor<'tcx> {
10121018
}
10131019
}
10141020

1021+
/// Checks that the dep-graph debugging attributes are only present when the query-dep-graph
1022+
/// option is passed to the compiler.
1023+
fn check_rustc_dirty_clean(&self, attr: &Attribute) -> bool {
1024+
if self.tcx.sess.opts.debugging_opts.query_dep_graph {
1025+
true
1026+
} else {
1027+
self.tcx
1028+
.sess
1029+
.struct_span_err(attr.span, "attribute requires -Z query-dep-graph to be enabled")
1030+
.emit();
1031+
false
1032+
}
1033+
}
1034+
10151035
/// Checks if `#[link_section]` is applied to a function or static.
10161036
fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
10171037
match target {

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ impl Session {
863863
} else if self.target.requires_uwtable {
864864
true
865865
} else {
866-
self.opts.cg.force_unwind_tables.unwrap_or(false)
866+
self.opts.cg.force_unwind_tables.unwrap_or(self.target.default_uwtable)
867867
}
868868
}
869869

compiler/rustc_target/src/spec/android_base.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ pub fn opts() -> TargetOptions {
1212
base.dwarf_version = Some(2);
1313
base.position_independent_executables = true;
1414
base.has_elf_tls = false;
15-
base.requires_uwtable = true;
15+
// This is for backward compatibility, see https://github.com/rust-lang/rust/issues/49867
16+
// for context. (At that time, there was no `-C force-unwind-tables`, so the only solution
17+
// was to always emit `uwtable`).
18+
base.default_uwtable = true;
1619
base.crt_static_respected = false;
1720
base
1821
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,10 @@ pub struct TargetOptions {
11111111
/// unwinders.
11121112
pub requires_uwtable: bool,
11131113

1114+
/// Whether or not to emit `uwtable` attributes on functions if `-C force-unwind-tables`
1115+
/// is not specified and `uwtable` is not required on this target.
1116+
pub default_uwtable: bool,
1117+
11141118
/// Whether or not SIMD types are passed by reference in the Rust ABI,
11151119
/// typically required if a target can be compiled with a mixed set of
11161120
/// target features. This is `true` by default, and `false` for targets like
@@ -1248,6 +1252,7 @@ impl Default for TargetOptions {
12481252
default_hidden_visibility: false,
12491253
emit_debug_gdb_scripts: true,
12501254
requires_uwtable: false,
1255+
default_uwtable: false,
12511256
simd_types_indirect: true,
12521257
limit_rdylib_exports: true,
12531258
override_export_symbols: None,
@@ -1711,6 +1716,7 @@ impl Target {
17111716
key!(default_hidden_visibility, bool);
17121717
key!(emit_debug_gdb_scripts, bool);
17131718
key!(requires_uwtable, bool);
1719+
key!(default_uwtable, bool);
17141720
key!(simd_types_indirect, bool);
17151721
key!(limit_rdylib_exports, bool);
17161722
key!(override_export_symbols, opt_list);
@@ -1947,6 +1953,7 @@ impl ToJson for Target {
19471953
target_option_val!(default_hidden_visibility);
19481954
target_option_val!(emit_debug_gdb_scripts);
19491955
target_option_val!(requires_uwtable);
1956+
target_option_val!(default_uwtable);
19501957
target_option_val!(simd_types_indirect);
19511958
target_option_val!(limit_rdylib_exports);
19521959
target_option_val!(override_export_symbols);

library/std/src/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ impl fmt::Display for NulError {
10361036
impl From<NulError> for io::Error {
10371037
/// Converts a [`NulError`] into a [`io::Error`].
10381038
fn from(_: NulError) -> io::Error {
1039-
io::Error::new(io::ErrorKind::InvalidInput, "data provided contains a nul byte")
1039+
io::Error::new_const(io::ErrorKind::InvalidInput, &"data provided contains a nul byte")
10401040
}
10411041
}
10421042

library/std/src/fs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2188,7 +2188,10 @@ impl DirBuilder {
21882188
match path.parent() {
21892189
Some(p) => self.create_dir_all(p)?,
21902190
None => {
2191-
return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree"));
2191+
return Err(io::Error::new_const(
2192+
io::ErrorKind::Other,
2193+
&"failed to create whole tree",
2194+
));
21922195
}
21932196
}
21942197
match self.inner.mkdir(path) {

library/std/src/io/buffered/bufwriter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ impl<W: Write> BufWriter<W> {
164164

165165
match r {
166166
Ok(0) => {
167-
return Err(Error::new(
167+
return Err(Error::new_const(
168168
ErrorKind::WriteZero,
169-
"failed to write the buffered data",
169+
&"failed to write the buffered data",
170170
));
171171
}
172172
Ok(n) => guard.consume(n),

0 commit comments

Comments
 (0)