Skip to content

Commit 8c7ad16

Browse files
committed
Auto merge of #109986 - JohnTitor:rollup-3aax38t, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #109909 (Deny `use`ing tool paths) - #109921 (Don't ICE when encountering `dyn*` in statics or consts) - #109922 (Disable `has_thread_local` on OpenHarmony) - #109926 (write threads info into log only when debugging) - #109968 (Add regression test for #80409) - #109969 (Add regression test for #86351) - #109973 (rustdoc: Improve logo display very small screen) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2eaeb1e + 9960e9f commit 8c7ad16

File tree

17 files changed

+135
-16
lines changed

17 files changed

+135
-16
lines changed

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
553553
}
554554

555555
Rvalue::Cast(CastKind::DynStar, _, _) => {
556-
unimplemented!()
556+
// `dyn*` coercion is implemented for CTFE.
557557
}
558558

559559
Rvalue::Cast(_, _, _) => {}

compiler/rustc_log/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
8383
.with_verbose_exit(verbose_entry_exit)
8484
.with_verbose_entry(verbose_entry_exit)
8585
.with_indent_amount(2);
86-
#[cfg(parallel_compiler)]
86+
#[cfg(all(parallel_compiler, debug_assertions))]
8787
let layer = layer.with_thread_ids(true).with_thread_names(true);
8888

8989
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer);

compiler/rustc_resolve/messages.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,9 @@ resolve_expected_found =
207207
resolve_indeterminate =
208208
cannot determine resolution for the visibility
209209
210+
resolve_tool_module_imported =
211+
cannot use a tool module through an import
212+
.note = the tool module imported here
213+
210214
resolve_module_only =
211215
visibility must resolve to a module

compiler/rustc_resolve/src/errors.rs

+9
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,15 @@ pub(crate) struct ExpectedFound {
469469
#[diag(resolve_indeterminate, code = "E0578")]
470470
pub(crate) struct Indeterminate(#[primary_span] pub(crate) Span);
471471

472+
#[derive(Diagnostic)]
473+
#[diag(resolve_tool_module_imported)]
474+
pub(crate) struct ToolModuleImported {
475+
#[primary_span]
476+
pub(crate) span: Span,
477+
#[note]
478+
pub(crate) import: Span,
479+
}
480+
472481
#[derive(Diagnostic)]
473482
#[diag(resolve_module_only)]
474483
pub(crate) struct ModuleOnly(#[primary_span] pub(crate) Span);

compiler/rustc_resolve/src/ident.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::late::{
1717
ConstantHasGenerics, ConstantItemKind, HasGenericParams, PathSource, Rib, RibKind,
1818
};
1919
use crate::macros::{sub_namespace_match, MacroRulesScope};
20-
use crate::{AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize};
20+
use crate::{errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, Determinacy, Finalize};
2121
use crate::{Import, ImportKind, LexicalScopeBinding, Module, ModuleKind, ModuleOrUniformRoot};
2222
use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, PrivacyError, Res};
2323
use crate::{ResolutionError, Resolver, Scope, ScopeSet, Segment, ToNameBinding, Weak};
@@ -1364,7 +1364,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13641364
}
13651365
};
13661366

1367-
let is_last = i == path.len() - 1;
1367+
let is_last = i + 1 == path.len();
13681368
let ns = if is_last { opt_ns.unwrap_or(TypeNS) } else { TypeNS };
13691369
let name = ident.name;
13701370

@@ -1501,16 +1501,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15011501
if let Some(next_module) = binding.module() {
15021502
module = Some(ModuleOrUniformRoot::Module(next_module));
15031503
record_segment_res(self, res);
1504-
} else if res == Res::ToolMod && i + 1 != path.len() {
1504+
} else if res == Res::ToolMod && !is_last && opt_ns.is_some() {
15051505
if binding.is_import() {
1506-
self.tcx
1507-
.sess
1508-
.struct_span_err(
1509-
ident.span,
1510-
"cannot use a tool module through an import",
1511-
)
1512-
.span_note(binding.span, "the tool module imported here")
1513-
.emit();
1506+
self.tcx.sess.emit_err(errors::ToolModuleImported {
1507+
span: ident.span,
1508+
import: binding.span,
1509+
});
15141510
}
15151511
let res = Res::NonMacroAttr(NonMacroAttrKind::Tool);
15161512
return PathResult::NonModule(PartialRes::new(res));

compiler/rustc_target/src/spec/aarch64_unknown_linux_ohos.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub fn target() -> Target {
1818
features: "+reserve-x18".into(),
1919
mcount: "\u{1}_mcount".into(),
2020
force_emulated_tls: true,
21+
has_thread_local: false,
2122
supported_sanitizers: SanitizerSet::ADDRESS
2223
| SanitizerSet::CFI
2324
| SanitizerSet::LEAK

compiler/rustc_target/src/spec/armv7_unknown_linux_ohos.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub fn target() -> Target {
2121
crt_static_default: false,
2222
mcount: "\u{1}mcount".into(),
2323
force_emulated_tls: true,
24+
has_thread_local: false,
2425
..super::linux_musl_base::opts()
2526
},
2627
}

src/librustdoc/html/static/css/rustdoc.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
3. Copy the filenames with updated suffixes from the directory.
77
*/
88

9+
:root {
10+
--nav-sub-mobile-padding: 8px;
11+
}
12+
913
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
1014
@font-face {
1115
font-family: 'Fira Sans';
@@ -1726,7 +1730,7 @@ in main.js
17261730

17271731
.source nav.sub {
17281732
margin: 0;
1729-
padding: 8px;
1733+
padding: var(--nav-sub-mobile-padding);
17301734
}
17311735
}
17321736

@@ -1783,6 +1787,7 @@ in main.js
17831787
.sub-logo-container > img {
17841788
height: 35px;
17851789
width: 35px;
1790+
margin-bottom: var(--nav-sub-mobile-padding);
17861791
}
17871792
}
17881793

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ fn init_logging() {
203203
.with_verbose_exit(true)
204204
.with_verbose_entry(true)
205205
.with_indent_amount(2);
206-
#[cfg(parallel_compiler)]
206+
#[cfg(all(parallel_compiler, debug_assertions))]
207207
let layer = layer.with_thread_ids(true).with_thread_names(true);
208208

209209
use tracing_subscriber::layer::SubscriberExt;

tests/rustdoc-gui/huge-logo.goml

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ size: (1280, 1024)
1818
assert-property: (".sub-logo-container", {"offsetWidth": "60", "offsetHeight": 60})
1919

2020
size: (400, 600)
21-
assert-property: (".sub-logo-container", {"offsetWidth": "35", "offsetHeight": 35})
21+
// 43 because 35px + 8px of margin
22+
assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"})
23+
assert-property: (".sub-logo-container", {"offsetWidth": "35", "offsetHeight": 43})

tests/rustdoc-gui/source-code-page.goml

+5
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,8 @@ call-function: ("check-sidebar-dir-entry", {
216216
"x": 0,
217217
"y": |source_sidebar_title_y| + |source_sidebar_title_height| + 6,
218218
})
219+
220+
// Now we check that the logo has a bottom margin so it's not stuck to the search input.
221+
assert-css: (".sub-logo-container > img", {"margin-bottom": "8px"})
222+
store-property: (logo_height, ".sub-logo-container", "clientHeight")
223+
assert-position: (".search-form", {"y": |logo_height| + 8})

tests/ui/const_prop/issue-86351.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags: --crate-type=lib -Zmir-opt-level=2
2+
// build-pass
3+
// ^-- Must be build-pass, because check-pass will not run const prop.
4+
5+
pub trait TestTrait {
6+
type MyType;
7+
fn func() -> Option<Self>
8+
where
9+
Self: Sized;
10+
}
11+
12+
impl<T> dyn TestTrait<MyType = T>
13+
where
14+
Self: Sized,
15+
{
16+
pub fn other_func() -> Option<Self> {
17+
match Self::func() {
18+
Some(me) => Some(me),
19+
None => None,
20+
}
21+
}
22+
}

tests/ui/dyn-star/const-and-static.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
3+
#![feature(dyn_star)]
4+
//~^ WARN the feature `dyn_star` is incomplete
5+
6+
const C: dyn* Send + Sync = &();
7+
8+
static S: dyn* Send + Sync = &();
9+
10+
fn main() {}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/const-and-static.rs:3:12
3+
|
4+
LL | #![feature(dyn_star)]
5+
| ^^^^^^^^
6+
|
7+
= note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

tests/ui/inference/issue-80409.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// check-pass
2+
3+
#![allow(unreachable_code, unused)]
4+
5+
use std::marker::PhantomData;
6+
7+
struct FsmBuilder<TFsm> {
8+
_fsm: PhantomData<TFsm>,
9+
}
10+
11+
impl<TFsm> FsmBuilder<TFsm> {
12+
fn state(&mut self) -> FsmStateBuilder<TFsm> {
13+
todo!()
14+
}
15+
}
16+
17+
struct FsmStateBuilder<TFsm> {
18+
_state: PhantomData<TFsm>,
19+
}
20+
21+
impl<TFsm> FsmStateBuilder<TFsm> {
22+
fn on_entry<TAction: Fn(&mut StateContext<'_, TFsm>)>(&self, _action: TAction) {}
23+
}
24+
25+
trait Fsm {
26+
type Context;
27+
}
28+
29+
struct StateContext<'a, TFsm: Fsm> {
30+
context: &'a mut TFsm::Context,
31+
}
32+
33+
fn main() {
34+
let mut builder: FsmBuilder<usize> = todo!();
35+
builder.state().on_entry(|_| {});
36+
}

tests/ui/resolve/tool-import.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// edition: 2018
2+
3+
use clippy::time::Instant;
4+
//~^ `clippy` is a tool module
5+
6+
fn main() {
7+
Instant::now();
8+
}

tests/ui/resolve/tool-import.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0433]: failed to resolve: `clippy` is a tool module, not a module
2+
--> $DIR/tool-import.rs:3:5
3+
|
4+
LL | use clippy::time::Instant;
5+
| ^^^^^^ `clippy` is a tool module, not a module
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0433`.

0 commit comments

Comments
 (0)