Skip to content

Commit e568261

Browse files
committed
Auto merge of #99849 - Dylan-DPC:rollup-1yfpplw, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #99714 (Fix regression introduced with #99383) - #99723 (Allow using stable os::fd::raw items through unstable os::wasi module) - #99810 (Fix settings slider on small width screens) - #99837 (Avoid `Symbol` to `String` conversions) - #99846 (Refactor `UnresolvedImportError`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 05e678c + 71b0e95 commit e568261

File tree

14 files changed

+88
-43
lines changed

14 files changed

+88
-43
lines changed

compiler/rustc_expand/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn get_features(
129129
.span_suggestion(
130130
mi.span(),
131131
"expected just one word",
132-
format!("{}", ident.name),
132+
ident.name,
133133
Applicability::MaybeIncorrect,
134134
)
135135
.emit();

compiler/rustc_parse/src/parser/item.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,6 @@ impl<'a> Parser<'a> {
16771677
}
16781678

16791679
/// Is this a possibly malformed start of a `macro_rules! foo` item definition?
1680-
16811680
fn is_macro_rules_item(&mut self) -> IsMacroRulesItem {
16821681
if self.check_keyword(kw::MacroRules) {
16831682
let macro_rules_span = self.token.span;

compiler/rustc_resolve/src/diagnostics.rs

+14-17
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
20232023
span: Span,
20242024
mut path: Vec<Segment>,
20252025
parent_scope: &ParentScope<'b>,
2026-
) -> Option<(Vec<Segment>, Vec<String>)> {
2026+
) -> Option<(Vec<Segment>, Option<String>)> {
20272027
debug!("make_path_suggestion: span={:?} path={:?}", span, path);
20282028

20292029
match (path.get(0), path.get(1)) {
@@ -2058,12 +2058,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
20582058
&mut self,
20592059
mut path: Vec<Segment>,
20602060
parent_scope: &ParentScope<'b>,
2061-
) -> Option<(Vec<Segment>, Vec<String>)> {
2061+
) -> Option<(Vec<Segment>, Option<String>)> {
20622062
// Replace first ident with `self` and check if that is valid.
20632063
path[0].ident.name = kw::SelfLower;
20642064
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
20652065
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
2066-
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
2066+
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
20672067
}
20682068

20692069
/// Suggests a missing `crate::` if that resolves to an correct module.
@@ -2077,20 +2077,20 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
20772077
&mut self,
20782078
mut path: Vec<Segment>,
20792079
parent_scope: &ParentScope<'b>,
2080-
) -> Option<(Vec<Segment>, Vec<String>)> {
2080+
) -> Option<(Vec<Segment>, Option<String>)> {
20812081
// Replace first ident with `crate` and check if that is valid.
20822082
path[0].ident.name = kw::Crate;
20832083
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
20842084
debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result);
20852085
if let PathResult::Module(..) = result {
20862086
Some((
20872087
path,
2088-
vec![
2088+
Some(
20892089
"`use` statements changed in Rust 2018; read more at \
20902090
<https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-\
20912091
clarity.html>"
20922092
.to_string(),
2093-
],
2093+
),
20942094
))
20952095
} else {
20962096
None
@@ -2108,12 +2108,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
21082108
&mut self,
21092109
mut path: Vec<Segment>,
21102110
parent_scope: &ParentScope<'b>,
2111-
) -> Option<(Vec<Segment>, Vec<String>)> {
2111+
) -> Option<(Vec<Segment>, Option<String>)> {
21122112
// Replace first ident with `crate` and check if that is valid.
21132113
path[0].ident.name = kw::Super;
21142114
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
21152115
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result);
2116-
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
2116+
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
21172117
}
21182118

21192119
/// Suggests a missing external crate name if that resolves to an correct module.
@@ -2130,7 +2130,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
21302130
&mut self,
21312131
mut path: Vec<Segment>,
21322132
parent_scope: &ParentScope<'b>,
2133-
) -> Option<(Vec<Segment>, Vec<String>)> {
2133+
) -> Option<(Vec<Segment>, Option<String>)> {
21342134
if path[1].ident.span.rust_2015() {
21352135
return None;
21362136
}
@@ -2151,7 +2151,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
21512151
name, path, result
21522152
);
21532153
if let PathResult::Module(..) = result {
2154-
return Some((path, Vec::new()));
2154+
return Some((path, None));
21552155
}
21562156
}
21572157

@@ -2175,7 +2175,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
21752175
import: &'b Import<'b>,
21762176
module: ModuleOrUniformRoot<'b>,
21772177
ident: Ident,
2178-
) -> Option<(Option<Suggestion>, Vec<String>)> {
2178+
) -> Option<(Option<Suggestion>, Option<String>)> {
21792179
let ModuleOrUniformRoot::Module(mut crate_module) = module else {
21802180
return None;
21812181
};
@@ -2287,12 +2287,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
22872287
String::from("a macro with this name exists at the root of the crate"),
22882288
Applicability::MaybeIncorrect,
22892289
));
2290-
let note = vec![
2291-
"this could be because a macro annotated with `#[macro_export]` will be exported \
2292-
at the root of the crate instead of the module where it is defined"
2293-
.to_string(),
2294-
];
2295-
Some((suggestion, note))
2290+
Some((suggestion, Some("this could be because a macro annotated with `#[macro_export]` will be exported \
2291+
at the root of the crate instead of the module where it is defined"
2292+
.to_string())))
22962293
} else {
22972294
None
22982295
}

compiler/rustc_resolve/src/imports.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<'a> Resolver<'a> {
336336
struct UnresolvedImportError {
337337
span: Span,
338338
label: Option<String>,
339-
note: Vec<String>,
339+
note: Option<String>,
340340
suggestion: Option<Suggestion>,
341341
}
342342

@@ -427,7 +427,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
427427
let err = UnresolvedImportError {
428428
span: import.span,
429429
label: None,
430-
note: Vec::new(),
430+
note: None,
431431
suggestion: None,
432432
};
433433
if path.contains("::") {
@@ -463,10 +463,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
463463

464464
let mut diag = struct_span_err!(self.r.session, span, E0432, "{}", &msg);
465465

466-
if let Some((_, UnresolvedImportError { note, .. })) = errors.iter().last() {
467-
for message in note {
468-
diag.note(message);
469-
}
466+
if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.iter().last() {
467+
diag.note(note);
470468
}
471469

472470
for (_, err) in errors.into_iter().take(MAX_LABEL_COUNT) {
@@ -644,7 +642,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
644642
None => UnresolvedImportError {
645643
span,
646644
label: Some(label),
647-
note: Vec::new(),
645+
note: None,
648646
suggestion,
649647
},
650648
};
@@ -686,7 +684,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
686684
return Some(UnresolvedImportError {
687685
span: import.span,
688686
label: Some(String::from("cannot glob-import a module into itself")),
689-
note: Vec::new(),
687+
note: None,
690688
suggestion: None,
691689
});
692690
}
@@ -830,7 +828,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
830828
let (suggestion, note) =
831829
match self.check_for_module_export_macro(import, module, ident) {
832830
Some((suggestion, note)) => (suggestion.or(lev_suggestion), note),
833-
_ => (lev_suggestion, Vec::new()),
831+
_ => (lev_suggestion, None),
834832
};
835833

836834
let label = match module {

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub trait InferCtxtExt<'tcx> {
184184
trait_pred: ty::PolyTraitPredicate<'tcx>,
185185
) -> bool;
186186

187-
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String>;
187+
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol>;
188188

189189
fn suggest_fn_call(
190190
&self,
@@ -737,13 +737,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
737737
/// Given a closure's `DefId`, return the given name of the closure.
738738
///
739739
/// This doesn't account for reassignments, but it's only used for suggestions.
740-
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String> {
741-
let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<String> {
740+
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol> {
741+
let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<Symbol> {
742742
// Get the local name of this closure. This can be inaccurate because
743743
// of the possibility of reassignment, but this should be good enough.
744744
match &kind {
745-
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => {
746-
Some(format!("{}", name))
745+
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) => {
746+
Some(ident.name)
747747
}
748748
_ => {
749749
err.note(msg);

compiler/rustc_traits/src/evaluate_obligation.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_infer::infer::TyCtxtInferExt;
1+
use rustc_infer::infer::{DefiningAnchor, TyCtxtInferExt};
22
use rustc_middle::ty::query::Providers;
33
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
44
use rustc_span::source_map::DUMMY_SP;
@@ -16,7 +16,9 @@ fn evaluate_obligation<'tcx>(
1616
canonical_goal: CanonicalPredicateGoal<'tcx>,
1717
) -> Result<EvaluationResult, OverflowError> {
1818
debug!("evaluate_obligation(canonical_goal={:#?})", canonical_goal);
19-
tcx.infer_ctxt().enter_with_canonical(
19+
// HACK This bubble is required for this tests to pass:
20+
// impl-trait/issue99642.rs
21+
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_with_canonical(
2022
DUMMY_SP,
2123
&canonical_goal,
2224
|ref infcx, goal, _canonical_inference_vars| {

compiler/rustc_traits/src/type_op.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc_hir as hir;
22
use rustc_hir::def_id::DefId;
33
use rustc_infer::infer::at::ToTrace;
44
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
5-
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
5+
use rustc_infer::infer::{DefiningAnchor, InferCtxt, TyCtxtInferExt};
66
use rustc_infer::traits::TraitEngineExt as _;
77
use rustc_middle::ty::query::Providers;
88
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
@@ -258,10 +258,15 @@ fn type_op_prove_predicate<'tcx>(
258258
tcx: TyCtxt<'tcx>,
259259
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
260260
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
261-
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| {
262-
type_op_prove_predicate_with_cause(infcx, fulfill_cx, key, ObligationCause::dummy());
263-
Ok(())
264-
})
261+
// HACK This bubble is required for this test to pass:
262+
// impl-trait/issue-99642.rs
263+
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
264+
&canonicalized,
265+
|infcx, fulfill_cx, key| {
266+
type_op_prove_predicate_with_cause(infcx, fulfill_cx, key, ObligationCause::dummy());
267+
Ok(())
268+
},
269+
)
265270
}
266271

267272
/// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,

library/std/src/os/fd/raw.rs

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::os::wasi::io::OwnedFd;
1414
use crate::sys_common::{AsInner, IntoInner};
1515

1616
/// Raw file descriptors.
17+
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
1718
#[stable(feature = "rust1", since = "1.0.0")]
1819
pub type RawFd = raw::c_int;
1920

@@ -22,6 +23,7 @@ pub type RawFd = raw::c_int;
2223
/// This is only available on unix and WASI platforms and must be imported in
2324
/// order to call the method. Windows platforms have a corresponding
2425
/// `AsRawHandle` and `AsRawSocket` set of traits.
26+
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
2527
#[stable(feature = "rust1", since = "1.0.0")]
2628
pub trait AsRawFd {
2729
/// Extracts the raw file descriptor.
@@ -57,6 +59,7 @@ pub trait AsRawFd {
5759

5860
/// A trait to express the ability to construct an object from a raw file
5961
/// descriptor.
62+
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
6063
#[stable(feature = "from_raw_os", since = "1.1.0")]
6164
pub trait FromRawFd {
6265
/// Constructs a new instance of `Self` from the given raw file
@@ -100,6 +103,7 @@ pub trait FromRawFd {
100103

101104
/// A trait to express the ability to consume an object and acquire ownership of
102105
/// its raw file descriptor.
106+
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
103107
#[stable(feature = "into_raw_os", since = "1.4.0")]
104108
pub trait IntoRawFd {
105109
/// Consumes this object, returning the raw underlying file descriptor.

library/std/src/os/wasi/io/raw.rs

+15
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,19 @@
22
33
#![unstable(feature = "wasi_ext", issue = "71213")]
44

5+
// NOTE: despite the fact that this module is unstable,
6+
// stable Rust had the capability to access the stable
7+
// re-exported items from os::fd::raw through this
8+
// unstable module.
9+
// In PR #95956 the stability checker was changed to check
10+
// all path segments of an item rather than just the last,
11+
// which caused the aforementioned stable usage to regress
12+
// (see issue #99502).
13+
// As a result, the items in os::fd::raw were given the
14+
// rustc_allowed_through_unstable_modules attribute.
15+
// No regression tests were added to ensure this property,
16+
// as CI is not configured to test wasm32-wasi.
17+
// If this module is stabilized,
18+
// you may want to remove those attributes
19+
// (assuming no other unstable modules need them).
520
pub use crate::os::fd::raw::*;

src/librustdoc/html/static/css/settings.css

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141

4242
.toggle {
4343
position: relative;
44-
display: inline-block;
4544
width: 100%;
46-
height: 27px;
4745
margin-right: 20px;
4846
display: flex;
4947
align-items: center;
@@ -58,6 +56,7 @@
5856
.slider {
5957
position: relative;
6058
width: 45px;
59+
min-width: 45px;
6160
display: block;
6261
height: 28px;
6362
margin-right: 20px;

src/test/rustdoc-gui/settings.goml

+9
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,12 @@ assert-false: "noscript section"
147147
javascript: false
148148
reload:
149149
assert-css: ("noscript section", {"display": "block"})
150+
javascript: true
151+
152+
// Check for the display on small screen
153+
show-text: true
154+
reload:
155+
size: (300, 1000)
156+
click: "#settings-menu"
157+
wait-for: "#settings"
158+
assert-css: ("#settings .slider", {"width": "45px"}, ALL)
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
type Opq = impl Sized;
5+
fn test() -> impl Iterator<Item = Opq> {
6+
Box::new(0..) as Box<dyn Iterator<Item = _>>
7+
}
8+
fn main(){}

src/test/ui/impl-trait/issue-99642.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// check-pass
2+
3+
fn test() -> impl Iterator<Item = impl Sized> {
4+
Box::new(0..) as Box<dyn Iterator<Item = _>>
5+
}
6+
7+
fn main() {}

src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
error[E0275]: overflow evaluating the requirement `<fn() -> Foo {foo} as FnOnce<()>>::Output == fn() -> Foo {foo}`
1+
error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
22
--> $DIR/issue-53398-cyclic-types.rs:5:13
33
|
44
LL | fn foo() -> Foo {
55
| ^^^
6+
|
7+
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`)
68

79
error: aborting due to previous error
810

0 commit comments

Comments
 (0)