Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #96685

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6d590ba
rustdoc: Resolve doc links on fields during early resolution
petrochenkov Apr 26, 2022
6d865f8
openbsd: unbreak build on native platform
semarie May 2, 2022
6d8b569
remove the special case for nonexported macro_rules! macros
m-ysk May 2, 2022
5796726
When suggesting to import an item, also suggest changing the path if …
estebank Apr 23, 2022
4934a9e
Tweak wording
estebank May 3, 2022
77390a1
Fix typo in lint levels doc
rockboynton May 3, 2022
3d12fd0
ignore a doctest for the non-exported macro
m-ysk May 3, 2022
4698a3f
ignore the doctest for map
m-ysk May 3, 2022
56c2769
Fix flaky rustdoc-ui test because it did not replace time result
GuillaumeGomez May 3, 2022
bfcd191
Quick fix for #96223.
ricked-twice May 3, 2022
574bee3
Taking review hints into account.
ricked-twice May 3, 2022
a63d414
Update `ProjectionElem::Downcast` documentation
tmiasko May 3, 2022
e5e0925
Rollup merge of #96353 - estebank:issue-95413, r=compiler-errors
JohnTitor May 3, 2022
a4afb49
Rollup merge of #96447 - petrochenkov:docregr, r=GuillaumeGomez
JohnTitor May 3, 2022
90749fc
Rollup merge of #96597 - semarie:split_debuginfo-unix, r=davidtwco,Ma…
JohnTitor May 3, 2022
5c2d31c
Rollup merge of #96630 - m-ysk:fix/issue-88038, r=notriddle
JohnTitor May 3, 2022
e55c3f8
Rollup merge of #96662 - rockboynton:master, r=GuillaumeGomez
JohnTitor May 3, 2022
b47fb3b
Rollup merge of #96668 - GuillaumeGomez:fix-rustdoc-ui-flaky-test, r=…
JohnTitor May 3, 2022
3c0c140
Rollup merge of #96679 - ricked-twice:issue-96223-fix, r=jackh726
JohnTitor May 3, 2022
0a18564
Rollup merge of #96684 - tmiasko:mir-downcast, r=petrochenkov
JohnTitor May 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2017,9 +2017,7 @@ pub enum ProjectionElem<V, T> {
from_end: bool,
},

/// "Downcast" to a variant of an ADT. Currently, we only introduce
/// this for ADTs with more than one variant. It may be better to
/// just introduce it always, or always for enums.
/// "Downcast" to a variant of an enum or a generator.
///
/// The included Symbol is the name of the variant, used for printing MIR.
Downcast(Option<Symbol>, VariantIdx),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_target::abi::VariantIdx;
#[derive(Copy, Clone, Debug, TypeFoldable)]
pub struct PlaceTy<'tcx> {
pub ty: Ty<'tcx>,
/// Downcast to a particular variant of an enum, if included.
/// Downcast to a particular variant of an enum or a generator, if included.
pub variant_index: Option<VariantIdx>,
}

Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'a> Resolver<'a> {
}

fn report_with_use_injections(&mut self, krate: &Crate) {
for UseError { mut err, candidates, def_id, instead, suggestion } in
for UseError { mut err, candidates, def_id, instead, suggestion, path } in
self.use_injections.drain(..)
{
let (span, found_use) = if let Some(def_id) = def_id.as_local() {
Expand All @@ -135,6 +135,7 @@ impl<'a> Resolver<'a> {
if instead { Instead::Yes } else { Instead::No },
found_use,
IsPattern::No,
path,
);
} else if let Some((span, msg, sugg, appl)) = suggestion {
err.span_suggestion(span, msg, sugg, appl);
Expand Down Expand Up @@ -702,6 +703,7 @@ impl<'a> Resolver<'a> {
Instead::No,
FoundUse::Yes,
IsPattern::Yes,
vec![],
);
}
err
Expand Down Expand Up @@ -1482,6 +1484,7 @@ impl<'a> Resolver<'a> {
Instead::No,
FoundUse::Yes,
IsPattern::No,
vec![],
);

if macro_kind == MacroKind::Derive && (ident.name == sym::Send || ident.name == sym::Sync) {
Expand Down Expand Up @@ -2448,6 +2451,7 @@ fn show_candidates(
instead: Instead,
found_use: FoundUse,
is_pattern: IsPattern,
path: Vec<Segment>,
) {
if candidates.is_empty() {
return;
Expand Down Expand Up @@ -2515,6 +2519,14 @@ fn show_candidates(
accessible_path_strings.into_iter().map(|a| a.0),
Applicability::MaybeIncorrect,
);
if let [first, .., last] = &path[..] {
err.span_suggestion_verbose(
first.ident.span.until(last.ident.span),
&format!("if you import `{}`, refer to it directly", last.ident),
String::new(),
Applicability::Unspecified,
);
}
} else {
msg.push(':');

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
def_id,
instead,
suggestion,
path: path.into(),
});
}

Expand Down Expand Up @@ -2759,6 +2760,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
def_id,
instead: false,
suggestion: None,
path: path.into(),
});
} else {
err.cancel();
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ struct UseError<'a> {
instead: bool,
/// Extra free-form suggestion.
suggestion: Option<(Span, &'static str, String, Applicability)>,
/// Path `Segment`s at the place of use that failed. Used for accurate suggestion after telling
/// the user to import the item directly.
path: Vec<Segment>,
}

#[derive(Clone, Copy, PartialEq, Debug)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
return false;
}

let orig_ty = old_pred.self_ty().skip_binder();
// This is a quick fix to resolve an ICE (#96223).
// This change should probably be deeper.
// As suggested by @jackh726, `mk_trait_obligation_with_new_self_ty` could take a `Binder<(TraitRef, Ty)>
// instead of `Binder<Ty>` leading to some changes to its call places.
let Some(orig_ty) = old_pred.self_ty().no_bound_vars() else {
return false;
};
let mk_result = |new_ty| {
let obligation =
self.mk_trait_obligation_with_new_self_ty(param_env, old_pred, new_ty);
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ macro_rules! impl_fn_for_zst {
///
/// # Example
///
/// ```
/// ```ignore(cannot-test-this-because-non-exported-macro)
/// cfg_if! {
/// if #[cfg(unix)] {
/// fn foo() { /* unix specific functionality */ }
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,8 @@ impl<'a> Builder<'a> {
// FIXME(davidtwco): #[cfg(not(bootstrap))] - #95612 needs to be in the bootstrap compiler
// for this conditional to be removed.
if !target.contains("windows") || compiler.stage >= 1 {
if target.contains("linux") || target.contains("windows") {
if target.contains("linux") || target.contains("windows") || target.contains("openbsd")
{
rustflags.arg("-Zunstable-options");
}
match self.config.rust_split_debuginfo {
Expand Down
5 changes: 2 additions & 3 deletions src/doc/rustc/src/lints/levels.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ This lint level gives you that.
'force-warn' does for 'warn'. It's the same as 'deny' in that a lint at this
level will produce an error, but unlike the 'deny' level, the 'forbid' level
can not be overridden to be anything lower than an error. However, lint
levels may still be capped with `--cap-lints` (see below) so `rustc --cap-
lints warn` will make lints set to 'forbid' just
warn.
levels may still be capped with `--cap-lints` (see below) so `rustc --cap-lints warn`
will make lints set to 'forbid' just warn.

## Configuring warning levels

Expand Down
10 changes: 0 additions & 10 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,16 +1225,6 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx>

fn visit_item(&mut self, item: &'hir hir::Item<'_>) {
let name = match &item.kind {
hir::ItemKind::Macro(ref macro_def, _) => {
// FIXME(#88038): Non exported macros have historically not been tested,
// but we really ought to start testing them.
let def_id = item.def_id.to_def_id();
if macro_def.macro_rules && !self.tcx.has_attr(def_id, sym::macro_export) {
intravisit::walk_item(self, item);
return;
}
item.ident.to_string()
}
hir::ItemKind::Impl(impl_) => {
rustc_hir_pretty::id_to_string(&self.map, impl_.self_ty.hir_id)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ use crate::passes::collect_intra_doc_links;
///
/// Example:
///
/// ```
/// ```ignore(cannot-test-this-because-non-exported-macro)
/// let letters = map!{"a" => "b", "c" => "d"};
/// ```
///
Expand Down
14 changes: 13 additions & 1 deletion src/librustdoc/passes/collect_intra_doc_links/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,22 @@ impl<'ra> EarlyDocLinkResolver<'_, 'ra> {
if let Res::Def(DefKind::Mod, ..) = child.res {
self.resolve_doc_links_extern_inner(def_id); // Inner attribute scope
}
// Traits are processed in `add_extern_traits_in_scope`.
// `DefKind::Trait`s are processed in `process_extern_impls`.
if let Res::Def(DefKind::Mod | DefKind::Enum, ..) = child.res {
self.process_module_children_or_reexports(def_id);
}
if let Res::Def(DefKind::Struct | DefKind::Union | DefKind::Variant, _) =
child.res
{
let field_def_ids = Vec::from_iter(
self.resolver
.cstore()
.associated_item_def_ids_untracked(def_id, self.sess),
);
for field_def_id in field_def_ids {
self.resolve_doc_links_extern_outer(field_def_id, scope_id);
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc-ui/block-doc-comment.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// check-pass
// compile-flags:--test
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"

// This test ensures that no code block is detected in the doc comments.

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/block-doc-comment.stdout
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME

26 changes: 26 additions & 0 deletions src/test/rustdoc-ui/intra-doc/assoc-field.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Traits in scope are collected for doc links in field attributes.

// check-pass
// aux-build: assoc-field-dep.rs

extern crate assoc_field_dep;
pub use assoc_field_dep::*;

#[derive(Clone)]
pub struct Struct;

pub mod mod1 {
pub struct Fields {
/// [crate::Struct::clone]
pub field: u8,
}
}

pub mod mod2 {
pub enum Fields {
V {
/// [crate::Struct::clone]
field: u8,
},
}
}
18 changes: 18 additions & 0 deletions src/test/rustdoc-ui/intra-doc/auxiliary/assoc-field-dep.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#[derive(Clone)]
pub struct Struct;

pub mod dep_mod1 {
pub struct Fields {
/// [crate::Struct::clone]
pub field: u8,
}
}

pub mod dep_mod2 {
pub enum Fields {
V {
/// [crate::Struct::clone]
field: u8,
},
}
}
5 changes: 5 additions & 0 deletions src/test/ui/macros/macro-outer-attributes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ help: consider importing this function
|
LL | use b::bar;
|
help: if you import `bar`, refer to it directly
|
LL - a::bar();
LL + bar();
|

error: aborting due to previous error

Expand Down
20 changes: 20 additions & 0 deletions src/test/ui/namespace/namespace-mix.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ LL | use m2::S;
|
LL | use xm2::S;
|
help: if you import `S`, refer to it directly
|
LL - check(m1::S);
LL + check(S);
|

error[E0423]: expected value, found type alias `xm1::S`
--> $DIR/namespace-mix.rs:40:11
Expand All @@ -41,6 +46,11 @@ LL | use m2::S;
|
LL | use xm2::S;
|
help: if you import `S`, refer to it directly
|
LL - check(xm1::S);
LL + check(S);
|

error[E0423]: expected value, found struct variant `m7::V`
--> $DIR/namespace-mix.rs:100:11
Expand All @@ -67,6 +77,11 @@ LL | use m8::V;
|
LL | use xm8::V;
|
help: if you import `V`, refer to it directly
|
LL - check(m7::V);
LL + check(V);
|

error[E0423]: expected value, found struct variant `xm7::V`
--> $DIR/namespace-mix.rs:106:11
Expand Down Expand Up @@ -95,6 +110,11 @@ LL | use m8::V;
|
LL | use xm8::V;
|
help: if you import `V`, refer to it directly
|
LL - check(xm7::V);
LL + check(V);
|

error[E0277]: the trait bound `c::Item: Impossible` is not satisfied
--> $DIR/namespace-mix.rs:33:11
Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/parser/circular_modules_main.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ help: consider importing this function
|
LL | use hi_str;
|
help: if you import `hi_str`, refer to it directly
|
LL - println!("{}", circular_modules_main::hi_str());
LL + println!("{}", hi_str());
|

error: aborting due to 2 previous errors

Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/resolve/enums-are-namespaced-xc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ help: consider importing this unit variant
|
LL | use namespaced_enums::Foo::A;
|
help: if you import `A`, refer to it directly
|
LL - let _ = namespaced_enums::A;
LL + let _ = A;
|

error[E0425]: cannot find function, tuple struct or tuple variant `B` in crate `namespaced_enums`
--> $DIR/enums-are-namespaced-xc.rs:7:31
Expand All @@ -19,6 +24,11 @@ help: consider importing this tuple variant
|
LL | use namespaced_enums::Foo::B;
|
help: if you import `B`, refer to it directly
|
LL - let _ = namespaced_enums::B(10);
LL + let _ = B(10);
|

error[E0422]: cannot find struct, variant or union type `C` in crate `namespaced_enums`
--> $DIR/enums-are-namespaced-xc.rs:9:31
Expand All @@ -30,6 +40,11 @@ help: consider importing this variant
|
LL | use namespaced_enums::Foo::C;
|
help: if you import `C`, refer to it directly
|
LL - let _ = namespaced_enums::C { a: 10 };
LL + let _ = C { a: 10 };
|

error: aborting due to 3 previous errors

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/resolve/issue-50599.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ LL | use std::f32::consts::LOG10_2;
|
LL | use std::f64::consts::LOG10_2;
|
help: if you import `LOG10_2`, refer to it directly
|
LL - const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize;
LL + const M: usize = (f64::from(N) * LOG10_2) as usize;
|

error: aborting due to previous error

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/resolve/missing-in-namespace.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ help: consider importing this struct
|
LL | use std::collections::HashMap;
|
help: if you import `HashMap`, refer to it directly
|
LL - let _map = std::hahmap::HashMap::new();
LL + let _map = HashMap::new();
|

error: aborting due to previous error

Expand Down
Loading