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
This commit is contained in:
bors 2022-07-28 13:32:35 +00:00
commit e5682615bb
14 changed files with 88 additions and 43 deletions

View File

@ -129,7 +129,7 @@ fn get_features(
.span_suggestion(
mi.span(),
"expected just one word",
format!("{}", ident.name),
ident.name,
Applicability::MaybeIncorrect,
)
.emit();

View File

@ -1677,7 +1677,6 @@ impl<'a> Parser<'a> {
}
/// Is this a possibly malformed start of a `macro_rules! foo` item definition?
fn is_macro_rules_item(&mut self) -> IsMacroRulesItem {
if self.check_keyword(kw::MacroRules) {
let macro_rules_span = self.token.span;

View File

@ -2023,7 +2023,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
span: Span,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Vec<String>)> {
) -> Option<(Vec<Segment>, Option<String>)> {
debug!("make_path_suggestion: span={:?} path={:?}", span, path);
match (path.get(0), path.get(1)) {
@ -2058,12 +2058,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Vec<String>)> {
) -> Option<(Vec<Segment>, Option<String>)> {
// Replace first ident with `self` and check if that is valid.
path[0].ident.name = kw::SelfLower;
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
}
/// Suggests a missing `crate::` if that resolves to an correct module.
@ -2077,7 +2077,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Vec<String>)> {
) -> Option<(Vec<Segment>, Option<String>)> {
// Replace first ident with `crate` and check if that is valid.
path[0].ident.name = kw::Crate;
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
@ -2085,12 +2085,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
if let PathResult::Module(..) = result {
Some((
path,
vec![
Some(
"`use` statements changed in Rust 2018; read more at \
<https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-\
clarity.html>"
.to_string(),
],
),
))
} else {
None
@ -2108,12 +2108,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Vec<String>)> {
) -> Option<(Vec<Segment>, Option<String>)> {
// Replace first ident with `crate` and check if that is valid.
path[0].ident.name = kw::Super;
let result = self.r.maybe_resolve_path(&path, None, parent_scope);
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result);
if let PathResult::Module(..) = result { Some((path, Vec::new())) } else { None }
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
}
/// Suggests a missing external crate name if that resolves to an correct module.
@ -2130,7 +2130,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
&mut self,
mut path: Vec<Segment>,
parent_scope: &ParentScope<'b>,
) -> Option<(Vec<Segment>, Vec<String>)> {
) -> Option<(Vec<Segment>, Option<String>)> {
if path[1].ident.span.rust_2015() {
return None;
}
@ -2151,7 +2151,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
name, path, result
);
if let PathResult::Module(..) = result {
return Some((path, Vec::new()));
return Some((path, None));
}
}
@ -2175,7 +2175,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
import: &'b Import<'b>,
module: ModuleOrUniformRoot<'b>,
ident: Ident,
) -> Option<(Option<Suggestion>, Vec<String>)> {
) -> Option<(Option<Suggestion>, Option<String>)> {
let ModuleOrUniformRoot::Module(mut crate_module) = module else {
return None;
};
@ -2287,12 +2287,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
String::from("a macro with this name exists at the root of the crate"),
Applicability::MaybeIncorrect,
));
let note = vec![
"this could be because a macro annotated with `#[macro_export]` will be exported \
at the root of the crate instead of the module where it is defined"
.to_string(),
];
Some((suggestion, note))
Some((suggestion, Some("this could be because a macro annotated with `#[macro_export]` will be exported \
at the root of the crate instead of the module where it is defined"
.to_string())))
} else {
None
}

View File

@ -336,7 +336,7 @@ impl<'a> Resolver<'a> {
struct UnresolvedImportError {
span: Span,
label: Option<String>,
note: Vec<String>,
note: Option<String>,
suggestion: Option<Suggestion>,
}
@ -427,7 +427,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
let err = UnresolvedImportError {
span: import.span,
label: None,
note: Vec::new(),
note: None,
suggestion: None,
};
if path.contains("::") {
@ -463,10 +463,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
let mut diag = struct_span_err!(self.r.session, span, E0432, "{}", &msg);
if let Some((_, UnresolvedImportError { note, .. })) = errors.iter().last() {
for message in note {
diag.note(message);
}
if let Some((_, UnresolvedImportError { note: Some(note), .. })) = errors.iter().last() {
diag.note(note);
}
for (_, err) in errors.into_iter().take(MAX_LABEL_COUNT) {
@ -644,7 +642,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
None => UnresolvedImportError {
span,
label: Some(label),
note: Vec::new(),
note: None,
suggestion,
},
};
@ -686,7 +684,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
return Some(UnresolvedImportError {
span: import.span,
label: Some(String::from("cannot glob-import a module into itself")),
note: Vec::new(),
note: None,
suggestion: None,
});
}
@ -830,7 +828,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
let (suggestion, note) =
match self.check_for_module_export_macro(import, module, ident) {
Some((suggestion, note)) => (suggestion.or(lev_suggestion), note),
_ => (lev_suggestion, Vec::new()),
_ => (lev_suggestion, None),
};
let label = match module {

View File

@ -184,7 +184,7 @@ pub trait InferCtxtExt<'tcx> {
trait_pred: ty::PolyTraitPredicate<'tcx>,
) -> bool;
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String>;
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol>;
fn suggest_fn_call(
&self,
@ -737,13 +737,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
/// Given a closure's `DefId`, return the given name of the closure.
///
/// This doesn't account for reassignments, but it's only used for suggestions.
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<String> {
let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<String> {
fn get_closure_name(&self, def_id: DefId, err: &mut Diagnostic, msg: &str) -> Option<Symbol> {
let get_name = |err: &mut Diagnostic, kind: &hir::PatKind<'_>| -> Option<Symbol> {
// Get the local name of this closure. This can be inaccurate because
// of the possibility of reassignment, but this should be good enough.
match &kind {
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, name, None) => {
Some(format!("{}", name))
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, _, ident, None) => {
Some(ident.name)
}
_ => {
err.note(msg);

View File

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

View File

@ -2,7 +2,7 @@ use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_infer::infer::at::ToTrace;
use rustc_infer::infer::canonical::{Canonical, QueryResponse};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::infer::{DefiningAnchor, InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::TraitEngineExt as _;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
@ -258,10 +258,15 @@ fn type_op_prove_predicate<'tcx>(
tcx: TyCtxt<'tcx>,
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, ()>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(&canonicalized, |infcx, fulfill_cx, key| {
type_op_prove_predicate_with_cause(infcx, fulfill_cx, key, ObligationCause::dummy());
Ok(())
})
// HACK This bubble is required for this test to pass:
// impl-trait/issue-99642.rs
tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::Bubble).enter_canonical_trait_query(
&canonicalized,
|infcx, fulfill_cx, key| {
type_op_prove_predicate_with_cause(infcx, fulfill_cx, key, ObligationCause::dummy());
Ok(())
},
)
}
/// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,

View File

@ -14,6 +14,7 @@ use crate::os::wasi::io::OwnedFd;
use crate::sys_common::{AsInner, IntoInner};
/// Raw file descriptors.
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
#[stable(feature = "rust1", since = "1.0.0")]
pub type RawFd = raw::c_int;
@ -22,6 +23,7 @@ pub type RawFd = raw::c_int;
/// This is only available on unix and WASI platforms and must be imported in
/// order to call the method. Windows platforms have a corresponding
/// `AsRawHandle` and `AsRawSocket` set of traits.
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait AsRawFd {
/// Extracts the raw file descriptor.
@ -57,6 +59,7 @@ pub trait AsRawFd {
/// A trait to express the ability to construct an object from a raw file
/// descriptor.
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
#[stable(feature = "from_raw_os", since = "1.1.0")]
pub trait FromRawFd {
/// Constructs a new instance of `Self` from the given raw file
@ -100,6 +103,7 @@ pub trait FromRawFd {
/// A trait to express the ability to consume an object and acquire ownership of
/// its raw file descriptor.
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
#[stable(feature = "into_raw_os", since = "1.4.0")]
pub trait IntoRawFd {
/// Consumes this object, returning the raw underlying file descriptor.

View File

@ -2,4 +2,19 @@
#![unstable(feature = "wasi_ext", issue = "71213")]
// NOTE: despite the fact that this module is unstable,
// stable Rust had the capability to access the stable
// re-exported items from os::fd::raw through this
// unstable module.
// In PR #95956 the stability checker was changed to check
// all path segments of an item rather than just the last,
// which caused the aforementioned stable usage to regress
// (see issue #99502).
// As a result, the items in os::fd::raw were given the
// rustc_allowed_through_unstable_modules attribute.
// No regression tests were added to ensure this property,
// as CI is not configured to test wasm32-wasi.
// If this module is stabilized,
// you may want to remove those attributes
// (assuming no other unstable modules need them).
pub use crate::os::fd::raw::*;

View File

@ -41,9 +41,7 @@
.toggle {
position: relative;
display: inline-block;
width: 100%;
height: 27px;
margin-right: 20px;
display: flex;
align-items: center;
@ -58,6 +56,7 @@
.slider {
position: relative;
width: 45px;
min-width: 45px;
display: block;
height: 28px;
margin-right: 20px;

View File

@ -147,3 +147,12 @@ assert-false: "noscript section"
javascript: false
reload:
assert-css: ("noscript section", {"display": "block"})
javascript: true
// Check for the display on small screen
show-text: true
reload:
size: (300, 1000)
click: "#settings-menu"
wait-for: "#settings"
assert-css: ("#settings .slider", {"width": "45px"}, ALL)

View File

@ -0,0 +1,8 @@
// check-pass
#![feature(type_alias_impl_trait)]
type Opq = impl Sized;
fn test() -> impl Iterator<Item = Opq> {
Box::new(0..) as Box<dyn Iterator<Item = _>>
}
fn main(){}

View File

@ -0,0 +1,7 @@
// check-pass
fn test() -> impl Iterator<Item = impl Sized> {
Box::new(0..) as Box<dyn Iterator<Item = _>>
}
fn main() {}

View File

@ -1,8 +1,10 @@
error[E0275]: overflow evaluating the requirement `<fn() -> Foo {foo} as FnOnce<()>>::Output == fn() -> Foo {foo}`
error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
--> $DIR/issue-53398-cyclic-types.rs:5:13
|
LL | fn foo() -> Foo {
| ^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`)
error: aborting due to previous error