Skip to content

Rollup of 8 pull requests #93570

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

Closed
wants to merge 20 commits into from
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4d4ec97
Document char validity
GKFX Jan 30, 2022
c790128
Improve wrapping on settings page
jsha Jan 28, 2022
5357ec1
(#93493) Add items from code review
GKFX Jan 31, 2022
76aa929
Fix incorrect panic message in example
TheColdVoid Feb 1, 2022
95bd87f
librustdoc: impl core::fmt::Write for rustdoc::html::render::Buffer
mfrw Jan 11, 2022
66d7e50
librustdoc: inline and forward all methods for `impl Write for Buffer`
mfrw Jan 11, 2022
62bea63
librustdoc: render: use render_into instead of creating a temp string
mfrw Feb 1, 2022
e22729b
Add missing | between print options
danielframpton Feb 1, 2022
63b12ae
Fix two incorrect "it's"
steffahn Feb 1, 2022
d372baf
Fix annotation of code blocks
GKFX Feb 1, 2022
d6c508b
Do not point at whole file missing `fn main`
estebank Jan 21, 2022
b26ad8d
Detect `::` -> `:` typo in type argument
estebank Jan 11, 2022
db6950f
Rollup merge of #92758 - mfrw:mfrw/rustdoc-impl-write, r=GuillaumeGomez
matthiaskrgr Feb 2, 2022
f6e5162
Rollup merge of #92788 - estebank:colon-colon, r=cjgillot
matthiaskrgr Feb 2, 2022
3bf7bce
Rollup merge of #93142 - estebank:missing-main, r=wesleywiser
matthiaskrgr Feb 2, 2022
9e22ab1
Rollup merge of #93420 - jsha:adjust-settings-layout, r=GuillaumeGomez
matthiaskrgr Feb 2, 2022
aa88bba
Rollup merge of #93493 - GKFX:char-docs-2, r=scottmcm
matthiaskrgr Feb 2, 2022
cdda61f
Rollup merge of #93531 - TheColdVoid:patch-1, r=m-ou-se
matthiaskrgr Feb 2, 2022
ebe293f
Rollup merge of #93559 - danielframpton:link-args-typo, r=oli-obk
matthiaskrgr Feb 2, 2022
f77b003
Rollup merge of #93560 - steffahn:a_typo, r=petrochenkov
matthiaskrgr Feb 2, 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: 2 additions & 2 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
@@ -1642,7 +1642,7 @@ pub enum FakeReadCause {
ForMatchedPlace(Option<DefId>),

/// A fake read of the RefWithinGuard version of a bind-by-value variable
/// in a match guard to ensure that it's value hasn't change by the time
/// in a match guard to ensure that its value hasn't change by the time
/// we create the OutsideGuard version.
ForGuardBinding,

@@ -2939,7 +2939,7 @@ impl Location {
let mut visited = FxHashSet::default();

while let Some(block) = queue.pop() {
// If we haven't visited this block before, then make sure we visit it's predecessors.
// If we haven't visited this block before, then make sure we visit its predecessors.
if visited.insert(block) {
queue.extend(predecessors[block].iter().cloned());
} else {
6 changes: 3 additions & 3 deletions compiler/rustc_passes/src/entry.rs
Original file line number Diff line number Diff line change
@@ -218,9 +218,9 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) {
// The file may be empty, which leads to the diagnostic machinery not emitting this
// note. This is a relatively simple way to detect that case and emit a span-less
// note instead.
if tcx.sess.source_map().lookup_line(sp.lo()).is_ok() {
err.set_span(sp);
err.span_label(sp, &note);
if tcx.sess.source_map().lookup_line(sp.hi()).is_ok() {
err.set_span(sp.shrink_to_hi());
err.span_label(sp.shrink_to_hi(), &note);
} else {
err.note(&note);
}
6 changes: 5 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
@@ -400,6 +400,8 @@ struct DiagnosticMetadata<'ast> {

/// Given `where <T as Bar>::Baz: String`, suggest `where T: Bar<Baz = String>`.
current_where_predicate: Option<&'ast WherePredicate>,

current_type_path: Option<&'ast Ty>,
}

struct LateResolutionVisitor<'a, 'b, 'ast> {
@@ -472,8 +474,10 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
}
fn visit_ty(&mut self, ty: &'ast Ty) {
let prev = self.diagnostic_metadata.current_trait_object;
let prev_ty = self.diagnostic_metadata.current_type_path;
match ty.kind {
TyKind::Path(ref qself, ref path) => {
self.diagnostic_metadata.current_type_path = Some(ty);
self.smart_resolve_path(ty.id, qself.as_ref(), path, PathSource::Type);
}
TyKind::ImplicitSelf => {
@@ -490,6 +494,7 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
}
visit::walk_ty(self, ty);
self.diagnostic_metadata.current_trait_object = prev;
self.diagnostic_metadata.current_type_path = prev_ty;
}
fn visit_poly_trait_ref(&mut self, tref: &'ast PolyTraitRef, m: &'ast TraitBoundModifier) {
self.smart_resolve_path(
@@ -1936,7 +1941,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
let instead = res.is_some();
let suggestion =
if res.is_none() { this.report_missing_type_error(path) } else { None };
// get_from_node_id

this.r.use_injections.push(UseError {
err,
37 changes: 37 additions & 0 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP};

use std::iter;
use std::ops::Deref;

use tracing::debug;

@@ -265,6 +266,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
}
}

self.detect_assoct_type_constraint_meant_as_path(base_span, &mut err);

// Emit special messages for unresolved `Self` and `self`.
if is_self_type(path, ns) {
err.code(rustc_errors::error_code!(E0411));
@@ -603,6 +606,40 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
(err, candidates)
}

fn detect_assoct_type_constraint_meant_as_path(
&self,
base_span: Span,
err: &mut DiagnosticBuilder<'_>,
) {
let Some(ty) = self.diagnostic_metadata.current_type_path else { return; };
let TyKind::Path(_, path) = &ty.kind else { return; };
for segment in &path.segments {
let Some(params) = &segment.args else { continue; };
let ast::GenericArgs::AngleBracketed(ref params) = params.deref() else { continue; };
for param in &params.args {
let ast::AngleBracketedArg::Constraint(constraint) = param else { continue; };
let ast::AssocConstraintKind::Bound { bounds } = &constraint.kind else {
continue;
};
for bound in bounds {
let ast::GenericBound::Trait(trait_ref, ast::TraitBoundModifier::None)
= bound else
{
continue;
};
if base_span == trait_ref.span {
err.span_suggestion_verbose(
constraint.ident.span.between(trait_ref.span),
"you might have meant to write a path instead of an associated type bound",
"::".to_string(),
Applicability::MachineApplicable,
);
}
}
}
}
}

fn get_single_associated_item(
&mut self,
path: &[Segment],
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
@@ -1188,7 +1188,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
"Compiler information to print on stdout",
"[crate-name|file-names|sysroot|target-libdir|cfg|target-list|\
target-cpus|target-features|relocation-models|code-models|\
tls-models|target-spec-json|native-static-libs|stack-protector-strategies\
tls-models|target-spec-json|native-static-libs|stack-protector-strategies|\
link-args]",
),
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
59 changes: 54 additions & 5 deletions library/core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
@@ -275,20 +275,69 @@ mod prim_bool {}
mod prim_never {}

#[doc(primitive = "char")]
#[allow(rustdoc::invalid_rust_codeblocks)]
/// A character type.
///
/// The `char` type represents a single character. More specifically, since
/// 'character' isn't a well-defined concept in Unicode, `char` is a '[Unicode
/// scalar value]', which is similar to, but not the same as, a '[Unicode code
/// point]'.
///
/// [Unicode scalar value]: https://www.unicode.org/glossary/#unicode_scalar_value
/// [Unicode code point]: https://www.unicode.org/glossary/#code_point
/// scalar value]'.
///
/// This documentation describes a number of methods and trait implementations on the
/// `char` type. For technical reasons, there is additional, separate
/// documentation in [the `std::char` module](char/index.html) as well.
///
/// # Validity
///
/// A `char` is a '[Unicode scalar value]', which is any '[Unicode code point]'
/// other than a [surrogate code point]. This has a fixed numerical definition:
/// code points are in the range 0 to 0x10FFFF, inclusive.
/// Surrogate code points, used by UTF-16, are in the range 0xD800 to 0xDFFF.
///
/// No `char` may be constructed, whether as a literal or at runtime, that is not a
/// Unicode scalar value:
///
/// ```compile_fail
/// // Each of these is a compiler error
/// ['\u{D800}', '\u{DFFF}', '\u{110000}'];
/// ```
///
/// ```should_panic
/// // Panics; from_u32 returns None.
/// char::from_u32(0xDE01).unwrap();
/// ```
///
/// ```no_run
/// // Undefined behaviour
/// unsafe { char::from_u32_unchecked(0x110000) };
/// ```
///
/// USVs are also the exact set of values that may be encoded in UTF-8. Because
/// `char` values are USVs and `str` values are valid UTF-8, it is safe to store
/// any `char` in a `str` or read any character from a `str` as a `char`.
///
/// The gap in valid `char` values is understood by the compiler, so in the
/// below example the two ranges are understood to cover the whole range of
/// possible `char` values and there is no error for a [non-exhaustive match].
///
/// ```
/// let c: char = 'a';
/// match c {
/// '\0' ..= '\u{D7FF}' => false,
/// '\u{E000}' ..= '\u{10FFFF}' => true,
/// };
/// ```
///
/// All USVs are valid `char` values, but not all of them represent a real
/// character. Many USVs are not currently assigned to a character, but may be
/// in the future ("reserved"); some will never be a character
/// ("noncharacters"); and some may be given different meanings by different
/// users ("private use").
///
/// [Unicode code point]: https://www.unicode.org/glossary/#code_point
/// [Unicode scalar value]: https://www.unicode.org/glossary/#unicode_scalar_value
/// [non-exhaustive match]: ../book/ch06-02-match.html#matches-are-exhaustive
/// [surrogate code point]: https://www.unicode.org/glossary/#surrogate_code_point
///
/// # Representation
///
/// `char` is always four bytes in size. This is a different representation than
2 changes: 1 addition & 1 deletion library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
@@ -405,7 +405,7 @@ impl TcpStream {
/// use std::net::TcpStream;
///
/// let stream = TcpStream::connect("127.0.0.1:8000")
/// .expect("couldn't bind to address");
/// .expect("Couldn't connect to the server...");
/// let mut buf = [0; 10];
/// let len = stream.peek(&mut buf).expect("peek failed");
/// ```
59 changes: 54 additions & 5 deletions library/std/src/primitive_docs.rs
Original file line number Diff line number Diff line change
@@ -275,20 +275,69 @@ mod prim_bool {}
mod prim_never {}

#[doc(primitive = "char")]
#[allow(rustdoc::invalid_rust_codeblocks)]
/// A character type.
///
/// The `char` type represents a single character. More specifically, since
/// 'character' isn't a well-defined concept in Unicode, `char` is a '[Unicode
/// scalar value]', which is similar to, but not the same as, a '[Unicode code
/// point]'.
///
/// [Unicode scalar value]: https://www.unicode.org/glossary/#unicode_scalar_value
/// [Unicode code point]: https://www.unicode.org/glossary/#code_point
/// scalar value]'.
///
/// This documentation describes a number of methods and trait implementations on the
/// `char` type. For technical reasons, there is additional, separate
/// documentation in [the `std::char` module](char/index.html) as well.
///
/// # Validity
///
/// A `char` is a '[Unicode scalar value]', which is any '[Unicode code point]'
/// other than a [surrogate code point]. This has a fixed numerical definition:
/// code points are in the range 0 to 0x10FFFF, inclusive.
/// Surrogate code points, used by UTF-16, are in the range 0xD800 to 0xDFFF.
///
/// No `char` may be constructed, whether as a literal or at runtime, that is not a
/// Unicode scalar value:
///
/// ```compile_fail
/// // Each of these is a compiler error
/// ['\u{D800}', '\u{DFFF}', '\u{110000}'];
/// ```
///
/// ```should_panic
/// // Panics; from_u32 returns None.
/// char::from_u32(0xDE01).unwrap();
/// ```
///
/// ```no_run
/// // Undefined behaviour
/// unsafe { char::from_u32_unchecked(0x110000) };
/// ```
///
/// USVs are also the exact set of values that may be encoded in UTF-8. Because
/// `char` values are USVs and `str` values are valid UTF-8, it is safe to store
/// any `char` in a `str` or read any character from a `str` as a `char`.
///
/// The gap in valid `char` values is understood by the compiler, so in the
/// below example the two ranges are understood to cover the whole range of
/// possible `char` values and there is no error for a [non-exhaustive match].
///
/// ```
/// let c: char = 'a';
/// match c {
/// '\0' ..= '\u{D7FF}' => false,
/// '\u{E000}' ..= '\u{10FFFF}' => true,
/// };
/// ```
///
/// All USVs are valid `char` values, but not all of them represent a real
/// character. Many USVs are not currently assigned to a character, but may be
/// in the future ("reserved"); some will never be a character
/// ("noncharacters"); and some may be given different meanings by different
/// users ("private use").
///
/// [Unicode code point]: https://www.unicode.org/glossary/#code_point
/// [Unicode scalar value]: https://www.unicode.org/glossary/#unicode_scalar_value
/// [non-exhaustive match]: ../book/ch06-02-match.html#matches-are-exhaustive
/// [surrogate code point]: https://www.unicode.org/glossary/#surrogate_code_point
///
/// # Representation
///
/// `char` is always four bytes in size. This is a different representation than
17 changes: 17 additions & 0 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
@@ -64,6 +64,23 @@ crate struct Buffer {
buffer: String,
}

impl core::fmt::Write for Buffer {
#[inline]
fn write_str(&mut self, s: &str) -> fmt::Result {
self.buffer.write_str(s)
}

#[inline]
fn write_char(&mut self, c: char) -> fmt::Result {
self.buffer.write_char(c)
}

#[inline]
fn write_fmt(self: &mut Self, args: fmt::Arguments<'_>) -> fmt::Result {
self.buffer.write_fmt(args)
}
}

impl Buffer {
crate fn empty_from(v: &Buffer) -> Buffer {
Buffer { for_html: v.for_html, buffer: String::new() }
2 changes: 1 addition & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
@@ -376,7 +376,7 @@ impl Setting {
description,
),
Setting::Select { js_data_name, description, default_value, ref options } => format!(
"<div class=\"setting-line\"><div class=\"radio-line\" id=\"{}\"><span class=\"setting-name\">{}</span>{}</div></div>",
"<div class=\"setting-line\"><div class=\"radio-line\" id=\"{}\"><span class=\"setting-name\">{}</span><div class=\"choices\">{}</div></div></div>",
js_data_name,
description,
options
3 changes: 1 addition & 2 deletions src/librustdoc/html/render/print_item.rs
Original file line number Diff line number Diff line change
@@ -139,8 +139,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer,
src_href: src_href.as_deref(),
};

let heading = item_vars.render().unwrap();
buf.write_str(&heading);
item_vars.render_into(buf).unwrap();

match *item.kind {
clean::ModuleItem(ref m) => item_module(buf, cx, item, &m.items),
16 changes: 9 additions & 7 deletions src/librustdoc/html/static/css/settings.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.setting-line {
padding: 5px;
margin: 0.6em 0 0.6em 0.3em;
position: relative;
}

@@ -17,17 +17,16 @@
border-bottom: 1px solid;
}

.setting-line .radio-line {
.setting-line .radio-line,
.setting-line .choices {
display: flex;
flex-wrap: wrap;
}

.setting-line .radio-line > * {
padding: 0.3em;
}

.setting-line .radio-line .setting-name {
flex-grow: 1;
margin-top: auto;
margin-bottom: auto;
}

.setting-line .radio-line input {
@@ -38,7 +37,10 @@
border-radius: 0.1em;
border: 1px solid;
margin-left: 0.5em;
min-width: 3.5em;
margin-top: 0.1em;
margin-bottom: 0.1em;
min-width: 3.8em;
padding: 0.3em;
}

.toggle {
6 changes: 6 additions & 0 deletions src/test/rustdoc-gui/mobile.goml
Original file line number Diff line number Diff line change
@@ -19,3 +19,9 @@ assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" }

size: (1000, 1000)
assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since \"" })

// On the settings page, the theme buttons should not line-wrap. Instead, they should
// all be placed as a group on a line below the setting name "Theme."
goto: file://|DOC_PATH|/settings.html
size: (400, 600)
compare-elements-position-near-false: ("#preferred-light-theme .setting-name", "#preferred-light-theme .choice", {"y": 16})
2 changes: 1 addition & 1 deletion src/test/ui/attributes/issue-90873.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![u=||{static d=||1;}]
//~^ unexpected token
//~| cannot find attribute `u` in this scope
//~| `main` function not found in crate `issue_90873`
//~| missing type for `static` item

#![a={impl std::ops::Neg for i8 {}}]
//~^ ERROR unexpected token
//~| ERROR cannot find attribute `a` in this scope
//~| ERROR `main` function not found in crate `issue_90873`
16 changes: 5 additions & 11 deletions src/test/ui/attributes/issue-90873.stderr
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ LL | #![u=||{static d=||1;}]
error: unexpected token: `{
impl std::ops::Neg for i8 {}
}`
--> $DIR/issue-90873.rs:7:6
--> $DIR/issue-90873.rs:6:6
|
LL | #![a={impl std::ops::Neg for i8 {}}]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -22,22 +22,16 @@ LL | #![u=||{static d=||1;}]
| ^

error: cannot find attribute `a` in this scope
--> $DIR/issue-90873.rs:7:4
--> $DIR/issue-90873.rs:6:4
|
LL | #![a={impl std::ops::Neg for i8 {}}]
| ^

error[E0601]: `main` function not found in crate `issue_90873`
--> $DIR/issue-90873.rs:1:1
--> $DIR/issue-90873.rs:6:37
|
LL | / #![u=||{static d=||1;}]
LL | |
LL | |
LL | |
LL | |
LL | |
LL | | #![a={impl std::ops::Neg for i8 {}}]
| |____________________________________^ consider adding a `main` function to `$DIR/issue-90873.rs`
LL | #![a={impl std::ops::Neg for i8 {}}]
| ^ consider adding a `main` function to `$DIR/issue-90873.rs`

error: missing type for `static` item
--> $DIR/issue-90873.rs:1:16
7 changes: 3 additions & 4 deletions src/test/ui/conditional-compilation/cfg-attr-cfg-2.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
error[E0601]: `main` function not found in crate `cfg_attr_cfg_2`
--> $DIR/cfg-attr-cfg-2.rs:8:1
--> $DIR/cfg-attr-cfg-2.rs:9:14
|
LL | / #[cfg_attr(foo, cfg(bar))]
LL | | fn main() { }
| |_____________^ consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs`
LL | fn main() { }
| ^ consider adding a `main` function to `$DIR/cfg-attr-cfg-2.rs`

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/conditional-compilation/cfg-in-crate-1.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0601]: `main` function not found in crate `cfg_in_crate_1`
--> $DIR/cfg-in-crate-1.rs:3:1
--> $DIR/cfg-in-crate-1.rs:3:13
|
LL | #![cfg(bar)]
| ^^^^^^^^^^^^ consider adding a `main` function to `$DIR/cfg-in-crate-1.rs`
| ^ consider adding a `main` function to `$DIR/cfg-in-crate-1.rs`

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/continue-after-missing-main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(dead_code)] //~ ERROR `main` function not found in crate
#![allow(dead_code)]

struct Tableau<'a, MP> {
provider: &'a MP,
@@ -27,4 +27,4 @@ fn create_and_solve_subproblems<'data_provider, 'original_data, MP>(
) {
let _: AdaptedMatrixProvider<'original_data, MP> = tableau.provider().clone_with_extra_bound();
//~^ ERROR lifetime mismatch
}
} //~ ERROR `main` function not found in crate
12 changes: 3 additions & 9 deletions src/test/ui/continue-after-missing-main.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
error[E0601]: `main` function not found in crate `continue_after_missing_main`
--> $DIR/continue-after-missing-main.rs:1:1
--> $DIR/continue-after-missing-main.rs:30:2
|
LL | / #![allow(dead_code)]
LL | |
LL | | struct Tableau<'a, MP> {
LL | | provider: &'a MP,
... |
LL | |
LL | | }
| |_^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs`
LL | }
| ^ consider adding a `main` function to `$DIR/continue-after-missing-main.rs`

error[E0623]: lifetime mismatch
--> $DIR/continue-after-missing-main.rs:28:56
8 changes: 3 additions & 5 deletions src/test/ui/elided-test.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
error[E0601]: `main` function not found in crate `elided_test`
--> $DIR/elided-test.rs:5:1
--> $DIR/elided-test.rs:7:2
|
LL | / #[test]
LL | | fn main() {
LL | | }
| |_^ consider adding a `main` function to `$DIR/elided-test.rs`
LL | }
| ^ consider adding a `main` function to `$DIR/elided-test.rs`

error: aborting due to previous error

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![feature(imported_main)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
//~^^^ ERROR `main` function not found in crate
pub mod foo {
type MainFn = impl Fn();
//~^ ERROR could not find defining uses
@@ -11,4 +10,4 @@ pub mod foo {
//~^ ERROR mismatched types [E0308]
}

use foo::BAR as main;
use foo::BAR as main; //~ ERROR `main` function not found in crate
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
error[E0601]: `main` function not found in crate `imported_main_const_fn_item_type_forbidden`
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:1:1
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:13:22
|
LL | / #![feature(imported_main)]
LL | | #![feature(type_alias_impl_trait)]
LL | | #![allow(incomplete_features)]
LL | |
... |
LL | |
LL | | use foo::BAR as main;
| |_____----------------^ consider adding a `main` function to `$DIR/imported_main_const_fn_item_type_forbidden.rs`
| |
| non-function item at `crate::main` is found
LL | use foo::BAR as main;
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_fn_item_type_forbidden.rs`
| |
| non-function item at `crate::main` is found

error[E0308]: mismatched types
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:10:29
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:9:29
|
LL | type MainFn = impl Fn();
| --------- the expected opaque type
@@ -25,7 +19,7 @@ LL | pub const BAR: MainFn = bar;
found fn item `fn() {bar}`

error: could not find defining uses
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:6:19
--> $DIR/imported_main_const_fn_item_type_forbidden.rs:5:19
|
LL | type MainFn = impl Fn();
| ^^^^^^^^^
3 changes: 1 addition & 2 deletions src/test/ui/entry-point/imported_main_const_forbidden.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![feature(imported_main)]
//~^ ERROR `main` function not found in crate
pub mod foo {
pub const BAR: usize = 42;
}

use foo::BAR as main;
use foo::BAR as main; //~ ERROR `main` function not found in crate
16 changes: 5 additions & 11 deletions src/test/ui/entry-point/imported_main_const_forbidden.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
error[E0601]: `main` function not found in crate `imported_main_const_forbidden`
--> $DIR/imported_main_const_forbidden.rs:1:1
--> $DIR/imported_main_const_forbidden.rs:6:22
|
LL | / #![feature(imported_main)]
LL | |
LL | | pub mod foo {
LL | | pub const BAR: usize = 42;
LL | | }
LL | |
LL | | use foo::BAR as main;
| |_____----------------^ consider adding a `main` function to `$DIR/imported_main_const_forbidden.rs`
| |
| non-function item at `crate::main` is found
LL | use foo::BAR as main;
| ---------------- ^ consider adding a `main` function to `$DIR/imported_main_const_forbidden.rs`
| |
| non-function item at `crate::main` is found

error: aborting due to previous error

3 changes: 1 addition & 2 deletions src/test/ui/main-wrong-location.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mod m {
//~^ ERROR `main` function not found
// An inferred main entry point
// must appear at the top of the crate
fn main() { }
}
} //~ ERROR `main` function not found
13 changes: 4 additions & 9 deletions src/test/ui/main-wrong-location.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
error[E0601]: `main` function not found in crate `main_wrong_location`
--> $DIR/main-wrong-location.rs:1:1
--> $DIR/main-wrong-location.rs:5:2
|
LL | / mod m {
LL | |
LL | | // An inferred main entry point
LL | | // must appear at the top of the crate
LL | | fn main() { }
LL | | }
| |_^ the main function must be defined at the crate level (in `$DIR/main-wrong-location.rs`)
LL | }
| ^ the main function must be defined at the crate level (in `$DIR/main-wrong-location.rs`)
|
note: here is a function named `main`
--> $DIR/main-wrong-location.rs:5:5
--> $DIR/main-wrong-location.rs:4:5
|
LL | fn main() { }
| ^^^^^^^^^^^^^
4 changes: 2 additions & 2 deletions src/test/ui/missing/missing-main.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0601]: `main` function not found in crate `missing_main`
--> $DIR/missing-main.rs:2:1
--> $DIR/missing-main.rs:2:14
|
LL | fn mian() { }
| ^^^^^^^^^^^^^ consider adding a `main` function to `$DIR/missing-main.rs`
| ^ consider adding a `main` function to `$DIR/missing-main.rs`

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/parser/issues/issue-49040.stderr
Original file line number Diff line number Diff line change
@@ -5,10 +5,10 @@ LL | #![allow(unused_variables)];
| ^ help: remove this semicolon

error[E0601]: `main` function not found in crate `issue_49040`
--> $DIR/issue-49040.rs:1:1
--> $DIR/issue-49040.rs:1:29
|
LL | #![allow(unused_variables)];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `$DIR/issue-49040.rs`
| ^ consider adding a `main` function to `$DIR/issue-49040.rs`

error: aborting due to 2 previous errors

14 changes: 14 additions & 0 deletions src/test/ui/suggestions/type-ascription-instead-of-path-in-type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
enum A {
B,
}

fn main() {
let _: Vec<A:B> = A::B;
//~^ ERROR cannot find trait `B` in this scope
//~| HELP you might have meant to write a path instead of an associated type bound
//~| ERROR associated type bounds are unstable
//~| HELP add `#![feature(associated_type_bounds)]` to the crate attributes to enable
//~| ERROR struct takes at least 1 generic argument but 0 generic arguments were supplied
//~| HELP add missing generic argument
//~| ERROR associated type bindings are not allowed here
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
error[E0405]: cannot find trait `B` in this scope
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:18
|
LL | let _: Vec<A:B> = A::B;
| ^ not found in this scope
|
help: you might have meant to write a path instead of an associated type bound
|
LL | let _: Vec<A::B> = A::B;
| ~~

error[E0658]: associated type bounds are unstable
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:16
|
LL | let _: Vec<A:B> = A::B;
| ^^^
|
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable

error[E0107]: this struct takes at least 1 generic argument but 0 generic arguments were supplied
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:12
|
LL | let _: Vec<A:B> = A::B;
| ^^^ expected at least 1 generic argument
|
note: struct defined here, with at least 1 generic parameter: `T`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
| ^^^ -
help: add missing generic argument
|
LL | let _: Vec<T, A:B> = A::B;
| ++

error[E0229]: associated type bindings are not allowed here
--> $DIR/type-ascription-instead-of-path-in-type.rs:6:16
|
LL | let _: Vec<A:B> = A::B;
| ^^^ associated type not allowed here

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0107, E0229, E0405, E0658.
For more information about an error, try `rustc --explain E0107`.