Skip to content

Rollup of 7 pull requests #101777

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

Merged
merged 45 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
241807d
Allow multi-part inlay hint labels with location links
Aug 31, 2022
fcc6133
Remove alias definition naively
ice1000 Aug 23, 2022
79e5c36
Extract shared logic
ice1000 Aug 24, 2022
277df02
This should work, but I got mysterious errors
ice1000 Aug 24, 2022
37e20de
Address comments
ice1000 Aug 29, 2022
a695e90
Create `trait Removable`, replace `ted` APIs with builder APIs
ice1000 Sep 2, 2022
68eabf1
Fix test
ice1000 Sep 2, 2022
364d9c4
Fmt
ice1000 Sep 2, 2022
e295f0c
Insert whitespaces into static & const bodies if they are expanded fr…
ChayimFriedman2 Sep 4, 2022
26b5f1f
Do not insert a newline after `;` if the next token is a `}`
ChayimFriedman2 Sep 4, 2022
748567c
complete full struct in enum varaint
Austaras Sep 2, 2022
265c75c
fix: sort all bounds on trait object types
lowr Sep 5, 2022
a1c2653
Auto merge of #13091 - ice1k:hey, r=Veykril
bors Sep 5, 2022
4790916
Auto merge of #13139 - Austaras:enum, r=Veykril
bors Sep 5, 2022
5be2e65
Auto merge of #13185 - ChayimFriedman2:insert-ws-in-static-const-macr…
bors Sep 5, 2022
6dfd8ae
Auto merge of #13192 - lowr:fix/dyn-sort-all-bounds, r=Veykril
bors Sep 5, 2022
5d126a1
Use proc-macro-srv from sysroot in rust-project.json
Sep 7, 2022
6909556
Auto merge of #13200 - P1n3appl3:sysroot, r=Veykril
bors Sep 7, 2022
064c9ef
Make clicking closing brace hint go to the opening brace
Aug 31, 2022
c4eadab
Update crates/rust-analyzer/src/to_proto.rs
jonas-schievink Sep 8, 2022
4e1a3da
Auto merge of #13158 - jonas-schievink:inlayhint-links, r=jonas-schie…
bors Sep 8, 2022
c7fefd5
fix: add semicolon completion to mod
randomicon00 Sep 8, 2022
bd3feea
fix: removed swap file
randomicon00 Sep 8, 2022
b7e8b9a
Auto merge of #13207 - randomicon00:semicol#13196, r=lnicola
bors Sep 9, 2022
b0cfeec
translations(rustc_session): migrates session.rs and config.rs
beowolx Aug 26, 2022
54fe5b7
use ubuntu 18.04 container for release
SpencerSharkey Sep 9, 2022
329d501
translations(rustc_session): migrate output.rs
beowolx Sep 1, 2022
b843b88
revert conditional logic for apt update step
SpencerSharkey Sep 11, 2022
dd65588
install rustup directly
SpencerSharkey Sep 11, 2022
ae57150
add rustup bin to path
SpencerSharkey Sep 11, 2022
73d7599
use rustup minimal profile and add curl retries
SpencerSharkey Sep 11, 2022
2e9f120
Auto merge of #13214 - SpencerSharkey:ubuntu-container-build, r=lnicola
bors Sep 11, 2022
c4559eb
Improve Attribute doc methods
GuillaumeGomez Sep 12, 2022
b963228
rustdoc: remove no-op CSS `.search-results .result-name > span`
notriddle Sep 12, 2022
a4f8d3e
Fix doc of log function
NaokiM03 Sep 13, 2022
c93b070
:arrow_up: rust-analyzer
lnicola Sep 13, 2022
de184a6
Add documentation for TyCtxt::visibility
GuillaumeGomez Sep 13, 2022
e80ccd3
Rustdoc-Json: Don't loose subitems of foreign traits.
aDotInTheVoid Sep 13, 2022
bc8ec5e
Rollup merge of #101266 - LuisCardosoOliveira:translation-rustcsessio…
matthiaskrgr Sep 13, 2022
f80b38b
Rollup merge of #101737 - notriddle:notriddle/search-results-result-n…
matthiaskrgr Sep 13, 2022
8fa8021
Rollup merge of #101752 - GuillaumeGomez:improve-attr-docs, r=lqd
matthiaskrgr Sep 13, 2022
e44073b
Rollup merge of #101754 - NaokiM03:rename-log-to-ilog, r=Dylan-DPC
matthiaskrgr Sep 13, 2022
2f6874d
Rollup merge of #101759 - lnicola:rust-analyzer-2022-09-13, r=lnicola
matthiaskrgr Sep 13, 2022
68dc639
Rollup merge of #101765 - GuillaumeGomez:tyctxt-visibility-doc, r=jyn514
matthiaskrgr Sep 13, 2022
f04eee1
Rollup merge of #101770 - aDotInTheVoid:rdj-index-clone, r=GuillaumeG…
matthiaskrgr Sep 13, 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
12 changes: 11 additions & 1 deletion compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,20 @@ impl AttrItem {

impl Attribute {
/// Returns `true` if it is a sugared doc comment (`///` or `//!` for example).
/// So `#[doc = "doc"]` will return `false`.
/// So `#[doc = "doc"]` (which is a doc comment) and `#[doc(...)]` (which is not
/// a doc comment) will return `false`.
pub fn is_doc_comment(&self) -> bool {
match self.kind {
AttrKind::Normal(..) => false,
AttrKind::DocComment(..) => true,
}
}

/// Returns the documentation and its kind if this is a doc comment or a sugared doc comment.
/// * `///doc` returns `Some(("doc", CommentKind::Line))`.
/// * `/** doc */` returns `Some(("doc", CommentKind::Block))`.
/// * `#[doc = "doc"]` returns `Some(("doc", CommentKind::Line))`.
/// * `#[doc(...)]` returns `None`.
pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> {
match self.kind {
AttrKind::DocComment(kind, data) => Some((data, kind)),
Expand All @@ -252,6 +258,10 @@ impl Attribute {
}
}

/// Returns the documentation if this is a doc comment or a sugared doc comment.
/// * `///doc` returns `Some("doc")`.
/// * `#[doc = "doc"]` returns `Some("doc")`.
/// * `#[doc(...)]` returns `None`.
pub fn doc_str(&self) -> Option<Symbol> {
match self.kind {
AttrKind::DocComment(.., data) => Some(data),
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/session.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ session_target_invalid_bits_size = {$err}
session_target_stack_protector_not_supported = `-Z stack-protector={$stack_protector}` is not supported for target {$target_triple} and will be ignored

session_split_debuginfo_unstable_platform = `-Csplit-debuginfo={$debuginfo}` is unstable on this platform

session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions

session_crate_name_does_not_match = `--crate-name` and `#[crate_name]` are required to match, but `{$s}` != `{$name}`

session_crate_name_invalid = crate names cannot start with a `-`, but `{$s}` has a leading hyphen

session_crate_name_empty = crate name must not be empty

session_invalid_character_in_create_name = invalid character `{$character}` in crate name: `{$crate_name}`
2 changes: 1 addition & 1 deletion compiler/rustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" }
rustc_macros = { path = "../rustc_macros" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_target = { path = "../rustc_target" }
rustc_hir = { path = "../rustc_hir" }
rustc_lint_defs = { path = "../rustc_lint_defs" }
rustc_target = { path = "../rustc_target" }
unicode-width = "0.1.4"
atty = "0.2"
termcolor = "1.0"
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,16 @@ rustc_queries! {
desc { "looking up late bound vars" }
}

/// Computes the visibility of the provided `def_id`.
///
/// If the item from the `def_id` doesn't have a visibility, it will panic. For example
/// a generic type parameter will panic if you call this method on it:
///
/// ```
/// pub trait Foo<T: Debug> {}
/// ```
///
/// In here, if you call `visibility` on `T`, it'll panic.
query visibility(def_id: DefId) -> ty::Visibility<DefId> {
desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
separate_provide_extern
Expand Down
51 changes: 50 additions & 1 deletion compiler/rustc_session/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::num::NonZeroU32;

use crate::cgu_reuse_tracker::CguReuse;
use crate::{self as rustc_session, SessionDiagnostic};
use rustc_errors::{fluent, DiagnosticBuilder, Handler, MultiSpan};
use rustc_errors::{fluent, DiagnosticBuilder, ErrorGuaranteed, Handler, MultiSpan};
use rustc_macros::SessionDiagnostic;
use rustc_span::{Span, Symbol};
use rustc_target::abi::TargetDataLayoutErrors;
Expand Down Expand Up @@ -170,3 +170,52 @@ pub struct StackProtectorNotSupportedForTarget<'a> {
pub struct SplitDebugInfoUnstablePlatform {
pub debuginfo: SplitDebuginfo,
}

#[derive(SessionDiagnostic)]
#[diag(session::file_is_not_writeable)]
pub struct FileIsNotWriteable<'a> {
pub file: &'a std::path::Path,
}

#[derive(SessionDiagnostic)]
#[diag(session::crate_name_does_not_match)]
pub struct CrateNameDoesNotMatch<'a> {
#[primary_span]
pub span: Span,
pub s: &'a str,
pub name: Symbol,
}

#[derive(SessionDiagnostic)]
#[diag(session::crate_name_invalid)]
pub struct CrateNameInvalid<'a> {
pub s: &'a str,
}

#[derive(SessionDiagnostic)]
#[diag(session::crate_name_empty)]
pub struct CrateNameEmpty {
#[primary_span]
pub span: Option<Span>,
}

pub struct InvalidCharacterInCrateName<'a> {
pub span: Option<Span>,
pub character: char,
pub crate_name: &'a str,
}

impl crate::SessionDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
fn into_diagnostic(
self,
sess: &Handler,
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = sess.struct_err(fluent::session::invalid_character_in_create_name);
if let Some(sp) = self.span {
diag.set_span(sp);
}
diag.set_arg("character", self.character);
diag.set_arg("crate_name", self.crate_name);
diag
}
}
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#![feature(map_many_mut)]
#![recursion_limit = "256"]
#![allow(rustc::potential_query_instability)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]

#[macro_use]
extern crate rustc_macros;
Expand Down
35 changes: 11 additions & 24 deletions compiler/rustc_session/src/output.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! Related to out filenames of compilation (e.g. save analysis, binaries).
use crate::config::{CrateType, Input, OutputFilenames, OutputType};
use crate::errors::{
CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable,
InvalidCharacterInCrateName,
};
use crate::Session;
use rustc_ast as ast;
use rustc_span::symbol::sym;
Expand Down Expand Up @@ -30,11 +34,7 @@ pub fn out_filename(
/// read-only file. We should be consistent.
pub fn check_file_is_writeable(file: &Path, sess: &Session) {
if !is_writeable(file) {
sess.fatal(&format!(
"output file {} is not writeable -- check its \
permissions",
file.display()
));
sess.emit_fatal(FileIsNotWriteable { file });
}
}

Expand All @@ -61,11 +61,7 @@ pub fn find_crate_name(sess: &Session, attrs: &[ast::Attribute], input: &Input)
if let Some(ref s) = sess.opts.crate_name {
if let Some((attr, name)) = attr_crate_name {
if name.as_str() != s {
let msg = format!(
"`--crate-name` and `#[crate_name]` are \
required to match, but `{s}` != `{name}`"
);
sess.span_err(attr.span, &msg);
sess.emit_err(CrateNameDoesNotMatch { span: attr.span, s, name });
}
}
return validate(s.clone(), None);
Expand All @@ -77,11 +73,7 @@ pub fn find_crate_name(sess: &Session, attrs: &[ast::Attribute], input: &Input)
if let Input::File(ref path) = *input {
if let Some(s) = path.file_stem().and_then(|s| s.to_str()) {
if s.starts_with('-') {
let msg = format!(
"crate names cannot start with a `-`, but \
`{s}` has a leading hyphen"
);
sess.err(&msg);
sess.emit_err(CrateNameInvalid { s });
} else {
return validate(s.replace('-', "_"), None);
}
Expand All @@ -94,15 +86,9 @@ pub fn find_crate_name(sess: &Session, attrs: &[ast::Attribute], input: &Input)
pub fn validate_crate_name(sess: &Session, s: &str, sp: Option<Span>) {
let mut err_count = 0;
{
let mut say = |s: &str| {
match sp {
Some(sp) => sess.span_err(sp, s),
None => sess.err(s),
};
err_count += 1;
};
if s.is_empty() {
say("crate name must not be empty");
err_count += 1;
sess.emit_err(CrateNameEmpty { span: sp });
}
for c in s.chars() {
if c.is_alphanumeric() {
Expand All @@ -111,7 +97,8 @@ pub fn validate_crate_name(sess: &Session, s: &str, sp: Option<Span>) {
if c == '_' {
continue;
}
say(&format!("invalid character `{c}` in crate name: `{s}`"));
err_count += 1;
sess.emit_err(InvalidCharacterInCrateName { span: sp, character: c, crate_name: s });
}
}

Expand Down
Loading